Socket
Socket
Sign inDemoInstall

@hiogawa/tiny-toast

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hiogawa/tiny-toast - npm Package Compare versions

Comparing version 0.0.1-pre.8 to 0.0.1-pre.9

6

./dist/index.js

@@ -54,7 +54,3 @@ // src/utils.ts

paused = false;
defaultCoreOptions = {
duration: 4e3
};
create(data, options) {
const duration = options?.duration ?? this.defaultCoreOptions.duration;
create(data, { duration }) {
const item = {

@@ -61,0 +57,0 @@ id: generateId(),

3

dist/index.d.ts

@@ -38,4 +38,3 @@ type PauseableTimeoutState = {

paused: boolean;
defaultCoreOptions: ToastCoreOptions;
create(data: T, options?: Partial<ToastCoreOptions>): void;
create(data: T, { duration }: ToastCoreOptions): void;
update(id: string, newItem: Partial<ToastItem<T>>): void;

@@ -42,0 +41,0 @@ dismiss(id: string): void;

@@ -54,7 +54,3 @@ // src/utils.ts

paused = false;
defaultCoreOptions = {
duration: 4e3
};
create(data, options) {
const duration = options?.duration ?? this.defaultCoreOptions.duration;
create(data, { duration }) {
const item = {

@@ -61,0 +57,0 @@ id: generateId(),

@@ -8,4 +8,8 @@ import React from 'react';

type ToastType = (typeof TOAST_TYPES)[number];
type RenderReactNode = (props: {
item: ReactToastItem;
toast: ReactToastManager;
}) => React.ReactNode;
interface ReactToastData {
node: React.ReactNode;
render: RenderReactNode;
position: ToastPosition;

@@ -16,11 +20,12 @@ type?: ToastType;

}
type ReactToastOptions = Omit<ReactToastData, "node">;
type ReactToastItem = ToastItem<ReactToastData>;
type ReactToastOptions = Omit<ReactToastData, "render"> & Pick<ReactToastItem, "duration">;
declare class ReactToastManager extends ToastManager<ReactToastData> {
defaultOptions: ReactToastOptions;
success: (this: ReactToastManager, node: React.ReactNode, options?: Partial<ReactToastOptions & ToastCoreOptions> | undefined) => void;
error: (this: ReactToastManager, node: React.ReactNode, options?: Partial<ReactToastOptions & ToastCoreOptions> | undefined) => void;
info: (this: ReactToastManager, node: React.ReactNode, options?: Partial<ReactToastOptions & ToastCoreOptions> | undefined) => void;
blank: (this: ReactToastManager, node: React.ReactNode, options?: Partial<ReactToastOptions & ToastCoreOptions> | undefined) => void;
custom: (this: ReactToastManager, node: React.ReactNode, options?: Partial<ReactToastOptions & ToastCoreOptions> | undefined) => void;
defaultOptions?: Partial<ReactToastOptions> | undefined;
constructor(defaultOptions?: Partial<ReactToastOptions> | undefined);
success: (this: ReactToastManager, node: React.ReactNode | RenderReactNode, options?: Partial<Omit<ReactToastData, "render"> & Pick<ReactToastItem, "duration"> & ToastCoreOptions> | undefined) => void;
error: (this: ReactToastManager, node: React.ReactNode | RenderReactNode, options?: Partial<Omit<ReactToastData, "render"> & Pick<ReactToastItem, "duration"> & ToastCoreOptions> | undefined) => void;
info: (this: ReactToastManager, node: React.ReactNode | RenderReactNode, options?: Partial<Omit<ReactToastData, "render"> & Pick<ReactToastItem, "duration"> & ToastCoreOptions> | undefined) => void;
blank: (this: ReactToastManager, node: React.ReactNode | RenderReactNode, options?: Partial<Omit<ReactToastData, "render"> & Pick<ReactToastItem, "duration"> & ToastCoreOptions> | undefined) => void;
custom: (this: ReactToastManager, node: React.ReactNode | RenderReactNode, options?: Partial<Omit<ReactToastData, "render"> & Pick<ReactToastItem, "duration"> & ToastCoreOptions> | undefined) => void;
}

@@ -35,6 +40,2 @@ type ReactToastContainerOptions = {

}) => React.ReactNode;
renderItem?: (props: {
item: ReactToastItem;
toast: ReactToastManager;
}) => React.ReactNode;
};

@@ -41,0 +42,0 @@

@@ -57,7 +57,3 @@ // src/utils.ts

paused = false;
defaultCoreOptions = {
duration: 4e3
};
create(data, options) {
const duration = options?.duration ?? this.defaultCoreOptions.duration;
create(data, { duration }) {
const item = {

@@ -142,8 +138,12 @@ id: generateId(),

];
var DEFAULT_OPTIONS = {
duration: 4e3,
position: "top-center",
type: "blank"
};
var ReactToastManager = class extends ToastManager {
// TODO: api is awkward... use constructor?
defaultOptions = {
position: "top-center",
type: "blank"
};
constructor(defaultOptions) {
super();
this.defaultOptions = defaultOptions;
}
success = createByTypeFactory("success");

@@ -159,3 +159,4 @@ error = createByTypeFactory("error");

{
node,
render: typeof node === "function" ? node : () => node,
...DEFAULT_OPTIONS,
...this.defaultOptions,

@@ -165,3 +166,6 @@ ...options,

},
options
{
...DEFAULT_OPTIONS,
...this.defaultOptions
}
);

@@ -477,7 +481,6 @@ };

const renderAnimation = options?.renderAnimation ?? ((props) => /* @__PURE__ */ React8.createElement(AnimationWrapper, { ...props }));
const renderItem = options?.renderItem ?? ((props) => /* @__PURE__ */ React8.createElement(ItemComponent, { ...props }));
const render = (item) => /* @__PURE__ */ React8.createElement(React8.Fragment, { key: item.id }, renderAnimation({
toast,
item,
children: renderItem({ toast, item })
children: /* @__PURE__ */ React8.createElement(ItemComponent, { toast, item })
}));

@@ -585,5 +588,8 @@ return /* @__PURE__ */ React8.createElement(

}
function ItemComponent({ item }) {
function ItemComponent({
item,
toast
}) {
if (item.data.type === "custom") {
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, item.data.node);
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, item.data.render({ item, toast }));
}

@@ -605,3 +611,3 @@ return /* @__PURE__ */ React8.createElement(

}
), /* @__PURE__ */ React8.createElement("div", { className: "uno-tiny-toast-gshazv" }, item.data.node))
), /* @__PURE__ */ React8.createElement("div", { className: "uno-tiny-toast-gshazv" }, item.data.render({ item, toast })))
);

@@ -608,0 +614,0 @@ }

{
"name": "@hiogawa/tiny-toast",
"version": "0.0.1-pre.8",
"version": "0.0.1-pre.9",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc