@yamada-ui/notice 1.1.5-next-20241005220055 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,7 +42,7 @@ var findId = (options, id) => options.find((notice) => notice.id === id);
42
42
  var findNotice = (state, id) => {
43
43
  const placement = getNoticePlacement(state, id);
44
44
  const index = placement ? state[placement].findIndex((notice) => notice.id === id) : -1;
45
- return { placement, index };
45
+ return { index, placement };
46
46
  };
47
47
  var getNoticePlacement = (state, id) => {
48
48
  for (const [placement, values] of Object.entries(state)) {
@@ -52,24 +52,24 @@ var getNoticePlacement = (state, id) => {
52
52
  var counter = 0;
53
53
  var createNotice = (message, {
54
54
  id,
55
- placement = "top",
55
+ style,
56
56
  duration,
57
- onCloseComplete,
57
+ placement = "top",
58
58
  status,
59
- style
59
+ onCloseComplete
60
60
  }) => {
61
61
  counter += 1;
62
62
  id != null ? id : id = counter;
63
63
  return {
64
64
  id,
65
- placement,
66
- status,
65
+ style,
67
66
  duration,
68
- message,
69
- onDelete: () => noticeStore.remove(String(id), placement),
70
67
  isDelete: false,
68
+ message,
69
+ placement,
70
+ status,
71
71
  onCloseComplete,
72
- style
72
+ onDelete: () => noticeStore.remove(String(id), placement)
73
73
  };
74
74
  };
75
75
  var createRender = (options) => {
@@ -84,12 +84,12 @@ var createRender = (options) => {
84
84
  return Render;
85
85
  };
86
86
  var initialState = {
87
- top: [],
88
- "top-left": [],
89
- "top-right": [],
90
87
  bottom: [],
91
88
  "bottom-left": [],
92
- "bottom-right": []
89
+ "bottom-right": [],
90
+ top: [],
91
+ "top-left": [],
92
+ "top-right": []
93
93
  };
94
94
  var createNoticeStore = (initialState2) => {
95
95
  let state = initialState2;
@@ -99,27 +99,47 @@ var createNoticeStore = (initialState2) => {
99
99
  storeChangeCache.forEach((onStoreChange) => onStoreChange());
100
100
  };
101
101
  return {
102
- getSnapshot: () => state,
103
- subscribe: (onStoreChange) => {
104
- storeChangeCache.add(onStoreChange);
105
- return () => {
106
- setState(() => initialState2);
107
- storeChangeCache.delete(onStoreChange);
108
- };
102
+ close: (id) => {
103
+ setState((prev) => {
104
+ const placement = getNoticePlacement(prev, id);
105
+ if (!placement) return prev;
106
+ return {
107
+ ...prev,
108
+ [placement]: prev[placement].map(
109
+ (notice) => notice.id == id ? { ...notice, isDelete: true } : notice
110
+ )
111
+ };
112
+ });
109
113
  },
110
- remove: (id, placement) => {
111
- setState((prevState) => ({
112
- ...prevState,
113
- [placement]: prevState[placement].filter((notice) => notice.id != id)
114
- }));
114
+ closeAll: ({ placement } = {}) => {
115
+ setState((prev) => {
116
+ let placements = [
117
+ "bottom",
118
+ "bottom-right",
119
+ "bottom-left",
120
+ "top",
121
+ "top-left",
122
+ "top-right"
123
+ ];
124
+ if (placement) placements = placement;
125
+ return placements.reduce(
126
+ (acc, placement2) => {
127
+ acc[placement2] = prev[placement2].map((notice) => ({
128
+ ...notice,
129
+ isDelete: true
130
+ }));
131
+ return acc;
132
+ },
133
+ { ...prev }
134
+ );
135
+ });
115
136
  },
116
137
  create: (message, options) => {
117
138
  const limit = options.limit;
118
139
  const notice = createNotice(message, options);
119
- const { placement, id } = notice;
140
+ const { id, placement } = notice;
120
141
  setState((prev) => {
121
- var _a;
122
- let prevNotices = (_a = prev[placement]) != null ? _a : [];
142
+ let prevNotices = prev[placement];
123
143
  if (limit !== void 0 && limit > 0 && prevNotices.length > limit - 1) {
124
144
  const n = prevNotices.length - (limit - 1);
125
145
  const notices2 = placement.includes("top") ? prevNotices.slice(n * -1) : prevNotices.slice(0, n);
@@ -133,11 +153,26 @@ var createNoticeStore = (initialState2) => {
133
153
  });
134
154
  return id;
135
155
  },
156
+ getSnapshot: () => state,
157
+ isActive: (id) => Boolean(findNotice(noticeStore.getSnapshot(), id).placement),
158
+ remove: (id, placement) => {
159
+ setState((prevState) => ({
160
+ ...prevState,
161
+ [placement]: prevState[placement].filter((notice) => notice.id != id)
162
+ }));
163
+ },
164
+ subscribe: (onStoreChange) => {
165
+ storeChangeCache.add(onStoreChange);
166
+ return () => {
167
+ setState(() => initialState2);
168
+ storeChangeCache.delete(onStoreChange);
169
+ };
170
+ },
136
171
  update: (id, options) => {
137
172
  setState((prev) => {
138
173
  const next = { ...prev };
139
- const { placement, index } = findNotice(next, id);
140
- if (placement && index !== -1) {
174
+ const { index, placement } = findNotice(next, id);
175
+ if (placement && index !== -1 && next[placement][index]) {
141
176
  next[placement][index] = {
142
177
  ...next[placement][index],
143
178
  ...options,
@@ -146,56 +181,20 @@ var createNoticeStore = (initialState2) => {
146
181
  }
147
182
  return next;
148
183
  });
149
- },
150
- closeAll: ({ placement } = {}) => {
151
- setState((prev) => {
152
- let placements = [
153
- "bottom",
154
- "bottom-right",
155
- "bottom-left",
156
- "top",
157
- "top-left",
158
- "top-right"
159
- ];
160
- if (placement) placements = placement;
161
- return placements.reduce(
162
- (acc, placement2) => {
163
- acc[placement2] = prev[placement2].map((notice) => ({
164
- ...notice,
165
- isDelete: true
166
- }));
167
- return acc;
168
- },
169
- { ...prev }
170
- );
171
- });
172
- },
173
- close: (id) => {
174
- setState((prev) => {
175
- const placement = getNoticePlacement(prev, id);
176
- if (!placement) return prev;
177
- return {
178
- ...prev,
179
- [placement]: prev[placement].map(
180
- (notice) => notice.id == id ? { ...notice, isDelete: true } : notice
181
- )
182
- };
183
- });
184
- },
185
- isActive: (id) => Boolean(findNotice(noticeStore.getSnapshot(), id).placement)
184
+ }
186
185
  };
187
186
  };
188
187
  var noticeStore = createNoticeStore(initialState);
189
188
  var Notice = ({
190
- variant = "basic",
189
+ className,
191
190
  colorScheme,
192
- status,
193
- icon,
194
- title,
191
+ variant = "basic",
192
+ closeStrategy = "button",
195
193
  description,
194
+ icon,
196
195
  isClosable,
197
- closeStrategy = "button",
198
- className,
196
+ status,
197
+ title,
199
198
  onClose
200
199
  }) => {
201
200
  const isButtonClosable = isClosable && (closeStrategy === "button" || closeStrategy === "both");
@@ -203,20 +202,20 @@ var Notice = ({
203
202
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
204
203
  import_alert.Alert,
205
204
  {
206
- status,
207
- variant,
205
+ className: (0, import_utils.cx)("ui-notice", className),
208
206
  colorScheme,
207
+ variant,
209
208
  alignItems: "start",
210
209
  boxShadow: "fallback(lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",
211
- className: (0, import_utils.cx)("ui-notice", className),
212
210
  pe: isButtonClosable ? 8 : void 0,
211
+ status,
213
212
  onClick: isElementClosable ? onClose : void 0,
214
213
  children: [
215
214
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
215
  import_alert.AlertIcon,
217
216
  {
218
- variant: icon == null ? void 0 : icon.variant,
219
217
  className: "ui-notice__icon",
218
+ variant: icon == null ? void 0 : icon.variant,
220
219
  ...(icon == null ? void 0 : icon.color) ? { color: icon.color } : {},
221
220
  children: icon == null ? void 0 : icon.children
222
221
  }
@@ -230,13 +229,13 @@ var Notice = ({
230
229
  {
231
230
  className: "ui-notice__close-button",
232
231
  size: "sm",
232
+ position: "absolute",
233
+ right: 2,
234
+ top: 2,
233
235
  onClick: (ev) => {
234
236
  ev.stopPropagation();
235
237
  onClose == null ? void 0 : onClose();
236
- },
237
- position: "absolute",
238
- top: 2,
239
- right: 2
238
+ }
240
239
  }
241
240
  ) : null
242
241
  ]
@@ -247,12 +246,12 @@ var Notice = ({
247
246
  // src/notice-provider.tsx
248
247
  var import_jsx_runtime2 = require("react/jsx-runtime");
249
248
  var NoticeProvider = ({
250
- variants,
251
- gap = "fallback(4, 1rem)",
252
249
  appendToParentPortal,
253
- listProps,
250
+ containerRef,
251
+ gap = "fallback(4, 1rem)",
252
+ variants,
254
253
  itemProps,
255
- containerRef
254
+ listProps
256
255
  }) => {
257
256
  const state = (0, import_react2.useSyncExternalStore)(
258
257
  noticeStore.subscribe,
@@ -265,17 +264,17 @@ var NoticeProvider = ({
265
264
  const right = !placement.includes("left") ? "env(safe-area-inset-right, 0px)" : void 0;
266
265
  const left = !placement.includes("right") ? "env(safe-area-inset-left, 0px)" : void 0;
267
266
  const css = {
268
- position: "fixed",
269
- zIndex: "fallback(zarbon, 160)",
270
- pointerEvents: "none",
267
+ bottom,
271
268
  display: "flex",
272
269
  flexDirection: "column",
273
- margin: gap,
274
270
  gap,
275
- top,
276
- bottom,
271
+ left,
272
+ margin: gap,
273
+ pointerEvents: "none",
274
+ position: "fixed",
277
275
  right,
278
- left
276
+ top,
277
+ zIndex: "fallback(zarbon, 160)"
279
278
  };
280
279
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
281
280
  import_core2.ui.ul,
@@ -306,19 +305,15 @@ var NoticeProvider = ({
306
305
  );
307
306
  };
308
307
  var defaultVariants = {
309
- initial: ({ placement }) => ({
310
- opacity: 0,
311
- [["top", "bottom"].includes(placement) ? "y" : "x"]: (placement === "bottom" ? 1 : placement.includes("right") ? 1 : -1) * 24
312
- }),
313
308
  animate: {
314
309
  opacity: 1,
315
- y: 0,
316
- x: 0,
317
310
  scale: 1,
318
311
  transition: {
319
312
  duration: 0.4,
320
313
  ease: [0.4, 0, 0.2, 1]
321
- }
314
+ },
315
+ x: 0,
316
+ y: 0
322
317
  },
323
318
  exit: {
324
319
  opacity: 0,
@@ -327,19 +322,23 @@ var defaultVariants = {
327
322
  duration: 0.2,
328
323
  ease: [0.4, 0, 1, 1]
329
324
  }
330
- }
325
+ },
326
+ initial: ({ placement }) => ({
327
+ [["bottom", "top"].includes(placement) ? "y" : "x"]: (placement === "bottom" ? 1 : placement.includes("right") ? 1 : -1) * 24,
328
+ opacity: 0
329
+ })
331
330
  };
332
331
  var NoticeComponent = (0, import_react2.memo)(
333
332
  ({
334
- variants = defaultVariants,
335
- itemProps,
336
- placement,
333
+ style,
337
334
  duration = 5e3,
335
+ isDelete = false,
338
336
  message,
337
+ placement,
338
+ variants = defaultVariants,
339
+ itemProps,
339
340
  onCloseComplete,
340
- isDelete = false,
341
- onDelete,
342
- style
341
+ onDelete
343
342
  }) => {
344
343
  const [delay, setDelay] = (0, import_react2.useState)(duration);
345
344
  const isPresent = (0, import_motion.useIsPresent)();
@@ -359,27 +358,27 @@ var NoticeComponent = (0, import_react2.memo)(
359
358
  }, [isPresent, isDelete, onDelete]);
360
359
  (0, import_use_timeout.useTimeout)(onClose, delay);
361
360
  const css = {
362
- pointerEvents: "auto",
363
361
  maxW: "36rem",
364
362
  minW: "20rem",
363
+ pointerEvents: "auto",
365
364
  ...style
366
365
  };
367
366
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
368
367
  import_motion.motion.li,
369
368
  {
370
- layout: true,
371
369
  className: "ui-notice__list__item",
372
- variants,
373
- initial: "initial",
374
- animate: "animate",
375
- exit: "exit",
376
- onHoverStart: onMouseEnter,
377
- onHoverEnd: onMouseLeave,
378
- custom: { placement },
379
370
  style: {
380
371
  display: "flex",
381
372
  justifyContent: placement.includes("left") ? "flex-start" : placement.includes("right") ? "flex-end" : "center"
382
373
  },
374
+ animate: "animate",
375
+ custom: { placement },
376
+ exit: "exit",
377
+ initial: "initial",
378
+ layout: true,
379
+ variants,
380
+ onHoverEnd: onMouseLeave,
381
+ onHoverStart: onMouseEnter,
383
382
  ...itemProps,
384
383
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { className: "ui-notice__list__item__inner", __css: css, children: (0, import_utils2.runIfFunc)(message, { onClose }) })
385
384
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/notice-provider.tsx","../src/notice.tsx"],"sourcesContent":["import type { CSSUIObject, ThemeConfig } from \"@yamada-ui/core\"\nimport { ui } from \"@yamada-ui/core\"\nimport type { MotionVariants, MotionStyle } from \"@yamada-ui/motion\"\nimport { AnimatePresence, motion, useIsPresent } from \"@yamada-ui/motion\"\nimport { Portal } from \"@yamada-ui/portal\"\nimport { useTimeout } from \"@yamada-ui/use-timeout\"\nimport { cx, runIfFunc, useUpdateEffect } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { memo, useEffect, useState, useSyncExternalStore } from \"react\"\nimport type { NoticeOptions } from \"./notice\"\nimport { noticeStore } from \"./notice\"\n\nexport interface NoticeProviderProps\n extends Omit<Required<ThemeConfig>[\"notice\"], \"options\"> {}\n\nexport const NoticeProvider: FC<NoticeProviderProps> = ({\n variants,\n gap = \"fallback(4, 1rem)\",\n appendToParentPortal,\n listProps,\n itemProps,\n containerRef,\n}) => {\n const state = useSyncExternalStore(\n noticeStore.subscribe,\n noticeStore.getSnapshot,\n noticeStore.getSnapshot,\n )\n\n const components = Object.entries(state).map(([placement, notices]) => {\n const top = placement.includes(\"top\")\n ? \"env(safe-area-inset-top, 0px)\"\n : undefined\n const bottom = placement.includes(\"bottom\")\n ? \"env(safe-area-inset-bottom, 0px)\"\n : undefined\n const right = !placement.includes(\"left\")\n ? \"env(safe-area-inset-right, 0px)\"\n : undefined\n const left = !placement.includes(\"right\")\n ? \"env(safe-area-inset-left, 0px)\"\n : undefined\n\n const css: CSSUIObject = {\n position: \"fixed\",\n zIndex: \"fallback(zarbon, 160)\",\n pointerEvents: \"none\",\n display: \"flex\",\n flexDirection: \"column\",\n margin: gap,\n gap,\n top,\n bottom,\n right,\n left,\n }\n\n return (\n <ui.ul\n key={placement}\n className={cx(\"ui-notice__list\", `ui-notice__list--${placement}`)}\n __css={css}\n {...listProps}\n >\n <AnimatePresence initial={false}>\n {notices.map((notice) => (\n <NoticeComponent\n key={notice.id}\n variants={variants}\n itemProps={itemProps}\n {...notice}\n />\n ))}\n </AnimatePresence>\n </ui.ul>\n )\n })\n\n return (\n <Portal\n appendToParentPortal={appendToParentPortal}\n containerRef={containerRef}\n >\n {components}\n </Portal>\n )\n}\n\nconst defaultVariants: MotionVariants = {\n initial: ({ placement }) => ({\n opacity: 0,\n [[\"top\", \"bottom\"].includes(placement) ? \"y\" : \"x\"]:\n (placement === \"bottom\" ? 1 : placement.includes(\"right\") ? 1 : -1) * 24,\n }),\n animate: {\n opacity: 1,\n y: 0,\n x: 0,\n scale: 1,\n transition: {\n duration: 0.4,\n ease: [0.4, 0, 0.2, 1],\n },\n },\n exit: {\n opacity: 0,\n scale: 0.95,\n transition: {\n duration: 0.2,\n ease: [0.4, 0, 1, 1],\n },\n },\n}\n\ninterface NoticeComponentProps\n extends NoticeOptions,\n Pick<NoticeProviderProps, \"variants\" | \"itemProps\"> {}\n\nconst NoticeComponent = memo(\n ({\n variants = defaultVariants,\n itemProps,\n placement,\n duration = 5000,\n message,\n onCloseComplete,\n isDelete = false,\n onDelete,\n style,\n }: NoticeComponentProps) => {\n const [delay, setDelay] = useState(duration)\n const isPresent = useIsPresent()\n\n useUpdateEffect(() => {\n if (!isPresent) onCloseComplete?.()\n }, [isPresent])\n\n useUpdateEffect(() => {\n setDelay(duration)\n }, [duration])\n\n const onMouseEnter = () => setDelay(null)\n const onMouseLeave = () => setDelay(duration)\n\n const onClose = () => {\n if (isPresent) onDelete()\n }\n\n useEffect(() => {\n if (isPresent && isDelete) onDelete()\n }, [isPresent, isDelete, onDelete])\n\n useTimeout(onClose, delay)\n\n const css: CSSUIObject = {\n pointerEvents: \"auto\",\n maxW: \"36rem\",\n minW: \"20rem\",\n ...style,\n }\n\n return (\n <motion.li\n layout\n className=\"ui-notice__list__item\"\n variants={variants}\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n onHoverStart={onMouseEnter}\n onHoverEnd={onMouseLeave}\n custom={{ placement }}\n style={\n {\n display: \"flex\",\n justifyContent: placement.includes(\"left\")\n ? \"flex-start\"\n : placement.includes(\"right\")\n ? \"flex-end\"\n : \"center\",\n } as MotionStyle\n }\n {...itemProps}\n >\n <ui.div className=\"ui-notice__list__item__inner\" __css={css}>\n {runIfFunc(message, { onClose })}\n </ui.div>\n </motion.li>\n )\n },\n)\n\nNoticeComponent.displayName = \"NoticeComponent\"\n","import type { AlertProps } from \"@yamada-ui/alert\"\nimport {\n Alert,\n AlertDescription,\n AlertIcon,\n AlertTitle,\n} from \"@yamada-ui/alert\"\nimport { CloseButton } from \"@yamada-ui/close-button\"\nimport type {\n CSSUIObject,\n NoticePlacement,\n NoticeComponentProps,\n NoticeConfigOptions,\n StyledTheme,\n} from \"@yamada-ui/core\"\nimport { ui, useTheme } from \"@yamada-ui/core\"\nimport { cx, merge } from \"@yamada-ui/utils\"\nimport type { FC, ReactNode } from \"react\"\nimport { useMemo } from \"react\"\n\nexport interface UseNoticeOptions extends NoticeConfigOptions {}\n\nexport interface NoticeOptions {\n id: string | number\n placement: NoticePlacement\n duration: UseNoticeOptions[\"duration\"]\n status: UseNoticeOptions[\"status\"]\n message: (props: NoticeComponentProps) => ReactNode\n isDelete?: boolean\n onDelete: () => void\n onCloseComplete?: () => void\n style?: CSSUIObject\n}\n\nconst findId = (\n options: NoticeOptions[],\n id: string | number,\n): NoticeOptions | undefined => options.find((notice) => notice.id === id)\n\nconst findNotice = (\n state: State,\n id: string | number,\n): {\n placement: NoticePlacement | undefined\n index: number\n} => {\n const placement = getNoticePlacement(state, id)\n\n const index = placement\n ? state[placement].findIndex((notice) => notice.id === id)\n : -1\n\n return { placement, index }\n}\n\nconst getNoticePlacement = (\n state: State,\n id: string | number,\n): NoticePlacement | undefined => {\n for (const [placement, values] of Object.entries(state)) {\n if (findId(values, id)) return placement as NoticePlacement\n }\n}\n\ninterface CreateNoticeOptions\n extends Partial<\n Pick<\n NoticeOptions,\n \"id\" | \"placement\" | \"status\" | \"duration\" | \"onCloseComplete\" | \"style\"\n >\n > {}\n\nlet counter = 0\n\nconst createNotice = (\n message: (props: NoticeComponentProps) => ReactNode,\n {\n id,\n placement = \"top\",\n duration,\n onCloseComplete,\n status,\n style,\n }: CreateNoticeOptions,\n) => {\n counter += 1\n\n id ??= counter\n\n return {\n id,\n placement,\n status,\n duration,\n message,\n onDelete: () => noticeStore.remove(String(id), placement),\n isDelete: false,\n onCloseComplete,\n style,\n }\n}\n\nconst createRender = (options: UseNoticeOptions): FC<NoticeComponentProps> => {\n const { component } = options\n\n const Render: FC<NoticeComponentProps> = (props) => {\n if (typeof component === \"function\") {\n return component({ ...props, ...options }) as JSX.Element\n } else {\n return <Notice {...props} {...options} />\n }\n }\n\n return Render\n}\n\nconst createNoticeFunc = (\n defaultOptions: UseNoticeOptions,\n theme: StyledTheme,\n) => {\n const themeOptions = theme.__config?.notice?.options ?? {}\n\n const computedOptions = (options: UseNoticeOptions) =>\n merge(themeOptions, merge(defaultOptions, options))\n\n const notice = (options: UseNoticeOptions = {}) => {\n options = computedOptions(options)\n\n const message = createRender(options)\n\n return noticeStore.create(message, options)\n }\n\n notice.update = (\n id: string | number,\n options: Omit<UseNoticeOptions, \"id\">,\n ) => {\n options = computedOptions(options)\n\n noticeStore.update(id, options)\n }\n\n notice.closeAll = noticeStore.closeAll\n notice.close = noticeStore.close\n notice.isActive = noticeStore.isActive\n\n return notice\n}\n\ntype CreateNoticeReturn = ReturnType<typeof createNoticeFunc>\n\n/**\n * `useNotice` is a custom hook that controls the notifications of the application.\n *\n * @see Docs https://yamada-ui.com/hooks/use-notice\n */\nexport const useNotice = (\n defaultOptions?: UseNoticeOptions,\n): CreateNoticeReturn => {\n const { theme } = useTheme()\n\n return useMemo(\n () => createNoticeFunc(defaultOptions ?? {}, theme),\n [defaultOptions, theme],\n )\n}\n\ntype State = {\n [K in NoticePlacement]: NoticeOptions[]\n}\n\ninterface Store {\n subscribe: (onStoreChange: () => void) => () => void\n getSnapshot: () => State\n create: (\n message: (props: NoticeComponentProps) => ReactNode,\n options: UseNoticeOptions,\n ) => string | number\n close: (id: string | number) => void\n closeAll: (options?: { placement?: NoticePlacement[] }) => void\n update: (id: string | number, options: Omit<UseNoticeOptions, \"id\">) => void\n remove: (id: string | number, placement: NoticePlacement) => void\n isActive: (id: string | number) => boolean\n}\n\nconst initialState = {\n top: [],\n \"top-left\": [],\n \"top-right\": [],\n bottom: [],\n \"bottom-left\": [],\n \"bottom-right\": [],\n}\n\nconst createNoticeStore = (initialState: State): Store => {\n let state = initialState\n const storeChangeCache = new Set<() => void>()\n\n const setState = (setStateFunc: (values: State) => State) => {\n state = setStateFunc(state)\n storeChangeCache.forEach((onStoreChange) => onStoreChange())\n }\n\n return {\n getSnapshot: () => state,\n\n subscribe: (onStoreChange) => {\n storeChangeCache.add(onStoreChange)\n\n return () => {\n setState(() => initialState)\n storeChangeCache.delete(onStoreChange)\n }\n },\n\n remove: (id, placement) => {\n setState((prevState) => ({\n ...prevState,\n [placement]: prevState[placement].filter((notice) => notice.id != id),\n }))\n },\n\n create: (message, options) => {\n const limit = options.limit\n\n const notice = createNotice(message, options)\n const { placement, id } = notice\n\n setState((prev) => {\n let prevNotices = prev[placement] ?? []\n\n if (\n limit !== undefined &&\n limit > 0 &&\n prevNotices.length > limit - 1\n ) {\n const n = prevNotices.length - (limit - 1)\n const notices = placement.includes(\"top\")\n ? prevNotices.slice(n * -1)\n : prevNotices.slice(0, n)\n\n const ids = notices.map(({ id }) => id)\n\n prevNotices = prevNotices.map((notice) =>\n ids.includes(notice.id) ? { ...notice, isDelete: true } : notice,\n )\n }\n\n const notices = placement.includes(\"top\")\n ? [notice, ...prevNotices]\n : [...prevNotices, notice]\n\n return { ...prev, [placement]: notices }\n })\n\n return id\n },\n\n update: (id, options) => {\n setState((prev) => {\n const next = { ...prev }\n const { placement, index } = findNotice(next, id)\n\n if (placement && index !== -1) {\n next[placement][index] = {\n ...next[placement][index],\n ...options,\n message: createRender(options),\n }\n }\n\n return next\n })\n },\n\n closeAll: ({ placement } = {}) => {\n setState((prev) => {\n let placements: NoticePlacement[] = [\n \"bottom\",\n \"bottom-right\",\n \"bottom-left\",\n \"top\",\n \"top-left\",\n \"top-right\",\n ]\n\n if (placement) placements = placement\n\n return placements.reduce(\n (acc, placement) => {\n acc[placement] = prev[placement].map((notice) => ({\n ...notice,\n isDelete: true,\n }))\n\n return acc\n },\n { ...prev },\n )\n })\n },\n\n close: (id) => {\n setState((prev) => {\n const placement = getNoticePlacement(prev, id)\n\n if (!placement) return prev\n\n return {\n ...prev,\n [placement]: prev[placement].map((notice) =>\n notice.id == id ? { ...notice, isDelete: true } : notice,\n ),\n }\n })\n },\n\n isActive: (id) =>\n Boolean(findNotice(noticeStore.getSnapshot(), id).placement),\n }\n}\n\nexport const noticeStore = createNoticeStore(initialState)\n\nexport interface NoticeProps\n extends Omit<AlertProps, keyof UseNoticeOptions>,\n UseNoticeOptions {\n onClose?: () => void\n}\n\nconst Notice: FC<NoticeProps> = ({\n variant = \"basic\",\n colorScheme,\n status,\n icon,\n title,\n description,\n isClosable,\n closeStrategy = \"button\",\n className,\n onClose,\n}) => {\n const isButtonClosable =\n isClosable && (closeStrategy === \"button\" || closeStrategy === \"both\")\n const isElementClosable =\n isClosable && (closeStrategy === \"element\" || closeStrategy === \"both\")\n\n return (\n <Alert\n status={status}\n variant={variant}\n colorScheme={colorScheme}\n alignItems=\"start\"\n boxShadow=\"fallback(lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))\"\n className={cx(\"ui-notice\", className)}\n pe={isButtonClosable ? 8 : undefined}\n onClick={isElementClosable ? onClose : undefined}\n >\n <AlertIcon\n variant={icon?.variant}\n className=\"ui-notice__icon\"\n {...(icon?.color ? { color: icon.color } : {})}\n >\n {icon?.children}\n </AlertIcon>\n\n <ui.div flex=\"1\">\n {title ? (\n <AlertTitle className=\"ui-notice__title\" lineClamp={1}>\n {title}\n </AlertTitle>\n ) : null}\n {description ? (\n <AlertDescription className=\"ui-notice__desc\" lineClamp={3}>\n {description}\n </AlertDescription>\n ) : null}\n </ui.div>\n\n {isButtonClosable ? (\n <CloseButton\n className=\"ui-notice__close-button\"\n size=\"sm\"\n onClick={(ev) => {\n ev.stopPropagation()\n\n onClose?.()\n }}\n position=\"absolute\"\n top={2}\n right={2}\n />\n ) : null}\n </Alert>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAAmB;AAEnB,oBAAsD;AACtD,oBAAuB;AACvB,yBAA2B;AAC3B,IAAAC,gBAA+C;AAE/C,IAAAC,g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a,SAAU,UAAS;AAAA,IACtC,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AAElC,uCAAW,SAAS,KAAK;AAEzB,UAAM,MAAmB;AAAA,MACvB,eAAe;AAAA,MACf,MAAM;AAAA,MACN,MAAM;AAAA,MACN,GAAG;AAAA,IACL;AAEA,WACE;AAAA,MAAC,qBAAO;AAAA,MAAP;AAAA,QACC,QAAM;AAAA,QACN,WAAU;AAAA,QACV;AAAA,QACA,SAAQ;AAAA,QACR,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,cAAc;AAAA,QACd,YAAY;AAAA,QACZ,QAAQ,EAAE,UAAU;AAAA,QACpB,OACE;AAAA,UACE,SAAS;AAAA,UACT,gBAAgB,UAAU,SAAS,MAAM,IACrC,eACA,UAAU,SAAS,OAAO,IACxB,aACA;AAAA,QACR;AAAA,QAED,GAAG;AAAA,QAEJ,uDAAC,gBAAG,KAAH,EAAO,WAAU,gCAA+B,OAAO,KACrD,uCAAU,SAAS,EAAE,QAAQ,CAAC,GACjC;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,gBAAgB,cAAc;","names":["import_core","import_utils","import_react","initialState","notices","id","notice","placement","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/notice-provider.tsx","../src/notice.tsx"],"sourcesContent":["import type { CSSUIObject, ThemeConfig } from \"@yamada-ui/core\"\nimport type { MotionStyle, MotionVariants } from \"@yamada-ui/motion\"\nimport type { FC } from \"react\"\nimport type { NoticeOptions } from \"./notice\"\nimport { ui } from \"@yamada-ui/core\"\nimport { AnimatePresence, motion, useIsPresent } from \"@yamada-ui/motion\"\nimport { Portal } from \"@yamada-ui/portal\"\nimport { useTimeout } from \"@yamada-ui/use-timeout\"\nimport { cx, runIfFunc, useUpdateEffect } from \"@yamada-ui/utils\"\nimport { memo, useEffect, useState, useSyncExternalStore } from \"react\"\nimport { noticeStore } from \"./notice\"\n\nexport interface NoticeProviderProps\n extends Omit<Required<ThemeConfig>[\"notice\"], \"options\"> {}\n\nexport const NoticeProvider: FC<NoticeProviderProps> = ({\n appendToParentPortal,\n containerRef,\n gap = \"fallback(4, 1rem)\",\n variants,\n itemProps,\n listProps,\n}) => {\n const state = useSyncExternalStore(\n noticeStore.subscribe,\n noticeStore.getSnapshot,\n noticeStore.getSnapshot,\n )\n\n const components = Object.entries(state).map(([placement, notices]) => {\n const top = placement.includes(\"top\")\n ? \"env(safe-area-inset-top, 0px)\"\n : undefined\n const bottom = placement.includes(\"bottom\")\n ? \"env(safe-area-inset-bottom, 0px)\"\n : undefined\n const right = !placement.includes(\"left\")\n ? \"env(safe-area-inset-right, 0px)\"\n : undefined\n const left = !placement.includes(\"right\")\n ? \"env(safe-area-inset-left, 0px)\"\n : undefined\n\n const css: CSSUIObject = {\n bottom,\n display: \"flex\",\n flexDirection: \"column\",\n gap,\n left,\n margin: gap,\n pointerEvents: \"none\",\n position: \"fixed\",\n right,\n top,\n zIndex: \"fallback(zarbon, 160)\",\n }\n\n return (\n <ui.ul\n key={placement}\n className={cx(\"ui-notice__list\", `ui-notice__list--${placement}`)}\n __css={css}\n {...listProps}\n >\n <AnimatePresence initial={false}>\n {notices.map((notice) => (\n <NoticeComponent\n key={notice.id}\n variants={variants}\n itemProps={itemProps}\n {...notice}\n />\n ))}\n </AnimatePresence>\n </ui.ul>\n )\n })\n\n return (\n <Portal\n appendToParentPortal={appendToParentPortal}\n containerRef={containerRef}\n >\n {components}\n </Portal>\n )\n}\n\nconst defaultVariants: MotionVariants = {\n animate: {\n opacity: 1,\n scale: 1,\n transition: {\n duration: 0.4,\n ease: [0.4, 0, 0.2, 1],\n },\n x: 0,\n y: 0,\n },\n exit: {\n opacity: 0,\n scale: 0.95,\n transition: {\n duration: 0.2,\n ease: [0.4, 0, 1, 1],\n },\n },\n initial: ({ placement }) => ({\n [[\"bottom\", \"top\"].includes(placement) ? \"y\" : \"x\"]:\n (placement === \"bottom\" ? 1 : placement.includes(\"right\") ? 1 : -1) * 24,\n opacity: 0,\n }),\n}\n\ninterface NoticeComponentProps\n extends NoticeOptions,\n Pick<NoticeProviderProps, \"itemProps\" | \"variants\"> {}\n\nconst NoticeComponent = memo(\n ({\n style,\n duration = 5000,\n isDelete = false,\n message,\n placement,\n variants = defaultVariants,\n itemProps,\n onCloseComplete,\n onDelete,\n }: NoticeComponentProps) => {\n const [delay, setDelay] = useState(duration)\n const isPresent = useIsPresent()\n\n useUpdateEffect(() => {\n if (!isPresent) onCloseComplete?.()\n }, [isPresent])\n\n useUpdateEffect(() => {\n setDelay(duration)\n }, [duration])\n\n const onMouseEnter = () => setDelay(null)\n const onMouseLeave = () => setDelay(duration)\n\n const onClose = () => {\n if (isPresent) onDelete()\n }\n\n useEffect(() => {\n if (isPresent && isDelete) onDelete()\n }, [isPresent, isDelete, onDelete])\n\n useTimeout(onClose, delay)\n\n const css: CSSUIObject = {\n maxW: \"36rem\",\n minW: \"20rem\",\n pointerEvents: \"auto\",\n ...style,\n }\n\n return (\n <motion.li\n className=\"ui-notice__list__item\"\n style={\n {\n display: \"flex\",\n justifyContent: placement.includes(\"left\")\n ? \"flex-start\"\n : placement.includes(\"right\")\n ? \"flex-end\"\n : \"center\",\n } as MotionStyle\n }\n animate=\"animate\"\n custom={{ placement }}\n exit=\"exit\"\n initial=\"initial\"\n layout\n variants={variants}\n onHoverEnd={onMouseLeave}\n onHoverStart={onMouseEnter}\n {...itemProps}\n >\n <ui.div className=\"ui-notice__list__item__inner\" __css={css}>\n {runIfFunc(message, { onClose })}\n </ui.div>\n </motion.li>\n )\n },\n)\n\nNoticeComponent.displayName = \"NoticeComponent\"\n","import type { AlertProps } from \"@yamada-ui/alert\"\nimport type {\n CSSUIObject,\n NoticeComponentProps,\n NoticeConfigOptions,\n NoticePlacement,\n StyledTheme,\n} from \"@yamada-ui/core\"\nimport type { FC, ReactNode } from \"react\"\nimport {\n Alert,\n AlertDescription,\n AlertIcon,\n AlertTitle,\n} from \"@yamada-ui/alert\"\nimport { CloseButton } from \"@yamada-ui/close-button\"\nimport { ui, useTheme } from \"@yamada-ui/core\"\nimport { cx, merge } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\nexport interface UseNoticeOptions extends NoticeConfigOptions {}\n\nexport interface NoticeOptions {\n id: number | string\n duration: UseNoticeOptions[\"duration\"]\n message: (props: NoticeComponentProps) => ReactNode\n placement: NoticePlacement\n status: UseNoticeOptions[\"status\"]\n onDelete: () => void\n style?: CSSUIObject\n isDelete?: boolean\n onCloseComplete?: () => void\n}\n\nconst findId = (\n options: NoticeOptions[],\n id: number | string,\n): NoticeOptions | undefined => options.find((notice) => notice.id === id)\n\nconst findNotice = (\n state: State,\n id: number | string,\n): {\n index: number\n placement: NoticePlacement | undefined\n} => {\n const placement = getNoticePlacement(state, id)\n\n const index = placement\n ? state[placement].findIndex((notice) => notice.id === id)\n : -1\n\n return { index, placement }\n}\n\nconst getNoticePlacement = (\n state: State,\n id: number | string,\n): NoticePlacement | undefined => {\n for (const [placement, values] of Object.entries(state)) {\n if (findId(values, id)) return placement as NoticePlacement\n }\n}\n\ninterface CreateNoticeOptions\n extends Partial<\n Pick<\n NoticeOptions,\n \"duration\" | \"id\" | \"onCloseComplete\" | \"placement\" | \"status\" | \"style\"\n >\n > {}\n\nlet counter = 0\n\nconst createNotice = (\n message: (props: NoticeComponentProps) => ReactNode,\n {\n id,\n style,\n duration,\n placement = \"top\",\n status,\n onCloseComplete,\n }: CreateNoticeOptions,\n) => {\n counter += 1\n\n id ??= counter\n\n return {\n id,\n style,\n duration,\n isDelete: false,\n message,\n placement,\n status,\n onCloseComplete,\n onDelete: () => noticeStore.remove(String(id), placement),\n }\n}\n\nconst createRender = (options: UseNoticeOptions): FC<NoticeComponentProps> => {\n const { component } = options\n\n const Render: FC<NoticeComponentProps> = (props) => {\n if (typeof component === \"function\") {\n return component({ ...props, ...options })\n } else {\n return <Notice {...props} {...options} />\n }\n }\n\n return Render\n}\n\nconst createNoticeFunc = (\n defaultOptions: UseNoticeOptions,\n theme: StyledTheme,\n) => {\n const themeOptions = theme.__config?.notice?.options ?? {}\n\n const computedOptions = (options: UseNoticeOptions) =>\n merge(themeOptions, merge(defaultOptions, options))\n\n const notice = (options: UseNoticeOptions = {}) => {\n options = computedOptions(options)\n\n const message = createRender(options)\n\n return noticeStore.create(message, options)\n }\n\n notice.update = (\n id: number | string,\n options: Omit<UseNoticeOptions, \"id\">,\n ) => {\n options = computedOptions(options)\n\n noticeStore.update(id, options)\n }\n\n notice.closeAll = noticeStore.closeAll\n notice.close = noticeStore.close\n notice.isActive = noticeStore.isActive\n\n return notice\n}\n\ntype CreateNoticeReturn = ReturnType<typeof createNoticeFunc>\n\n/**\n * `useNotice` is a custom hook that controls the notifications of the application.\n *\n * @see Docs https://yamada-ui.com/hooks/use-notice\n */\nexport const useNotice = (\n defaultOptions?: UseNoticeOptions,\n): CreateNoticeReturn => {\n const { theme } = useTheme()\n\n return useMemo(\n () => createNoticeFunc(defaultOptions ?? {}, theme),\n [defaultOptions, theme],\n )\n}\n\ntype State = {\n [K in NoticePlacement]: NoticeOptions[]\n}\n\ninterface Store {\n close: (id: number | string) => void\n closeAll: (options?: { placement?: NoticePlacement[] }) => void\n create: (\n message: (props: NoticeComponentProps) => ReactNode,\n options: UseNoticeOptions,\n ) => number | string\n getSnapshot: () => State\n isActive: (id: number | string) => boolean\n remove: (id: number | string, placement: NoticePlacement) => void\n subscribe: (onStoreChange: () => void) => () => void\n update: (id: number | string, options: Omit<UseNoticeOptions, \"id\">) => void\n}\n\nconst initialState = {\n bottom: [],\n \"bottom-left\": [],\n \"bottom-right\": [],\n top: [],\n \"top-left\": [],\n \"top-right\": [],\n}\n\nconst createNoticeStore = (initialState: State): Store => {\n let state = initialState\n const storeChangeCache = new Set<() => void>()\n\n const setState = (setStateFunc: (values: State) => State) => {\n state = setStateFunc(state)\n storeChangeCache.forEach((onStoreChange) => onStoreChange())\n }\n\n return {\n close: (id) => {\n setState((prev) => {\n const placement = getNoticePlacement(prev, id)\n\n if (!placement) return prev\n\n return {\n ...prev,\n [placement]: prev[placement].map((notice) =>\n notice.id == id ? { ...notice, isDelete: true } : notice,\n ),\n }\n })\n },\n\n closeAll: ({ placement } = {}) => {\n setState((prev) => {\n let placements: NoticePlacement[] = [\n \"bottom\",\n \"bottom-right\",\n \"bottom-left\",\n \"top\",\n \"top-left\",\n \"top-right\",\n ]\n\n if (placement) placements = placement\n\n return placements.reduce(\n (acc, placement) => {\n acc[placement] = prev[placement].map((notice) => ({\n ...notice,\n isDelete: true,\n }))\n\n return acc\n },\n { ...prev },\n )\n })\n },\n\n create: (message, options) => {\n const limit = options.limit\n\n const notice = createNotice(message, options)\n const { id, placement } = notice\n\n setState((prev) => {\n let prevNotices = prev[placement]\n\n if (\n limit !== undefined &&\n limit > 0 &&\n prevNotices.length > limit - 1\n ) {\n const n = prevNotices.length - (limit - 1)\n const notices = placement.includes(\"top\")\n ? prevNotices.slice(n * -1)\n : prevNotices.slice(0, n)\n\n const ids = notices.map(({ id }) => id)\n\n prevNotices = prevNotices.map((notice) =>\n ids.includes(notice.id) ? { ...notice, isDelete: true } : notice,\n )\n }\n\n const notices = placement.includes(\"top\")\n ? [notice, ...prevNotices]\n : [...prevNotices, notice]\n\n return { ...prev, [placement]: notices }\n })\n\n return id\n },\n\n getSnapshot: () => state,\n\n isActive: (id) =>\n Boolean(findNotice(noticeStore.getSnapshot(), id).placement),\n\n remove: (id, placement) => {\n setState((prevState) => ({\n ...prevState,\n [placement]: prevState[placement].filter((notice) => notice.id != id),\n }))\n },\n\n subscribe: (onStoreChange) => {\n storeChangeCache.add(onStoreChange)\n\n return () => {\n setState(() => initialState)\n storeChangeCache.delete(onStoreChange)\n }\n },\n\n update: (id, options) => {\n setState((prev) => {\n const next = { ...prev }\n const { index, placement } = findNotice(next, id)\n\n if (placement && index !== -1 && next[placement][index]) {\n next[placement][index] = {\n ...next[placement][index],\n ...options,\n message: createRender(options),\n }\n }\n\n return next\n })\n },\n }\n}\n\nexport const noticeStore = createNoticeStore(initialState)\n\nexport interface NoticeProps\n extends Omit<AlertProps, keyof UseNoticeOptions>,\n UseNoticeOptions {\n onClose?: () => void\n}\n\nconst Notice: FC<NoticeProps> = ({\n className,\n colorScheme,\n variant = \"basic\",\n closeStrategy = \"button\",\n description,\n icon,\n isClosable,\n status,\n title,\n onClose,\n}) => {\n const isButtonClosable =\n isClosable && (closeStrategy === \"button\" || closeStrategy === \"both\")\n const isElementClosable =\n isClosable && (closeStrategy === \"element\" || closeStrategy === \"both\")\n\n return (\n <Alert\n className={cx(\"ui-notice\", className)}\n colorScheme={colorScheme}\n variant={variant}\n alignItems=\"start\"\n boxShadow=\"fallback(lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))\"\n pe={isButtonClosable ? 8 : undefined}\n status={status}\n onClick={isElementClosable ? onClose : undefined}\n >\n <AlertIcon\n className=\"ui-notice__icon\"\n variant={icon?.variant}\n {...(icon?.color ? { color: icon.color } : {})}\n >\n {icon?.children}\n </AlertIcon>\n\n <ui.div flex=\"1\">\n {title ? (\n <AlertTitle className=\"ui-notice__title\" lineClamp={1}>\n {title}\n </AlertTitle>\n ) : null}\n {description ? (\n <AlertDescription className=\"ui-notice__desc\" lineClamp={3}>\n {description}\n </AlertDescription>\n ) : null}\n </ui.div>\n\n {isButtonClosable ? (\n <CloseButton\n className=\"ui-notice__close-button\"\n size=\"sm\"\n position=\"absolute\"\n right={2}\n top={2}\n onClick={(ev) => {\n ev.stopPropagation()\n\n onClose?.()\n }}\n />\n ) : null}\n </Alert>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,eAAmB;AACnB,oBAAsD;AACtD,oBAAuB;AACvB,yBAA2B;AAC3B,IAAAC,gBAA+C;AAC/C,IAAAC,gBAAgE;;;ACAhE,mBAKO;AACP,0BAA4B;AAC5B,kBAA6B;AAC7B,mBAA0B;AAC1B,mBAAwB;AA2FX;AA3Eb,IA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AAmB;AAAA,MACvB,MAAM;AAAA,MACN,MAAM;AAAA,MACN,eAAe;AAAA,MACf,GAAG;AAAA,IACL;AAEA,WACE;AAAA,MAAC,qBAAO;AAAA,MAAP;AAAA,QACC,WAAU;AAAA,QACV,OACE;AAAA,UACE,SAAS;AAAA,UACT,gBAAgB,UAAU,SAAS,MAAM,IACrC,eACA,UAAU,SAAS,OAAO,IACxB,aACA;AAAA,QACR;AAAA,QAEF,SAAQ;AAAA,QACR,QAAQ,EAAE,UAAU;AAAA,QACpB,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,QAAM;AAAA,QACN;AAAA,QACA,YAAY;AAAA,QACZ,cAAc;AAAA,QACb,GAAG;AAAA,QAEJ,uDAAC,gBAAG,KAAH,EAAO,WAAU,gCAA+B,OAAO,KACrD,uCAAU,SAAS,EAAE,QAAQ,CAAC,GACjC;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,gBAAgB,cAAc;","names":["import_core","import_utils","import_react","initialState","placement","notices","id","notice","import_jsx_runtime"]}
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import {
3
3
  NoticeProvider
4
- } from "./chunk-TNXAE4RC.mjs";
5
- import "./chunk-D5QBPLL6.mjs";
4
+ } from "./chunk-OWEFOXHK.mjs";
5
+ import "./chunk-SAIMVHSM.mjs";
6
6
  export {
7
7
  NoticeProvider
8
8
  };
package/dist/notice.d.mts CHANGED
@@ -1,28 +1,28 @@
1
1
  import { AlertProps } from '@yamada-ui/alert';
2
- import { NoticeConfigOptions, NoticePlacement, NoticeComponentProps, CSSUIObject, StyledTheme } from '@yamada-ui/core';
2
+ import { NoticeConfigOptions, NoticeComponentProps, NoticePlacement, CSSUIObject, StyledTheme } from '@yamada-ui/core';
3
3
  import { ReactNode } from 'react';
4
4
 
5
5
  interface UseNoticeOptions extends NoticeConfigOptions {
6
6
  }
7
7
  interface NoticeOptions {
8
- id: string | number;
9
- placement: NoticePlacement;
8
+ id: number | string;
10
9
  duration: UseNoticeOptions["duration"];
11
- status: UseNoticeOptions["status"];
12
10
  message: (props: NoticeComponentProps) => ReactNode;
13
- isDelete?: boolean;
11
+ placement: NoticePlacement;
12
+ status: UseNoticeOptions["status"];
14
13
  onDelete: () => void;
15
- onCloseComplete?: () => void;
16
14
  style?: CSSUIObject;
15
+ isDelete?: boolean;
16
+ onCloseComplete?: () => void;
17
17
  }
18
18
  declare const createNoticeFunc: (defaultOptions: UseNoticeOptions, theme: StyledTheme) => {
19
19
  (options?: UseNoticeOptions): string | number;
20
- update(id: string | number, options: Omit<UseNoticeOptions, "id">): void;
20
+ update(id: number | string, options: Omit<UseNoticeOptions, "id">): void;
21
21
  closeAll: (options?: {
22
22
  placement?: NoticePlacement[];
23
23
  }) => void;
24
- close: (id: string | number) => void;
25
- isActive: (id: string | number) => boolean;
24
+ close: (id: number | string) => void;
25
+ isActive: (id: number | string) => boolean;
26
26
  };
27
27
  type CreateNoticeReturn = ReturnType<typeof createNoticeFunc>;
28
28
  /**
@@ -35,16 +35,16 @@ type State = {
35
35
  [K in NoticePlacement]: NoticeOptions[];
36
36
  };
37
37
  interface Store {
38
- subscribe: (onStoreChange: () => void) => () => void;
39
- getSnapshot: () => State;
40
- create: (message: (props: NoticeComponentProps) => ReactNode, options: UseNoticeOptions) => string | number;
41
- close: (id: string | number) => void;
38
+ close: (id: number | string) => void;
42
39
  closeAll: (options?: {
43
40
  placement?: NoticePlacement[];
44
41
  }) => void;
45
- update: (id: string | number, options: Omit<UseNoticeOptions, "id">) => void;
46
- remove: (id: string | number, placement: NoticePlacement) => void;
47
- isActive: (id: string | number) => boolean;
42
+ create: (message: (props: NoticeComponentProps) => ReactNode, options: UseNoticeOptions) => number | string;
43
+ getSnapshot: () => State;
44
+ isActive: (id: number | string) => boolean;
45
+ remove: (id: number | string, placement: NoticePlacement) => void;
46
+ subscribe: (onStoreChange: () => void) => () => void;
47
+ update: (id: number | string, options: Omit<UseNoticeOptions, "id">) => void;
48
48
  }
49
49
  declare const noticeStore: Store;
50
50
  interface NoticeProps extends Omit<AlertProps, keyof UseNoticeOptions>, UseNoticeOptions {
package/dist/notice.d.ts CHANGED
@@ -1,28 +1,28 @@
1
1
  import { AlertProps } from '@yamada-ui/alert';
2
- import { NoticeConfigOptions, NoticePlacement, NoticeComponentProps, CSSUIObject, StyledTheme } from '@yamada-ui/core';
2
+ import { NoticeConfigOptions, NoticeComponentProps, NoticePlacement, CSSUIObject, StyledTheme } from '@yamada-ui/core';
3
3
  import { ReactNode } from 'react';
4
4
 
5
5
  interface UseNoticeOptions extends NoticeConfigOptions {
6
6
  }
7
7
  interface NoticeOptions {
8
- id: string | number;
9
- placement: NoticePlacement;
8
+ id: number | string;
10
9
  duration: UseNoticeOptions["duration"];
11
- status: UseNoticeOptions["status"];
12
10
  message: (props: NoticeComponentProps) => ReactNode;
13
- isDelete?: boolean;
11
+ placement: NoticePlacement;
12
+ status: UseNoticeOptions["status"];
14
13
  onDelete: () => void;
15
- onCloseComplete?: () => void;
16
14
  style?: CSSUIObject;
15
+ isDelete?: boolean;
16
+ onCloseComplete?: () => void;
17
17
  }
18
18
  declare const createNoticeFunc: (defaultOptions: UseNoticeOptions, theme: StyledTheme) => {
19
19
  (options?: UseNoticeOptions): string | number;
20
- update(id: string | number, options: Omit<UseNoticeOptions, "id">): void;
20
+ update(id: number | string, options: Omit<UseNoticeOptions, "id">): void;
21
21
  closeAll: (options?: {
22
22
  placement?: NoticePlacement[];
23
23
  }) => void;
24
- close: (id: string | number) => void;
25
- isActive: (id: string | number) => boolean;
24
+ close: (id: number | string) => void;
25
+ isActive: (id: number | string) => boolean;
26
26
  };
27
27
  type CreateNoticeReturn = ReturnType<typeof createNoticeFunc>;
28
28
  /**
@@ -35,16 +35,16 @@ type State = {
35
35
  [K in NoticePlacement]: NoticeOptions[];
36
36
  };
37
37
  interface Store {
38
- subscribe: (onStoreChange: () => void) => () => void;
39
- getSnapshot: () => State;
40
- create: (message: (props: NoticeComponentProps) => ReactNode, options: UseNoticeOptions) => string | number;
41
- close: (id: string | number) => void;
38
+ close: (id: number | string) => void;
42
39
  closeAll: (options?: {
43
40
  placement?: NoticePlacement[];
44
41
  }) => void;
45
- update: (id: string | number, options: Omit<UseNoticeOptions, "id">) => void;
46
- remove: (id: string | number, placement: NoticePlacement) => void;
47
- isActive: (id: string | number) => boolean;
42
+ create: (message: (props: NoticeComponentProps) => ReactNode, options: UseNoticeOptions) => number | string;
43
+ getSnapshot: () => State;
44
+ isActive: (id: number | string) => boolean;
45
+ remove: (id: number | string, placement: NoticePlacement) => void;
46
+ subscribe: (onStoreChange: () => void) => () => void;
47
+ update: (id: number | string, options: Omit<UseNoticeOptions, "id">) => void;
48
48
  }
49
49
  declare const noticeStore: Store;
50
50
  interface NoticeProps extends Omit<AlertProps, keyof UseNoticeOptions>, UseNoticeOptions {