@cerberus-design/react 0.15.0-next-32cd15e → 0.15.0-next-68149ba

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.
Files changed (111) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +35 -3
  2. package/build/legacy/components/DatePicker.client.cjs +37 -30
  3. package/build/legacy/components/DatePicker.client.cjs.map +1 -1
  4. package/build/legacy/components/button/button.cjs +154 -0
  5. package/build/legacy/components/button/button.cjs.map +1 -0
  6. package/build/legacy/components/button/index.cjs +163 -0
  7. package/build/legacy/components/button/index.cjs.map +1 -0
  8. package/build/legacy/components/button/parts.cjs +159 -0
  9. package/build/legacy/components/button/parts.cjs.map +1 -0
  10. package/build/legacy/components/deprecated/NavMenuTrigger.cjs.map +1 -1
  11. package/build/legacy/context/confirm-modal.cjs +53 -44
  12. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  13. package/build/legacy/context/cta-modal.cjs +53 -44
  14. package/build/legacy/context/cta-modal.cjs.map +1 -1
  15. package/build/legacy/context/notification-center.cjs +22 -15
  16. package/build/legacy/context/notification-center.cjs.map +1 -1
  17. package/build/legacy/context/prompt-modal.cjs +75 -66
  18. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  19. package/build/legacy/hooks/useRootColors.cjs +0 -1
  20. package/build/legacy/hooks/useRootColors.cjs.map +1 -1
  21. package/build/legacy/index.cjs +416 -394
  22. package/build/legacy/index.cjs.map +1 -1
  23. package/build/modern/_tsup-dts-rollup.d.ts +35 -3
  24. package/build/modern/{chunk-BRVZVAPT.js → chunk-245SMQ45.js} +1 -1
  25. package/build/modern/chunk-245SMQ45.js.map +1 -0
  26. package/build/modern/{chunk-ISCJ542I.js → chunk-2HOUQ2DX.js} +2 -2
  27. package/build/modern/chunk-2JX27W6Y.js +15 -0
  28. package/build/modern/chunk-2JX27W6Y.js.map +1 -0
  29. package/build/modern/{chunk-F5OVI74O.js → chunk-3RGRHMJQ.js} +6 -6
  30. package/build/modern/chunk-3RGRHMJQ.js.map +1 -0
  31. package/build/modern/{chunk-FV4UITYD.js → chunk-5QONP7GT.js} +4 -4
  32. package/build/modern/{chunk-O6LFWUHI.js → chunk-7P7OWBGV.js} +2 -2
  33. package/build/modern/{chunk-UNDJYNQC.js → chunk-7S47NSGR.js} +6 -6
  34. package/build/modern/chunk-7S47NSGR.js.map +1 -0
  35. package/build/modern/{chunk-25HMVHLT.js → chunk-7SU6FCTJ.js} +5 -5
  36. package/build/modern/chunk-CYC2YUKU.js +1 -0
  37. package/build/modern/{chunk-NJSETNRL.js → chunk-DXBZ3HMY.js} +2 -2
  38. package/build/modern/{chunk-A6BRQ2QK.js → chunk-KU2AWAK3.js} +2 -2
  39. package/build/modern/chunk-KU2AWAK3.js.map +1 -0
  40. package/build/modern/chunk-MER66QUY.js +52 -0
  41. package/build/modern/chunk-MER66QUY.js.map +1 -0
  42. package/build/modern/{chunk-EDARV2EI.js → chunk-MISIUX63.js} +4 -4
  43. package/build/modern/{chunk-N24COMHJ.js → chunk-NGOLRISW.js} +4 -4
  44. package/build/modern/{chunk-ZUXK7V4G.js → chunk-Q4IV5NUT.js} +9 -9
  45. package/build/modern/chunk-Q4IV5NUT.js.map +1 -0
  46. package/build/modern/{chunk-GCQMH4QA.js → chunk-SXLPDPOZ.js} +4 -4
  47. package/build/modern/{chunk-MZ3UCDUL.js → chunk-VYCU7I4J.js} +4 -4
  48. package/build/modern/{chunk-RMVJK26W.js → chunk-XJQXHSH7.js} +1 -2
  49. package/build/modern/chunk-XJQXHSH7.js.map +1 -0
  50. package/build/modern/{chunk-FOKO6LKG.js → chunk-Z7FGXAND.js} +7 -7
  51. package/build/modern/chunk-Z7FGXAND.js.map +1 -0
  52. package/build/modern/components/AccordionItemGroup.js +1 -1
  53. package/build/modern/components/Admonition.client.js +3 -3
  54. package/build/modern/components/Admonition.js +4 -4
  55. package/build/modern/components/Avatar.js +2 -2
  56. package/build/modern/components/Checkbox.js +2 -2
  57. package/build/modern/components/DatePicker.client.js +4 -2
  58. package/build/modern/components/FileStatus.js +3 -3
  59. package/build/modern/components/FileUploader.js +3 -3
  60. package/build/modern/components/Input.js +2 -2
  61. package/build/modern/components/Select.js +2 -2
  62. package/build/modern/components/Tag.js +2 -2
  63. package/build/modern/components/button/button.js +12 -0
  64. package/build/modern/components/button/button.js.map +1 -0
  65. package/build/modern/components/button/index.js +16 -0
  66. package/build/modern/components/button/index.js.map +1 -0
  67. package/build/modern/components/button/parts.js +10 -0
  68. package/build/modern/components/button/parts.js.map +1 -0
  69. package/build/modern/components/deprecated/NavMenuTrigger.js +1 -1
  70. package/build/modern/context/confirm-modal.js +5 -4
  71. package/build/modern/context/cta-modal.js +5 -4
  72. package/build/modern/context/notification-center.js +5 -4
  73. package/build/modern/context/prompt-modal.js +6 -5
  74. package/build/modern/hooks/useRootColors.js +1 -1
  75. package/build/modern/index.js +53 -46
  76. package/build/modern/index.js.map +1 -1
  77. package/package.json +2 -2
  78. package/src/components/DatePicker.client.tsx +1 -1
  79. package/src/components/button/button.tsx +77 -0
  80. package/src/components/button/index.ts +2 -0
  81. package/src/components/button/parts.ts +26 -0
  82. package/src/components/deprecated/NavMenuTrigger.tsx +1 -1
  83. package/src/context/confirm-modal.tsx +1 -1
  84. package/src/context/cta-modal.tsx +1 -1
  85. package/src/context/notification-center.tsx +1 -1
  86. package/src/context/prompt-modal.tsx +1 -1
  87. package/src/hooks/useRootColors.ts +0 -1
  88. package/src/index.ts +1 -1
  89. package/build/legacy/components/Button.cjs +0 -51
  90. package/build/legacy/components/Button.cjs.map +0 -1
  91. package/build/modern/chunk-A6BRQ2QK.js.map +0 -1
  92. package/build/modern/chunk-BRVZVAPT.js.map +0 -1
  93. package/build/modern/chunk-F5OVI74O.js.map +0 -1
  94. package/build/modern/chunk-FOKO6LKG.js.map +0 -1
  95. package/build/modern/chunk-RMVJK26W.js.map +0 -1
  96. package/build/modern/chunk-STNRGV3Y.js +0 -29
  97. package/build/modern/chunk-STNRGV3Y.js.map +0 -1
  98. package/build/modern/chunk-UNDJYNQC.js.map +0 -1
  99. package/build/modern/chunk-ZUXK7V4G.js.map +0 -1
  100. package/build/modern/components/Button.js +0 -7
  101. package/src/components/Button.tsx +0 -36
  102. /package/build/modern/{chunk-ISCJ542I.js.map → chunk-2HOUQ2DX.js.map} +0 -0
  103. /package/build/modern/{chunk-FV4UITYD.js.map → chunk-5QONP7GT.js.map} +0 -0
  104. /package/build/modern/{chunk-O6LFWUHI.js.map → chunk-7P7OWBGV.js.map} +0 -0
  105. /package/build/modern/{chunk-25HMVHLT.js.map → chunk-7SU6FCTJ.js.map} +0 -0
  106. /package/build/modern/{components/Button.js.map → chunk-CYC2YUKU.js.map} +0 -0
  107. /package/build/modern/{chunk-NJSETNRL.js.map → chunk-DXBZ3HMY.js.map} +0 -0
  108. /package/build/modern/{chunk-EDARV2EI.js.map → chunk-MISIUX63.js.map} +0 -0
  109. /package/build/modern/{chunk-N24COMHJ.js.map → chunk-NGOLRISW.js.map} +0 -0
  110. /package/build/modern/{chunk-GCQMH4QA.js.map → chunk-SXLPDPOZ.js.map} +0 -0
  111. /package/build/modern/{chunk-MZ3UCDUL.js.map → chunk-VYCU7I4J.js.map} +0 -0
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/button/index.ts
21
+ var button_exports = {};
22
+ __export(button_exports, {
23
+ Button: () => Button,
24
+ ButtonIcon: () => ButtonIcon,
25
+ ButtonParts: () => ButtonParts
26
+ });
27
+ module.exports = __toCommonJS(button_exports);
28
+
29
+ // src/components/button/button.tsx
30
+ var import_react2 = require("react");
31
+ var import_css = require("@cerberus/styled-system/css");
32
+ var import_recipes = require("@cerberus/styled-system/recipes");
33
+
34
+ // src/components/Show.tsx
35
+ var import_react = require("react");
36
+ function Show(props) {
37
+ const { when, children, fallback } = props;
38
+ const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
39
+ return (0, import_react.useMemo)(() => {
40
+ if (condition) return children;
41
+ return fallback ?? null;
42
+ }, [condition, children, fallback]);
43
+ }
44
+
45
+ // src/components/Spinner.tsx
46
+ var import_jsx_runtime = require("react/jsx-runtime");
47
+ function Spinner(props) {
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ "svg",
50
+ {
51
+ "aria-busy": "true",
52
+ role: "status",
53
+ xmlns: "http://www.w3.org/2000/svg",
54
+ height: props.size,
55
+ width: props.size,
56
+ viewBox: "0 0 24 24",
57
+ ...props,
58
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
59
+ "g",
60
+ {
61
+ fill: "none",
62
+ stroke: "currentColor",
63
+ strokeLinecap: "round",
64
+ strokeLinejoin: "round",
65
+ strokeWidth: 2,
66
+ children: [
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
68
+ "path",
69
+ {
70
+ strokeDasharray: 16,
71
+ strokeDashoffset: 16,
72
+ d: "M12 3c4.97 0 9 4.03 9 9",
73
+ children: [
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ "animate",
76
+ {
77
+ fill: "freeze",
78
+ attributeName: "stroke-dashoffset",
79
+ dur: "0.15s",
80
+ values: "16;0"
81
+ }
82
+ ),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
+ "animateTransform",
85
+ {
86
+ attributeName: "transform",
87
+ dur: "0.75s",
88
+ repeatCount: "indefinite",
89
+ type: "rotate",
90
+ values: "0 12 12;360 12 12"
91
+ }
92
+ )
93
+ ]
94
+ }
95
+ ),
96
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
+ "path",
98
+ {
99
+ strokeDasharray: 64,
100
+ strokeDashoffset: 64,
101
+ strokeOpacity: 0.3,
102
+ d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z",
103
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
+ "animate",
105
+ {
106
+ fill: "freeze",
107
+ attributeName: "stroke-dashoffset",
108
+ dur: "0.6s",
109
+ values: "64;0"
110
+ }
111
+ )
112
+ }
113
+ )
114
+ ]
115
+ }
116
+ )
117
+ }
118
+ );
119
+ }
120
+
121
+ // src/components/button/button.tsx
122
+ var import_jsx = require("@cerberus/styled-system/jsx");
123
+ var import_jsx_runtime2 = require("react/jsx-runtime");
124
+ var ButtonContext = (0, import_react2.createContext)({
125
+ pending: false
126
+ });
127
+ function Button(props) {
128
+ const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
129
+ const value = (0, import_react2.useMemo)(() => ({ pending }), [pending]);
130
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
131
+ "button",
132
+ {
133
+ ...nativeProps,
134
+ disabled: pending || nativeProps.disabled,
135
+ className: (0, import_css.cx)(
136
+ nativeProps.className,
137
+ (0, import_recipes.button)({
138
+ palette,
139
+ usage,
140
+ shape,
141
+ size
142
+ })
143
+ )
144
+ }
145
+ ) });
146
+ }
147
+ function ButtonIcon(props) {
148
+ const { pending } = (0, import_react2.useContext)(ButtonContext);
149
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Show, { when: pending, fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: props.children }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx.Box, { w: "4", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, {}) }) });
150
+ }
151
+
152
+ // src/components/button/parts.ts
153
+ var ButtonParts = {
154
+ Root: Button,
155
+ Icon: ButtonIcon
156
+ };
157
+ // Annotate the CommonJS export names for ESM import in node:
158
+ 0 && (module.exports = {
159
+ Button,
160
+ ButtonIcon,
161
+ ButtonParts
162
+ });
163
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/button/index.ts","../../../../src/components/button/button.tsx","../../../../src/components/Show.tsx","../../../../src/components/Spinner.tsx","../../../../src/components/button/parts.ts"],"sourcesContent":["export * from './button'\nexport * from './parts'\n","'use client'\n\nimport {\n type ButtonHTMLAttributes,\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n button,\n type ButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { Show } from '../Show'\nimport { Spinner } from '../Spinner'\nimport { Box } from '@cerberus/styled-system/jsx'\n\n/**\n * This module contains the Button component.\n * @module\n */\n\ninterface ButtonContextValue {\n pending: boolean\n}\n\nconst ButtonContext = createContext<ButtonContextValue>({\n pending: false,\n})\n\nexport type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n ButtonVariantProps & {\n pending?: boolean\n }\n\n/**\n * A component that allows the user to perform actions\n * @see https://cerberus.digitalu.design/react/button\n */\nexport function Button(props: ButtonProps): JSX.Element {\n const { palette, usage, shape, size, pending = false, ...nativeProps } = props\n const value = useMemo(() => ({ pending }), [pending])\n\n return (\n <ButtonContext.Provider value={value}>\n <button\n {...nativeProps}\n disabled={pending || nativeProps.disabled}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n size,\n }),\n )}\n />\n </ButtonContext.Provider>\n )\n}\n\n/**\n * An icon to display in a button that utilizes the pending state to display\n * a loading spinner.\n */\nexport function ButtonIcon(props: PropsWithChildren<object>) {\n const { pending } = useContext(ButtonContext)\n return (\n <Show when={pending} fallback={<>{props.children}</>}>\n <Box w=\"4\">\n <Spinner />\n </Box>\n </Show>\n )\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n","import type { SVGProps } from 'react'\n\n/**\n * This module contains the Spinner component.\n * @module\n */\n\nexport type SpinnerProps = SVGProps<SVGSVGElement> & {\n /**\n * The size of the spinner\n */\n size?: number | string\n}\n\n/**\n * The Spinner component is used to display a loading indicator. Typically used\n * in buttons, modals, and other components that require a loading state.\n * @see https://cerberus.digitalu.design/react/loading-states/\n * @example\n * ```tsx\n * <Button>\n * <Show when={loading} fallback={<>Save</>}>\n * Saving\n * <Spinner size={24} />\n * </Show>\n * </Button>\n * ```\n */\nexport function Spinner(props: SpinnerProps) {\n return (\n <svg\n aria-busy=\"true\"\n role=\"status\"\n xmlns=\"http://www.w3.org/2000/svg\"\n height={props.size}\n width={props.size}\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <g\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n >\n <path\n strokeDasharray={16}\n strokeDashoffset={16}\n d=\"M12 3c4.97 0 9 4.03 9 9\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n dur=\"0.15s\"\n values=\"16;0\"\n ></animate>\n <animateTransform\n attributeName=\"transform\"\n dur=\"0.75s\"\n repeatCount=\"indefinite\"\n type=\"rotate\"\n values=\"0 12 12;360 12 12\"\n ></animateTransform>\n </path>\n <path\n strokeDasharray={64}\n strokeDashoffset={64}\n strokeOpacity={0.3}\n d=\"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n dur=\"0.6s\"\n values=\"64;0\"\n ></animate>\n </path>\n </g>\n </svg>\n )\n}\n","import type { ElementType } from 'react'\nimport { Button, ButtonIcon } from './button'\n\n/**\n * This module contains the parts of the Button component.\n * @module 'button/parts'\n */\n\ninterface ButtonPartsValue {\n Root: ElementType\n Icon: ElementType\n}\n\n/**\n * An Object containing the parts of the Button component. For users that\n * prefer Object component syntax.\n *\n * @remarks\n *\n * When using object component syntax, you import the ButtonParts object and\n * the entire family of components vs. only what you use.\n */\nexport const ButtonParts: ButtonPartsValue = {\n Root: Button,\n Icon: ButtonIcon,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,gBAMO;AACP,iBAAmB;AACnB,qBAGO;;;ACXP,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,sBAAQ,MAAM;AACnB,QAAI,UAAW,QAAO;AACtB,WAAO,Y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UAAU,OAAO,GAAG,YAAY,IAAI;AACzE,QAAM,YAAQ,uBAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAEpD,SACE,6CAAC,cAAc,UAAd,EAAuB,OACtB;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU,WAAW,YAAY;AAAA,MACjC,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,uBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF,GACF;AAEJ;AAMO,SAAS,WAAW,OAAkC;AAC3D,QAAM,EAAE,QAAQ,QAAI,0BAAW,aAAa;AAC5C,SACE,6CAAC,QAAK,MAAM,SAAS,UAAU,6EAAG,gBAAM,UAAS,GAC/C,uDAAC,kBAAI,GAAE,KACL,uDAAC,WAAQ,GACX,GACF;AAEJ;;;AGtDO,IAAM,cAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM;AACR;","names":["import_react","import_jsx_runtime"]}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/button/parts.ts
21
+ var parts_exports = {};
22
+ __export(parts_exports, {
23
+ ButtonParts: () => ButtonParts
24
+ });
25
+ module.exports = __toCommonJS(parts_exports);
26
+
27
+ // src/components/button/button.tsx
28
+ var import_react2 = require("react");
29
+ var import_css = require("@cerberus/styled-system/css");
30
+ var import_recipes = require("@cerberus/styled-system/recipes");
31
+
32
+ // src/components/Show.tsx
33
+ var import_react = require("react");
34
+ function Show(props) {
35
+ const { when, children, fallback } = props;
36
+ const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
37
+ return (0, import_react.useMemo)(() => {
38
+ if (condition) return children;
39
+ return fallback ?? null;
40
+ }, [condition, children, fallback]);
41
+ }
42
+
43
+ // src/components/Spinner.tsx
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ function Spinner(props) {
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
+ "svg",
48
+ {
49
+ "aria-busy": "true",
50
+ role: "status",
51
+ xmlns: "http://www.w3.org/2000/svg",
52
+ height: props.size,
53
+ width: props.size,
54
+ viewBox: "0 0 24 24",
55
+ ...props,
56
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
57
+ "g",
58
+ {
59
+ fill: "none",
60
+ stroke: "currentColor",
61
+ strokeLinecap: "round",
62
+ strokeLinejoin: "round",
63
+ strokeWidth: 2,
64
+ children: [
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
66
+ "path",
67
+ {
68
+ strokeDasharray: 16,
69
+ strokeDashoffset: 16,
70
+ d: "M12 3c4.97 0 9 4.03 9 9",
71
+ children: [
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
73
+ "animate",
74
+ {
75
+ fill: "freeze",
76
+ attributeName: "stroke-dashoffset",
77
+ dur: "0.15s",
78
+ values: "16;0"
79
+ }
80
+ ),
81
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
82
+ "animateTransform",
83
+ {
84
+ attributeName: "transform",
85
+ dur: "0.75s",
86
+ repeatCount: "indefinite",
87
+ type: "rotate",
88
+ values: "0 12 12;360 12 12"
89
+ }
90
+ )
91
+ ]
92
+ }
93
+ ),
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ "path",
96
+ {
97
+ strokeDasharray: 64,
98
+ strokeDashoffset: 64,
99
+ strokeOpacity: 0.3,
100
+ d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z",
101
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
+ "animate",
103
+ {
104
+ fill: "freeze",
105
+ attributeName: "stroke-dashoffset",
106
+ dur: "0.6s",
107
+ values: "64;0"
108
+ }
109
+ )
110
+ }
111
+ )
112
+ ]
113
+ }
114
+ )
115
+ }
116
+ );
117
+ }
118
+
119
+ // src/components/button/button.tsx
120
+ var import_jsx = require("@cerberus/styled-system/jsx");
121
+ var import_jsx_runtime2 = require("react/jsx-runtime");
122
+ var ButtonContext = (0, import_react2.createContext)({
123
+ pending: false
124
+ });
125
+ function Button(props) {
126
+ const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
127
+ const value = (0, import_react2.useMemo)(() => ({ pending }), [pending]);
128
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
129
+ "button",
130
+ {
131
+ ...nativeProps,
132
+ disabled: pending || nativeProps.disabled,
133
+ className: (0, import_css.cx)(
134
+ nativeProps.className,
135
+ (0, import_recipes.button)({
136
+ palette,
137
+ usage,
138
+ shape,
139
+ size
140
+ })
141
+ )
142
+ }
143
+ ) });
144
+ }
145
+ function ButtonIcon(props) {
146
+ const { pending } = (0, import_react2.useContext)(ButtonContext);
147
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Show, { when: pending, fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: props.children }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx.Box, { w: "4", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, {}) }) });
148
+ }
149
+
150
+ // src/components/button/parts.ts
151
+ var ButtonParts = {
152
+ Root: Button,
153
+ Icon: ButtonIcon
154
+ };
155
+ // Annotate the CommonJS export names for ESM import in node:
156
+ 0 && (module.exports = {
157
+ ButtonParts
158
+ });
159
+ //# sourceMappingURL=parts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/button/parts.ts","../../../../src/components/button/button.tsx","../../../../src/components/Show.tsx","../../../../src/components/Spinner.tsx"],"sourcesContent":["import type { ElementType } from 'react'\nimport { Button, ButtonIcon } from './button'\n\n/**\n * This module contains the parts of the Button component.\n * @module 'button/parts'\n */\n\ninterface ButtonPartsValue {\n Root: ElementType\n Icon: ElementType\n}\n\n/**\n * An Object containing the parts of the Button component. For users that\n * prefer Object component syntax.\n *\n * @remarks\n *\n * When using object component syntax, you import the ButtonParts object and\n * the entire family of components vs. only what you use.\n */\nexport const ButtonParts: ButtonPartsValue = {\n Root: Button,\n Icon: ButtonIcon,\n}\n","'use client'\n\nimport {\n type ButtonHTMLAttributes,\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n button,\n type ButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { Show } from '../Show'\nimport { Spinner } from '../Spinner'\nimport { Box } from '@cerberus/styled-system/jsx'\n\n/**\n * This module contains the Button component.\n * @module\n */\n\ninterface ButtonContextValue {\n pending: boolean\n}\n\nconst ButtonContext = createContext<ButtonContextValue>({\n pending: false,\n})\n\nexport type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n ButtonVariantProps & {\n pending?: boolean\n }\n\n/**\n * A component that allows the user to perform actions\n * @see https://cerberus.digitalu.design/react/button\n */\nexport function Button(props: ButtonProps): JSX.Element {\n const { palette, usage, shape, size, pending = false, ...nativeProps } = props\n const value = useMemo(() => ({ pending }), [pending])\n\n return (\n <ButtonContext.Provider value={value}>\n <button\n {...nativeProps}\n disabled={pending || nativeProps.disabled}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n size,\n }),\n )}\n />\n </ButtonContext.Provider>\n )\n}\n\n/**\n * An icon to display in a button that utilizes the pending state to display\n * a loading spinner.\n */\nexport function ButtonIcon(props: PropsWithChildren<object>) {\n const { pending } = useContext(ButtonContext)\n return (\n <Show when={pending} fallback={<>{props.children}</>}>\n <Box w=\"4\">\n <Spinner />\n </Box>\n </Show>\n )\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n","import type { SVGProps } from 'react'\n\n/**\n * This module contains the Spinner component.\n * @module\n */\n\nexport type SpinnerProps = SVGProps<SVGSVGElement> & {\n /**\n * The size of the spinner\n */\n size?: number | string\n}\n\n/**\n * The Spinner component is used to display a loading indicator. Typically used\n * in buttons, modals, and other components that require a loading state.\n * @see https://cerberus.digitalu.design/react/loading-states/\n * @example\n * ```tsx\n * <Button>\n * <Show when={loading} fallback={<>Save</>}>\n * Saving\n * <Spinner size={24} />\n * </Show>\n * </Button>\n * ```\n */\nexport function Spinner(props: SpinnerProps) {\n return (\n <svg\n aria-busy=\"true\"\n role=\"status\"\n xmlns=\"http://www.w3.org/2000/svg\"\n height={props.size}\n width={props.size}\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <g\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n >\n <path\n strokeDasharray={16}\n strokeDashoffset={16}\n d=\"M12 3c4.97 0 9 4.03 9 9\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n dur=\"0.15s\"\n values=\"16;0\"\n ></animate>\n <animateTransform\n attributeName=\"transform\"\n dur=\"0.75s\"\n repeatCount=\"indefinite\"\n type=\"rotate\"\n values=\"0 12 12;360 12 12\"\n ></animateTransform>\n </path>\n <path\n strokeDasharray={64}\n strokeDashoffset={64}\n strokeOpacity={0.3}\n d=\"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n dur=\"0.6s\"\n values=\"64;0\"\n ></animate>\n </path>\n </g>\n </svg>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,gBAMO;AACP,iBAAmB;AACnB,qBAGO;;;ACXP,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,sBAAQ,MAAM;AACnB,QAAI,UAAW,QAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;;;ACQQ;AAlBD,SAAS,QAAQ,OAAqB;AAC3C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,MAAK;AAAA,MACL,OAAM;AAAA,MACN,QAAQ,MAAM;AAAA,MACd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AAA,MACjC,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,uBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF,GACF;AAEJ;AAMO,SAAS,WAAW,OAAkC;AAC3D,QAAM,EAAE,QAAQ,QAAI,0BAAW,aAAa;AAC5C,SACE,6CAAC,QAAK,MAAM,SAAS,UAAU,6EAAG,gBAAM,UAAS,GAC/C,uDAAC,kBAAI,GAAE,KACL,uDAAC,WAAQ,GACX,GACF;AAEJ;;;ADtDO,IAAM,cAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM;AACR;","names":["import_react","import_jsx_runtime"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/deprecated/NavMenuTrigger.tsx","../../../../src/aria-helpers/nav-menu.aria.ts","../../../../src/context/navMenu.tsx","../../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n type ButtonHTMLAttributes,\n type ElementType,\n type MouseEvent,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { button } from '@cerberus/styled-system/recipes'\nimport {\n createNavTriggerProps,\n type NavTriggerAriaValues,\n} from '../../aria-helpers/nav-menu.aria'\nimport { useNavMenuContext } from '../../context/navMenu'\nimport type { ButtonProps } from '../Button'\nimport { Show } from '../Show'\n\n/**\n * This module contains the NavMenuTrigger component.\n * @module\n */\n\nexport interface NavMenuTriggerProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n ButtonProps,\n NavTriggerAriaValues {\n /**\n * The element type to render as. Recommended to use for an IconButton trigger vs a standard Button.\n * @default 'button'\n * @example\n * ```tsx\n * <NavMenuTrigger as={IconButton} href=\"/home\" />\n * ```\n */\n as?: ElementType\n}\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenuTrigger(props: NavMenuTriggerProps): JSX.Element {\n const {\n as,\n palette,\n usage,\n shape,\n controls,\n expanded: propsExpanded,\n onClick,\n ...nativeProps\n } = props\n const { triggerRef, onToggle, expanded } = useNavMenuContext()\n const ariaProps = createNavTriggerProps({\n controls,\n expanded: propsExpanded ?? expanded,\n })\n const hasAs = Boolean(as)\n const AsSub: ElementType = as!\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n if (onClick) return onClick(e)\n onToggle()\n },\n [onClick, onToggle],\n )\n\n return (\n <Show\n when={hasAs}\n fallback={\n <button\n {...nativeProps}\n {...ariaProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n onClick={handleClick}\n ref={triggerRef}\n >\n {props.children}\n </button>\n }\n >\n {hasAs && (\n <AsSub\n {...nativeProps}\n {...ariaProps}\n onClick={handleClick}\n ref={triggerRef}\n />\n )}\n </Show>\n )\n}\n","export interface NavTriggerAriaValues {\n controls: string\n expanded?: boolean\n}\n\ninterface NavTriggerAriaReturn {\n ['aria-controls']: string\n ['aria-expanded']: boolean\n}\n\nexport function createNavTriggerProps(\n values: NavTriggerAriaValues,\n): NavTriggerAriaReturn {\n return {\n ['aria-controls']: values.controls,\n ['aria-expanded']: values.expanded ?? false,\n }\n}\n","'use client'\n\nimport { css } from '@cerberus/styled-system/css'\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type PropsWithChildren,\n type RefObject,\n} from 'react'\n\n/**\n * This module provides a context and hook for the nav menu.\n * @module NavMenu\n */\n\nexport type NavTriggerRef = RefObject<HTMLButtonElement>\nexport type NavMenuRef = RefObject<HTMLUListElement>\n\nexport interface NavMenuContextValue {\n /**\n * The ref for the trigger button.\n */\n triggerRef: NavTriggerRef | null\n /**\n * The ref for the menu.\n */\n menuRef: NavMenuRef | null\n /**\n * Whether the menu is expanded.\n */\n expanded: boolean\n /**\n * Called when the menu button is clicked.\n */\n onToggle: () => void\n}\n\nconst NavMenuContext = createContext<NavMenuContextValue | null>(null)\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenu(props: PropsWithChildren): JSX.Element {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const menuRef = useRef<HTMLUListElement>(null)\n const [expanded, setExpanded] = useState<boolean>(false)\n\n const handleToggle = useCallback(() => {\n setExpanded((prev) => !prev)\n }, [])\n\n const value = useMemo(\n () => ({\n triggerRef,\n menuRef,\n expanded,\n onToggle: handleToggle,\n }),\n [expanded, handleToggle],\n )\n\n return (\n <NavMenuContext.Provider value={value}>\n <nav\n className={css({\n position: 'relative',\n })}\n >\n {props.children}\n </nav>\n </NavMenuContext.Provider>\n )\n}\n\n/**\n * Used to access the nav menu context.\n * @returns The nav menu context.\n */\nexport function useNavMenuContext(): NavMenuContextValue {\n const context = useContext(NavMenuContext)\n if (!context) {\n throw new Error('useNavMenuContext must be used within a NavMenu.')\n }\n return context\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAKO;AACP,IAAAC,cAAmB;AACnB,qBAAuB;;;ACChB,SAAS,sBACd,QACsB;AACtB,SAAO;AAAA,IACL,CAAC,eAAe,GAAG,OAAO;AAAA,IAC1B,CAAC,eAAe,GAAG,OAAO,YAAY;AAAA,EACxC;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AAAA,UACH;AAAA,UACA,SAAS;AAAA,UACT,KAAK;AAAA,UAEJ,gBAAM;AAAA;AAAA,MACT;AAAA,MAGD,mBACC;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,SAAS;AAAA,UACT,KAAK;AAAA;AAAA,MACP;AAAA;AAAA,EAEJ;AAEJ;","names":["import_react","import_css","import_react","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../../src/components/deprecated/NavMenuTrigger.tsx","../../../../src/aria-helpers/nav-menu.aria.ts","../../../../src/context/navMenu.tsx","../../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n type ButtonHTMLAttributes,\n type ElementType,\n type MouseEvent,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { button } from '@cerberus/styled-system/recipes'\nimport {\n createNavTriggerProps,\n type NavTriggerAriaValues,\n} from '../../aria-helpers/nav-menu.aria'\nimport { useNavMenuContext } from '../../context/navMenu'\nimport type { ButtonProps } from '../button/button'\nimport { Show } from '../Show'\n\n/**\n * This module contains the NavMenuTrigger component.\n * @module\n */\n\nexport interface NavMenuTriggerProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n ButtonProps,\n NavTriggerAriaValues {\n /**\n * The element type to render as. Recommended to use for an IconButton trigger vs a standard Button.\n * @default 'button'\n * @example\n * ```tsx\n * <NavMenuTrigger as={IconButton} href=\"/home\" />\n * ```\n */\n as?: ElementType\n}\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenuTrigger(props: NavMenuTriggerProps): JSX.Element {\n const {\n as,\n palette,\n usage,\n shape,\n controls,\n expanded: propsExpanded,\n onClick,\n ...nativeProps\n } = props\n const { triggerRef, onToggle, expanded } = useNavMenuContext()\n const ariaProps = createNavTriggerProps({\n controls,\n expanded: propsExpanded ?? expanded,\n })\n const hasAs = Boolean(as)\n const AsSub: ElementType = as!\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n if (onClick) return onClick(e)\n onToggle()\n },\n [onClick, onToggle],\n )\n\n return (\n <Show\n when={hasAs}\n fallback={\n <button\n {...nativeProps}\n {...ariaProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n onClick={handleClick}\n ref={triggerRef}\n >\n {props.children}\n </button>\n }\n >\n {hasAs && (\n <AsSub\n {...nativeProps}\n {...ariaProps}\n onClick={handleClick}\n ref={triggerRef}\n />\n )}\n </Show>\n )\n}\n","export interface NavTriggerAriaValues {\n controls: string\n expanded?: boolean\n}\n\ninterface NavTriggerAriaReturn {\n ['aria-controls']: string\n ['aria-expanded']: boolean\n}\n\nexport function createNavTriggerProps(\n values: NavTriggerAriaValues,\n): NavTriggerAriaReturn {\n return {\n ['aria-controls']: values.controls,\n ['aria-expanded']: values.expanded ?? false,\n }\n}\n","'use client'\n\nimport { css } from '@cerberus/styled-system/css'\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type PropsWithChildren,\n type RefObject,\n} from 'react'\n\n/**\n * This module provides a context and hook for the nav menu.\n * @module NavMenu\n */\n\nexport type NavTriggerRef = RefObject<HTMLButtonElement>\nexport type NavMenuRef = RefObject<HTMLUListElement>\n\nexport interface NavMenuContextValue {\n /**\n * The ref for the trigger button.\n */\n triggerRef: NavTriggerRef | null\n /**\n * The ref for the menu.\n */\n menuRef: NavMenuRef | null\n /**\n * Whether the menu is expanded.\n */\n expanded: boolean\n /**\n * Called when the menu button is clicked.\n */\n onToggle: () => void\n}\n\nconst NavMenuContext = createContext<NavMenuContextValue | null>(null)\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenu(props: PropsWithChildren): JSX.Element {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const menuRef = useRef<HTMLUListElement>(null)\n const [expanded, setExpanded] = useState<boolean>(false)\n\n const handleToggle = useCallback(() => {\n setExpanded((prev) => !prev)\n }, [])\n\n const value = useMemo(\n () => ({\n triggerRef,\n menuRef,\n expanded,\n onToggle: handleToggle,\n }),\n [expanded, handleToggle],\n )\n\n return (\n <NavMenuContext.Provider value={value}>\n <nav\n className={css({\n position: 'relative',\n })}\n >\n {props.children}\n </nav>\n </NavMenuContext.Provider>\n )\n}\n\n/**\n * Used to access the nav menu context.\n * @returns The nav menu context.\n */\nexport function useNavMenuContext(): NavMenuContextValue {\n const context = useContext(NavMenuContext)\n if (!context) {\n throw new Error('useNavMenuContext must be used within a NavMenu.')\n }\n return context\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAKO;AACP,IAAAC,cAAmB;AACnB,qBAAuB;;;ACChB,SAAS,sBACd,QACsB;AACtB,SAAO;AAAA,IACL,CAAC,eAAe,GAAG,OAAO;AAAA,IAC1B,CAAC,eAAe,GAAG,OAAO,YAAY;AAAA,EACxC;AACF;;;ACfA,iBAAoB;AACpB,mBASO;AAuDD;AA1BN,IAAM,qBAAiB,4BAA0C,IAAI;AAyC9D,SAAS,oBAAyC;AACvD,QAAM,cAAU,yBAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;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AAA;AAAA,MACP;AAAA;AAAA,EAEJ;AAEJ;","names":["import_react","import_css","import_react","import_jsx_runtime"]}
@@ -25,18 +25,38 @@ __export(confirm_modal_exports, {
25
25
  useConfirmModal: () => useConfirmModal
26
26
  });
27
27
  module.exports = __toCommonJS(confirm_modal_exports);
28
- var import_react5 = require("react");
28
+ var import_react6 = require("react");
29
29
 
30
- // src/components/Button.tsx
30
+ // src/components/button/button.tsx
31
+ var import_react2 = require("react");
31
32
  var import_css = require("@cerberus/styled-system/css");
32
33
  var import_recipes = require("@cerberus/styled-system/recipes");
34
+
35
+ // src/components/Show.tsx
36
+ var import_react = require("react");
37
+ function Show(props) {
38
+ const { when, children, fallback } = props;
39
+ const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
40
+ return (0, import_react.useMemo)(() => {
41
+ if (condition) return children;
42
+ return fallback ?? null;
43
+ }, [condition, children, fallback]);
44
+ }
45
+
46
+ // src/components/button/button.tsx
47
+ var import_jsx = require("@cerberus/styled-system/jsx");
33
48
  var import_jsx_runtime = require("react/jsx-runtime");
49
+ var ButtonContext = (0, import_react2.createContext)({
50
+ pending: false
51
+ });
34
52
  function Button(props) {
35
- const { palette, usage, shape, size, ...nativeProps } = props;
36
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
53
+ const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
54
+ const value = (0, import_react2.useMemo)(() => ({ pending }), [pending]);
55
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
37
56
  "button",
38
57
  {
39
58
  ...nativeProps,
59
+ disabled: pending || nativeProps.disabled,
40
60
  className: (0, import_css.cx)(
41
61
  nativeProps.className,
42
62
  (0, import_recipes.button)({
@@ -47,34 +67,23 @@ function Button(props) {
47
67
  })
48
68
  )
49
69
  }
50
- );
70
+ ) });
51
71
  }
52
72
 
53
73
  // src/context/confirm-modal.tsx
54
74
  var import_css4 = require("@cerberus/styled-system/css");
55
75
 
56
- // src/components/Show.tsx
57
- var import_react = require("react");
58
- function Show(props) {
59
- const { when, children, fallback } = props;
60
- const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
61
- return (0, import_react.useMemo)(() => {
62
- if (condition) return children;
63
- return fallback ?? null;
64
- }, [condition, children, fallback]);
65
- }
66
-
67
76
  // src/components/Avatar.tsx
68
77
  var import_css2 = require("@cerberus/styled-system/css");
69
78
  var import_patterns = require("@cerberus/styled-system/patterns");
70
79
  var import_recipes2 = require("@cerberus/styled-system/recipes");
71
80
 
72
81
  // src/context/cerberus.tsx
73
- var import_react2 = require("react");
82
+ var import_react3 = require("react");
74
83
  var import_jsx_runtime2 = require("react/jsx-runtime");
75
- var CerberusContext = (0, import_react2.createContext)(null);
84
+ var CerberusContext = (0, import_react3.createContext)(null);
76
85
  function useCerberusContext() {
77
- const context = (0, import_react2.useContext)(CerberusContext);
86
+ const context = (0, import_react3.useContext)(CerberusContext);
78
87
  if (!context) {
79
88
  throw new Error("useCerberus must be used within a CerberusProvider");
80
89
  }
@@ -171,21 +180,21 @@ var iconSizeMap = {
171
180
  };
172
181
 
173
182
  // src/context/confirm-modal.tsx
174
- var import_jsx = require("@cerberus/styled-system/jsx");
183
+ var import_jsx2 = require("@cerberus/styled-system/jsx");
175
184
 
176
185
  // src/components/Dialog.tsx
177
- var import_react4 = require("@ark-ui/react");
186
+ var import_react5 = require("@ark-ui/react");
178
187
  var import_recipes3 = require("@cerberus/styled-system/recipes");
179
188
 
180
189
  // src/components/Portal.tsx
181
- var import_react3 = require("@ark-ui/react");
182
- var Portal = import_react3.Portal;
190
+ var import_react4 = require("@ark-ui/react");
191
+ var Portal = import_react4.Portal;
183
192
 
184
193
  // src/components/Dialog.tsx
185
194
  var import_css3 = require("@cerberus/styled-system/css");
186
195
  var import_jsx_runtime4 = require("react/jsx-runtime");
187
196
  function DialogProvider(props) {
188
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react4.Dialog.Root, { ...props });
197
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Dialog.Root, { ...props });
189
198
  }
190
199
  function Dialog(props) {
191
200
  const { size, ...contentProps } = props;
@@ -197,39 +206,39 @@ function Dialog(props) {
197
206
  }
198
207
  function DialogHeading(props) {
199
208
  const styles = (0, import_recipes3.dialog)();
200
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react4.Dialog.Title, { ...props, className: (0, import_css3.cx)(props.className, styles.title) });
209
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Dialog.Title, { ...props, className: (0, import_css3.cx)(props.className, styles.title) });
201
210
  }
202
211
  function DialogDescription(props) {
203
212
  const styles = (0, import_recipes3.dialog)();
204
213
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
205
- import_react4.Dialog.Description,
214
+ import_react5.Dialog.Description,
206
215
  {
207
216
  ...props,
208
217
  className: (0, import_css3.cx)(props.className, styles.description)
209
218
  }
210
219
  );
211
220
  }
212
- var DialogTrigger = import_react4.Dialog.Trigger;
213
- var DialogCloseTrigger = import_react4.Dialog.CloseTrigger;
214
- var DialogBackdrop = import_react4.Dialog.Backdrop;
215
- var DialogPositioner = import_react4.Dialog.Positioner;
216
- var DialogContent = import_react4.Dialog.Content;
221
+ var DialogTrigger = import_react5.Dialog.Trigger;
222
+ var DialogCloseTrigger = import_react5.Dialog.CloseTrigger;
223
+ var DialogBackdrop = import_react5.Dialog.Backdrop;
224
+ var DialogPositioner = import_react5.Dialog.Positioner;
225
+ var DialogContent = import_react5.Dialog.Content;
217
226
 
218
227
  // src/context/confirm-modal.tsx
219
228
  var import_jsx_runtime5 = require("react/jsx-runtime");
220
- var ConfirmModalContext = (0, import_react5.createContext)(null);
229
+ var ConfirmModalContext = (0, import_react6.createContext)(null);
221
230
  function ConfirmModal(props) {
222
- const [open, setOpen] = (0, import_react5.useState)(false);
223
- const [content, setContent] = (0, import_react5.useState)(null);
224
- const resolveRef = (0, import_react5.useRef)(null);
231
+ const [open, setOpen] = (0, import_react6.useState)(false);
232
+ const [content, setContent] = (0, import_react6.useState)(null);
233
+ const resolveRef = (0, import_react6.useRef)(null);
225
234
  const kind = (content == null ? void 0 : content.kind) ?? "non-destructive";
226
235
  const { icons } = useCerberusContext();
227
236
  const { confirmModal: ConfirmIcon } = icons;
228
- const palette = (0, import_react5.useMemo)(
237
+ const palette = (0, import_react6.useMemo)(
229
238
  () => kind === "destructive" ? "danger" : "action",
230
239
  [kind]
231
240
  );
232
- const handleChoice = (0, import_react5.useCallback)(
241
+ const handleChoice = (0, import_react6.useCallback)(
233
242
  (e) => {
234
243
  var _a, _b;
235
244
  const target = e.currentTarget;
@@ -241,7 +250,7 @@ function ConfirmModal(props) {
241
250
  },
242
251
  [setOpen]
243
252
  );
244
- const handleShow = (0, import_react5.useCallback)(
253
+ const handleShow = (0, import_react6.useCallback)(
245
254
  (options) => {
246
255
  return new Promise((resolve) => {
247
256
  setContent({ ...options });
@@ -251,7 +260,7 @@ function ConfirmModal(props) {
251
260
  },
252
261
  [setOpen, setContent]
253
262
  );
254
- const value = (0, import_react5.useMemo)(
263
+ const value = (0, import_react6.useMemo)(
255
264
  () => ({
256
265
  show: handleShow
257
266
  }),
@@ -259,10 +268,10 @@ function ConfirmModal(props) {
259
268
  );
260
269
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(ConfirmModalContext.Provider, { value, children: [
261
270
  props.children,
262
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogProvider, { open, onOpenChange: (e) => setOpen(e.open), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Dialog, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx.VStack, { gap: "xl", w: "full", children: [
263
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx.VStack, { alignItems: "flex-start", gap: "md", w: "full", children: [
271
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogProvider, { open, onOpenChange: (e) => setOpen(e.open), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Dialog, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx2.VStack, { gap: "xl", w: "full", children: [
272
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx2.VStack, { alignItems: "flex-start", gap: "md", w: "full", children: [
264
273
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
265
- import_jsx.HStack,
274
+ import_jsx2.HStack,
266
275
  {
267
276
  alignSelf: "center",
268
277
  justify: "center",
@@ -297,7 +306,7 @@ function ConfirmModal(props) {
297
306
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogHeading, { children: content == null ? void 0 : content.heading }),
298
307
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogDescription, { children: content == null ? void 0 : content.description })
299
308
  ] }),
300
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx.HStack, { gap: "4", w: "full", children: [
309
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx2.HStack, { gap: "4", w: "full", children: [
301
310
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
302
311
  Button,
303
312
  {
@@ -330,7 +339,7 @@ function ConfirmModal(props) {
330
339
  ] });
331
340
  }
332
341
  function useConfirmModal() {
333
- const context = (0, import_react5.useContext)(ConfirmModalContext);
342
+ const context = (0, import_react6.useContext)(ConfirmModalContext);
334
343
  if (context === null) {
335
344
  throw new Error(
336
345
  "useConfirmModal must be used within a ConfirmModal Provider"