@liner-fe/prism 2.9.51 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -103,7 +103,7 @@ type ANSWER = 'answer';
103
103
  type ACCENT = 'accent';
104
104
  type NORMAL = 'normal';
105
105
  type POST = 'post';
106
- type AcceptAsHTMLTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'header' | 'footer' | 'p' | 'article' | 'body' | 'main' | 'b' | 'blockquote';
106
+ type AcceptAsHTMLTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'header' | 'footer' | 'p' | 'article' | 'body' | 'main' | 'b' | 'blockquote' | 'span';
107
107
  interface WithHTMLAsProps {
108
108
  as?: Extract<keyof HTMLElementTagNameMap, AcceptAsHTMLTag>;
109
109
  }
@@ -424,6 +424,7 @@ interface ISnackbarBase extends ToastProps {
424
424
  title: string;
425
425
  description?: string;
426
426
  position?: 'left' | 'right';
427
+ timer?: number;
427
428
  }
428
429
  interface ButtonType {
429
430
  onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
package/lib/index.js CHANGED
@@ -2293,6 +2293,7 @@ import { useRecoilValue as useRecoilValue2, useSetRecoilState as useSetRecoilSta
2293
2293
 
2294
2294
  // src/hooks/useSnackbar.ts
2295
2295
  import { atom as atom2, useSetRecoilState as useSetRecoilState3 } from "recoil";
2296
+ import { millisecondsInSecond as millisecondsInSecond3 } from "date-fns/constants";
2296
2297
  var snackbarAtom = atom2({
2297
2298
  key: "snackbarAtom",
2298
2299
  default: []
@@ -2302,7 +2303,8 @@ var useSnackbar = /* @__PURE__ */ __name(() => {
2302
2303
  return {
2303
2304
  open: /* @__PURE__ */ __name((info) => {
2304
2305
  const snackbarId = generateRandomId();
2305
- setSnackbar((prev) => [...prev, { ...info, snackbarId }]);
2306
+ const timer = info.timer ?? (info.button ? millisecondsInSecond3 * 10 : millisecondsInSecond3 + 800);
2307
+ setSnackbar((prev) => [...prev, { ...info, snackbarId, timer }]);
2306
2308
  }, "open")
2307
2309
  };
2308
2310
  }, "useSnackbar");
@@ -2410,6 +2412,8 @@ var SnackbarButton = /* @__PURE__ */ __name(({
2410
2412
  }, "SnackbarButton");
2411
2413
 
2412
2414
  // src/components/Snackbar/index.tsx
2415
+ import { useCallback, useEffect as useEffect3, useRef as useRef3, useState as useState5 } from "react";
2416
+ import { millisecondsInSecond as millisecondsInSecond4 } from "date-fns/constants";
2413
2417
  import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
2414
2418
  import { createElement as createElement3 } from "react";
2415
2419
  var { Provider: Provider2, Root: Root2, Viewport: Viewport2 } = Toast;
@@ -2436,10 +2440,38 @@ var Snackbar = /* @__PURE__ */ __name(() => {
2436
2440
  }, "Snackbar");
2437
2441
  var SingleSnackbar = /* @__PURE__ */ __name((props) => {
2438
2442
  const setSnackbar = useSetRecoilState4(snackbarAtom);
2439
- const { snackbarId, description, title } = props;
2440
- const onCloseSnackbar = /* @__PURE__ */ __name(() => {
2443
+ const timerRef = useRef3();
2444
+ const { snackbarId, description, title, timer } = props;
2445
+ const [isOpen, setIsOpen] = useState5(true);
2446
+ const onCloseSnackbar = useCallback(() => {
2441
2447
  setSnackbar((prev) => prev.filter((snackbar) => snackbar.snackbarId !== snackbarId));
2442
- }, "onCloseSnackbar");
2448
+ if (timerRef.current) {
2449
+ clearTimeout(timerRef.current);
2450
+ }
2451
+ }, [setSnackbar, snackbarId]);
2452
+ useEffect3(() => {
2453
+ if (timer && timer > 0) {
2454
+ const preCloseTimeout = setTimeout(() => {
2455
+ setIsOpen(false);
2456
+ }, timer);
2457
+ timerRef.current = setTimeout(() => {
2458
+ onCloseSnackbar();
2459
+ }, timer + millisecondsInSecond4);
2460
+ return () => {
2461
+ clearTimeout(preCloseTimeout);
2462
+ if (timerRef.current) {
2463
+ clearTimeout(timerRef.current);
2464
+ }
2465
+ };
2466
+ }
2467
+ }, [timer, onCloseSnackbar]);
2468
+ useEffect3(() => {
2469
+ return () => {
2470
+ if (timerRef.current) {
2471
+ clearTimeout(timerRef.current);
2472
+ }
2473
+ };
2474
+ }, []);
2443
2475
  if (props.kind === "navigation") {
2444
2476
  return /* @__PURE__ */ jsxs12(
2445
2477
  Root2,
@@ -2447,7 +2479,7 @@ var SingleSnackbar = /* @__PURE__ */ __name((props) => {
2447
2479
  onSwipeEnd: onCloseSnackbar,
2448
2480
  className: clsx18(style_module_default15.Root, style_module_default15.NavigationWrapper),
2449
2481
  onClick: props.onClick,
2450
- open: true,
2482
+ open: isOpen,
2451
2483
  children: [
2452
2484
  /* @__PURE__ */ jsxs12("div", { className: clsx18(style_module_default15.Content, style_module_default15.MarginRight12), children: [
2453
2485
  /* @__PURE__ */ jsx26(SnackbarTitle, { title }),
@@ -2474,7 +2506,7 @@ var SingleSnackbar = /* @__PURE__ */ __name((props) => {
2474
2506
  {
2475
2507
  onSwipeEnd: onCloseSnackbar,
2476
2508
  className: clsx18(style_module_default15.Root, style_module_default15.gap300, style_module_default15.extendedContainer),
2477
- open: true,
2509
+ open: isOpen,
2478
2510
  children: [
2479
2511
  /* @__PURE__ */ jsxs12("div", { className: style_module_default15.Content, children: [
2480
2512
  /* @__PURE__ */ jsx26(SnackbarTitle, { title }),
@@ -2493,7 +2525,7 @@ var SingleSnackbar = /* @__PURE__ */ __name((props) => {
2493
2525
  }
2494
2526
  );
2495
2527
  }
2496
- return /* @__PURE__ */ jsxs12(Root2, { onSwipeEnd: onCloseSnackbar, className: clsx18(style_module_default15.Root, style_module_default15.Wrapper), open: true, children: [
2528
+ return /* @__PURE__ */ jsxs12(Root2, { onSwipeEnd: onCloseSnackbar, className: clsx18(style_module_default15.Root, style_module_default15.Wrapper), open: isOpen, children: [
2497
2529
  /* @__PURE__ */ jsxs12("div", { className: style_module_default15.ContentWrapper, children: [
2498
2530
  /* @__PURE__ */ jsx26(SnackbarIcon, { icon: props.icon }),
2499
2531
  /* @__PURE__ */ jsxs12("div", { className: clsx18(style_module_default15.Content, style_module_default15.MarginRight12), children: [
@@ -2980,7 +3012,7 @@ var PrimitiveCoachMark = Object.assign(PrimitiveCoachMarkRoot, {
2980
3012
  });
2981
3013
 
2982
3014
  // src/components/coach-mark/compact/index.tsx
2983
- import { forwardRef as forwardRef18, useState as useState5 } from "react";
3015
+ import { forwardRef as forwardRef18, useState as useState6 } from "react";
2984
3016
 
2985
3017
  // src/components/coach-mark/compact/style.module.scss
2986
3018
  var style_module_default19 = {
@@ -3212,7 +3244,7 @@ var CompactCoachMarkRoot = /* @__PURE__ */ __name((props) => {
3212
3244
  }, "CompactCoachMarkRoot");
3213
3245
  var CompactCoachMarkContent = forwardRef18(
3214
3246
  ({ tag, title, level = "brand", className, side = "top", sideOffset = -15, onClose, ...props }, ref) => {
3215
- const [isHover, setIsHover] = useState5(false);
3247
+ const [isHover, setIsHover] = useState6(false);
3216
3248
  return /* @__PURE__ */ jsxs15(
3217
3249
  PrimitiveCoachMark.Content,
3218
3250
  {
@@ -3280,7 +3312,7 @@ var style_module_default21 = {
3280
3312
  import {
3281
3313
  forwardRef as forwardRef19,
3282
3314
  isValidElement,
3283
- useEffect as useEffect3
3315
+ useEffect as useEffect4
3284
3316
  } from "react";
3285
3317
  import { IconClose } from "@liner-fe/icon";
3286
3318
  import { cva as cva12 } from "cva";
@@ -3304,7 +3336,7 @@ var coachMarkLevelButtonLevelMap = {
3304
3336
  };
3305
3337
  var CoachMarkRoot = /* @__PURE__ */ __name((props) => {
3306
3338
  const { children } = props;
3307
- useEffect3(() => {
3339
+ useEffect4(() => {
3308
3340
  if (isValidElement(children) && "image" in children.props) {
3309
3341
  const imageProps = children.props.image;
3310
3342
  if (imageProps?.src) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liner-fe/prism",
3
- "version": "2.9.51",
3
+ "version": "2.11.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -17,10 +17,10 @@
17
17
  "react": "^18.2.0",
18
18
  "react-dom": "^18.2.0",
19
19
  "recoil": "^0.5.2",
20
+ "@liner-fe/design-token": "^2.5.35",
20
21
  "@liner-fe/design-token-primitive": "^0.2.34",
21
- "@liner-fe/icon": "^0.2.42",
22
- "@liner-fe/illust": "^0.2.10",
23
- "@liner-fe/design-token": "^2.5.35"
22
+ "@liner-fe/icon": "^0.2.43",
23
+ "@liner-fe/illust": "^0.2.10"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@chromatic-com/storybook": "^1.5.0",