@expcat/tigercat-react 0.0.65 → 0.0.67

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 (196) hide show
  1. package/dist/styles/index.css +4 -0
  2. package/dist/styles/index.d.mts +2 -0
  3. package/package.json +12 -9
  4. package/dist/chunk-2DOPHSZP.js +0 -32
  5. package/dist/chunk-2TS6X5RA.js +0 -73
  6. package/dist/chunk-2Y327ZU4.js +0 -493
  7. package/dist/chunk-3OF7XPIQ.js +0 -90
  8. package/dist/chunk-3WPKVV4N.js +0 -140
  9. package/dist/chunk-5FRENLDC.js +0 -194
  10. package/dist/chunk-5QKMQRCW.js +0 -89
  11. package/dist/chunk-5ZVSFIZD.js +0 -50
  12. package/dist/chunk-6MGEGOYJ.js +0 -108
  13. package/dist/chunk-6PUSRC6S.js +0 -68
  14. package/dist/chunk-72ZRDBXN.js +0 -25
  15. package/dist/chunk-77D7VQMG.js +0 -43
  16. package/dist/chunk-7P6PHSFM.js +0 -548
  17. package/dist/chunk-AG6GVQ5O.js +0 -271
  18. package/dist/chunk-AQ6DHCP6.js +0 -53
  19. package/dist/chunk-AQQRWISY.js +0 -184
  20. package/dist/chunk-C5EFBJBR.js +0 -540
  21. package/dist/chunk-D3I2SY7X.js +0 -301
  22. package/dist/chunk-DZJUFU55.js +0 -300
  23. package/dist/chunk-EI2GHMQS.js +0 -37
  24. package/dist/chunk-ENR3RIMM.js +0 -205
  25. package/dist/chunk-EQWQXURG.js +0 -18
  26. package/dist/chunk-EUHWE7MN.js +0 -267
  27. package/dist/chunk-FAKTU64M.js +0 -67
  28. package/dist/chunk-FQ6UHRAO.js +0 -499
  29. package/dist/chunk-GX74TC62.js +0 -54
  30. package/dist/chunk-HDDBBZQH.js +0 -321
  31. package/dist/chunk-IFY46RWU.js +0 -25
  32. package/dist/chunk-IQINYCU6.js +0 -99
  33. package/dist/chunk-IY4LEJYF.js +0 -78
  34. package/dist/chunk-JW64IJP2.js +0 -210
  35. package/dist/chunk-KUCFT2OA.js +0 -43
  36. package/dist/chunk-LNKI6HQ3.js +0 -152
  37. package/dist/chunk-LXA2YBAO.js +0 -38
  38. package/dist/chunk-MKWXJZ3T.js +0 -74
  39. package/dist/chunk-NEULKOYJ.js +0 -48
  40. package/dist/chunk-NI2WNZRT.js +0 -38
  41. package/dist/chunk-OFCKGWTS.js +0 -12
  42. package/dist/chunk-OTRGVENC.js +0 -305
  43. package/dist/chunk-P273E6XE.js +0 -219
  44. package/dist/chunk-Q3DPJHNM.js +0 -407
  45. package/dist/chunk-QFVE7GKD.js +0 -109
  46. package/dist/chunk-QL6OBKEN.js +0 -84
  47. package/dist/chunk-QL6UEG3U.js +0 -27
  48. package/dist/chunk-QORSSZX4.js +0 -144
  49. package/dist/chunk-R4JSBXGG.js +0 -12
  50. package/dist/chunk-R5BQHZWB.js +0 -698
  51. package/dist/chunk-R7MS42PL.js +0 -90
  52. package/dist/chunk-TB2UHDOZ.js +0 -19
  53. package/dist/chunk-TBIEWDY5.js +0 -175
  54. package/dist/chunk-TJFS44SH.js +0 -48
  55. package/dist/chunk-TZ26HQAW.js +0 -85
  56. package/dist/chunk-U4ZVEPYD.js +0 -71
  57. package/dist/chunk-UFAXJVMD.js +0 -120
  58. package/dist/chunk-VJJ76I7U.js +0 -19
  59. package/dist/chunk-VO4WDK4K.js +0 -37
  60. package/dist/chunk-VSF4DF7N.js +0 -84
  61. package/dist/chunk-VVO4V4IK.js +0 -56
  62. package/dist/chunk-WK5HN4OH.js +0 -113
  63. package/dist/chunk-XZDJ5FRB.js +0 -333
  64. package/dist/chunk-YE2M2HNM.js +0 -168
  65. package/dist/chunk-YYGTJKP5.js +0 -39
  66. package/dist/chunk-ZREFCRX3.js +0 -52
  67. package/dist/components/Alert.d.ts +0 -24
  68. package/dist/components/Alert.js +0 -10
  69. package/dist/components/Avatar.d.ts +0 -12
  70. package/dist/components/Avatar.js +0 -10
  71. package/dist/components/Badge.d.ts +0 -12
  72. package/dist/components/Badge.js +0 -10
  73. package/dist/components/Breadcrumb.d.ts +0 -13
  74. package/dist/components/Breadcrumb.js +0 -14
  75. package/dist/components/BreadcrumbItem.d.ts +0 -21
  76. package/dist/components/BreadcrumbItem.js +0 -11
  77. package/dist/components/Button.d.ts +0 -8
  78. package/dist/components/Button.js +0 -10
  79. package/dist/components/Card.d.ts +0 -33
  80. package/dist/components/Card.js +0 -10
  81. package/dist/components/Checkbox.d.ts +0 -48
  82. package/dist/components/Checkbox.js +0 -11
  83. package/dist/components/CheckboxGroup.d.ts +0 -39
  84. package/dist/components/CheckboxGroup.js +0 -14
  85. package/dist/components/Code.d.ts +0 -9
  86. package/dist/components/Code.js +0 -16
  87. package/dist/components/Col.d.ts +0 -7
  88. package/dist/components/Col.js +0 -11
  89. package/dist/components/ConfigProvider.d.ts +0 -14
  90. package/dist/components/ConfigProvider.js +0 -14
  91. package/dist/components/Container.d.ts +0 -13
  92. package/dist/components/Container.js +0 -10
  93. package/dist/components/Content.d.ts +0 -9
  94. package/dist/components/Content.js +0 -10
  95. package/dist/components/DatePicker.d.ts +0 -24
  96. package/dist/components/DatePicker.js +0 -10
  97. package/dist/components/Descriptions.d.ts +0 -53
  98. package/dist/components/Descriptions.js +0 -16
  99. package/dist/components/Divider.d.ts +0 -12
  100. package/dist/components/Divider.js +0 -10
  101. package/dist/components/Drawer.d.ts +0 -19
  102. package/dist/components/Drawer.js +0 -11
  103. package/dist/components/Dropdown.d.ts +0 -22
  104. package/dist/components/Dropdown.js +0 -16
  105. package/dist/components/DropdownItem.d.ts +0 -17
  106. package/dist/components/DropdownItem.js +0 -13
  107. package/dist/components/DropdownMenu.d.ts +0 -13
  108. package/dist/components/DropdownMenu.js +0 -10
  109. package/dist/components/Footer.d.ts +0 -9
  110. package/dist/components/Footer.js +0 -10
  111. package/dist/components/Form.d.ts +0 -56
  112. package/dist/components/Form.js +0 -14
  113. package/dist/components/FormItem.d.ts +0 -16
  114. package/dist/components/FormItem.js +0 -11
  115. package/dist/components/Header.d.ts +0 -9
  116. package/dist/components/Header.js +0 -10
  117. package/dist/components/Icon.d.ts +0 -9
  118. package/dist/components/Icon.js +0 -10
  119. package/dist/components/Input.d.ts +0 -28
  120. package/dist/components/Input.js +0 -10
  121. package/dist/components/Layout.d.ts +0 -9
  122. package/dist/components/Layout.js +0 -10
  123. package/dist/components/Link.d.ts +0 -10
  124. package/dist/components/Link.js +0 -10
  125. package/dist/components/List.d.ts +0 -94
  126. package/dist/components/List.js +0 -12
  127. package/dist/components/Loading.d.ts +0 -8
  128. package/dist/components/Loading.js +0 -10
  129. package/dist/components/Menu.d.ts +0 -35
  130. package/dist/components/Menu.js +0 -14
  131. package/dist/components/MenuItem.d.ts +0 -20
  132. package/dist/components/MenuItem.js +0 -11
  133. package/dist/components/MenuItemGroup.d.ts +0 -16
  134. package/dist/components/MenuItemGroup.js +0 -12
  135. package/dist/components/Message.d.ts +0 -44
  136. package/dist/components/Message.js +0 -20
  137. package/dist/components/Modal.d.ts +0 -41
  138. package/dist/components/Modal.js +0 -11
  139. package/dist/components/Notification.d.ts +0 -40
  140. package/dist/components/Notification.js +0 -20
  141. package/dist/components/Pagination.d.ts +0 -11
  142. package/dist/components/Pagination.js +0 -16
  143. package/dist/components/Popconfirm.d.ts +0 -34
  144. package/dist/components/Popconfirm.js +0 -10
  145. package/dist/components/Popover.d.ts +0 -14
  146. package/dist/components/Popover.js +0 -10
  147. package/dist/components/Progress.d.ts +0 -8
  148. package/dist/components/Progress.js +0 -10
  149. package/dist/components/Radio.d.ts +0 -20
  150. package/dist/components/Radio.js +0 -11
  151. package/dist/components/RadioGroup.d.ts +0 -28
  152. package/dist/components/RadioGroup.js +0 -14
  153. package/dist/components/Row.d.ts +0 -11
  154. package/dist/components/Row.js +0 -14
  155. package/dist/components/Select.d.ts +0 -23
  156. package/dist/components/Select.js +0 -10
  157. package/dist/components/Sidebar.d.ts +0 -9
  158. package/dist/components/Sidebar.js +0 -10
  159. package/dist/components/Skeleton.d.ts +0 -7
  160. package/dist/components/Skeleton.js +0 -10
  161. package/dist/components/Slider.d.ts +0 -12
  162. package/dist/components/Slider.js +0 -10
  163. package/dist/components/Space.d.ts +0 -11
  164. package/dist/components/Space.js +0 -10
  165. package/dist/components/Steps.d.ts +0 -31
  166. package/dist/components/Steps.js +0 -14
  167. package/dist/components/StepsItem.d.ts +0 -36
  168. package/dist/components/StepsItem.js +0 -10
  169. package/dist/components/SubMenu.d.ts +0 -20
  170. package/dist/components/SubMenu.js +0 -13
  171. package/dist/components/Switch.d.ts +0 -12
  172. package/dist/components/Switch.js +0 -10
  173. package/dist/components/TabPane.d.ts +0 -42
  174. package/dist/components/TabPane.js +0 -10
  175. package/dist/components/Table.d.ts +0 -46
  176. package/dist/components/Table.js +0 -10
  177. package/dist/components/Tabs.d.ts +0 -43
  178. package/dist/components/Tabs.js +0 -14
  179. package/dist/components/Tag.d.ts +0 -16
  180. package/dist/components/Tag.js +0 -10
  181. package/dist/components/Text.d.ts +0 -9
  182. package/dist/components/Text.js +0 -10
  183. package/dist/components/Textarea.d.ts +0 -13
  184. package/dist/components/Textarea.js +0 -10
  185. package/dist/components/TimePicker.d.ts +0 -28
  186. package/dist/components/TimePicker.js +0 -10
  187. package/dist/components/Timeline.d.ts +0 -47
  188. package/dist/components/Timeline.js +0 -10
  189. package/dist/components/Tooltip.d.ts +0 -15
  190. package/dist/components/Tooltip.js +0 -10
  191. package/dist/components/Tree.d.ts +0 -154
  192. package/dist/components/Tree.js +0 -16
  193. package/dist/components/Upload.d.ts +0 -16
  194. package/dist/components/Upload.js +0 -11
  195. package/dist/index.d.ts +0 -77
  196. package/dist/index.js +0 -364
@@ -1,205 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var tigercatCore = require('@expcat/tigercat-core');
5
- var jsxRuntime = require('react/jsx-runtime');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var React__default = /*#__PURE__*/_interopDefault(React);
10
-
11
- // src/components/Popconfirm.tsx
12
- var popconfirmIdCounter = 0;
13
- var createPopconfirmId = () => `tiger-popconfirm-${++popconfirmIdCounter}`;
14
- var PopconfirmIcon = ({ type }) => /* @__PURE__ */ jsxRuntime.jsx(
15
- "svg",
16
- {
17
- xmlns: "http://www.w3.org/2000/svg",
18
- fill: "none",
19
- viewBox: tigercatCore.popconfirmIconViewBox,
20
- strokeWidth: tigercatCore.popconfirmIconStrokeWidth,
21
- stroke: "currentColor",
22
- children: /* @__PURE__ */ jsxRuntime.jsx(
23
- "path",
24
- {
25
- strokeLinecap: tigercatCore.popconfirmIconPathStrokeLinecap,
26
- strokeLinejoin: tigercatCore.popconfirmIconPathStrokeLinejoin,
27
- d: tigercatCore.getPopconfirmIconPath(type)
28
- }
29
- )
30
- }
31
- );
32
- var Popconfirm = ({
33
- visible,
34
- defaultVisible = false,
35
- title = "\u786E\u5B9A\u8981\u6267\u884C\u6B64\u64CD\u4F5C\u5417\uFF1F",
36
- description,
37
- icon = "warning",
38
- showIcon = true,
39
- okText = "\u786E\u5B9A",
40
- cancelText = "\u53D6\u6D88",
41
- okType = "primary",
42
- placement = "top",
43
- disabled = false,
44
- className,
45
- style,
46
- children,
47
- titleContent,
48
- descriptionContent,
49
- onVisibleChange,
50
- onConfirm,
51
- onCancel,
52
- ...divProps
53
- }) => {
54
- const isControlled = visible !== void 0;
55
- const [internalVisible, setInternalVisible] = React.useState(defaultVisible);
56
- const currentVisible = isControlled ? visible : internalVisible;
57
- const containerRef = React.useRef(null);
58
- const popconfirmIdRef = React.useRef(null);
59
- if (!popconfirmIdRef.current) {
60
- popconfirmIdRef.current = createPopconfirmId();
61
- }
62
- const popconfirmId = popconfirmIdRef.current;
63
- const titleId = `${popconfirmId}-title`;
64
- const descriptionId = `${popconfirmId}-description`;
65
- const describedBy = description || descriptionContent ? descriptionId : void 0;
66
- const setVisible = (newVisible) => {
67
- if (disabled && newVisible) return;
68
- if (!isControlled) {
69
- setInternalVisible(newVisible);
70
- }
71
- onVisibleChange?.(newVisible);
72
- };
73
- const handleConfirm = () => {
74
- onConfirm?.();
75
- setVisible(false);
76
- };
77
- const handleCancel = () => {
78
- onCancel?.();
79
- setVisible(false);
80
- };
81
- const handleTriggerClick = () => {
82
- if (disabled) return;
83
- setVisible(!currentVisible);
84
- };
85
- React.useEffect(() => {
86
- if (!currentVisible) return;
87
- const handleClickOutside = (event) => {
88
- const target = event.target;
89
- if (!target) return;
90
- if (containerRef.current?.contains(target)) return;
91
- setVisible(false);
92
- };
93
- const timeoutId = window.setTimeout(() => {
94
- document.addEventListener("click", handleClickOutside);
95
- }, 0);
96
- return () => {
97
- clearTimeout(timeoutId);
98
- document.removeEventListener("click", handleClickOutside);
99
- };
100
- }, [currentVisible]);
101
- React.useEffect(() => {
102
- if (!currentVisible) return;
103
- const handleKeyDown = (event) => {
104
- if (event.key !== "Escape") return;
105
- setVisible(false);
106
- };
107
- document.addEventListener("keydown", handleKeyDown);
108
- return () => document.removeEventListener("keydown", handleKeyDown);
109
- }, [currentVisible]);
110
- const containerClasses = React.useMemo(
111
- () => tigercatCore.classNames(tigercatCore.getPopconfirmContainerClasses(), className),
112
- [className]
113
- );
114
- const triggerClasses = React.useMemo(() => tigercatCore.getPopconfirmTriggerClasses(disabled), [disabled]);
115
- const contentWrapperClasses = React.useMemo(
116
- () => tigercatCore.getDropdownMenuWrapperClasses(Boolean(currentVisible), placement),
117
- [currentVisible, placement]
118
- );
119
- const arrowClasses = React.useMemo(() => tigercatCore.getPopconfirmArrowClasses(placement), [placement]);
120
- const contentClasses = React.useMemo(() => tigercatCore.getPopconfirmContentClasses(), []);
121
- const titleClasses = React.useMemo(() => tigercatCore.getPopconfirmTitleClasses(), []);
122
- const descriptionClasses = React.useMemo(() => tigercatCore.getPopconfirmDescriptionClasses(), []);
123
- const iconClasses = React.useMemo(() => tigercatCore.getPopconfirmIconClasses(icon), [icon]);
124
- const buttonsClasses = React.useMemo(() => tigercatCore.getPopconfirmButtonsClasses(), []);
125
- const cancelButtonClasses = React.useMemo(() => tigercatCore.getPopconfirmCancelButtonClasses(), []);
126
- const okButtonClasses = React.useMemo(() => tigercatCore.getPopconfirmOkButtonClasses(okType), [okType]);
127
- if (!children) {
128
- return null;
129
- }
130
- const mergedStyle = tigercatCore.mergeStyleValues(style);
131
- const triggerProps = {
132
- className: triggerClasses,
133
- onClick: (event) => {
134
- const target = children;
135
- if (React__default.default.isValidElement(target)) {
136
- const onChildClick = target.props.onClick;
137
- if (typeof onChildClick === "function") {
138
- onChildClick(event);
139
- }
140
- }
141
- if (event.defaultPrevented) return;
142
- handleTriggerClick();
143
- },
144
- "aria-haspopup": "dialog",
145
- "aria-expanded": Boolean(currentVisible),
146
- "aria-controls": currentVisible ? popconfirmId : void 0
147
- };
148
- const triggerNode = (() => {
149
- if (React__default.default.isValidElement(children)) {
150
- return React__default.default.cloneElement(children, {
151
- ...triggerProps,
152
- className: tigercatCore.classNames(children.props.className, triggerProps.className)
153
- });
154
- }
155
- return /* @__PURE__ */ jsxRuntime.jsx(
156
- "div",
157
- {
158
- ...triggerProps,
159
- role: "button",
160
- tabIndex: disabled ? -1 : 0,
161
- "aria-disabled": disabled,
162
- onKeyDown: (event) => {
163
- if (disabled) return;
164
- if (event.key === "Enter" || event.key === " ") {
165
- event.preventDefault();
166
- handleTriggerClick();
167
- }
168
- },
169
- children
170
- }
171
- );
172
- })();
173
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: containerClasses, style: mergedStyle, ...divProps, children: [
174
- triggerNode,
175
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: contentWrapperClasses, hidden: !currentVisible, "aria-hidden": !currentVisible, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
176
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowClasses, "aria-hidden": "true" }),
177
- /* @__PURE__ */ jsxRuntime.jsxs(
178
- "div",
179
- {
180
- id: popconfirmId,
181
- role: "dialog",
182
- "aria-modal": "false",
183
- "aria-labelledby": titleId,
184
- "aria-describedby": describedBy,
185
- className: contentClasses,
186
- children: [
187
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start", children: [
188
- showIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: iconClasses, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PopconfirmIcon, { type: icon }) }),
189
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
190
- /* @__PURE__ */ jsxRuntime.jsx("div", { id: titleId, className: titleClasses, children: titleContent || title }),
191
- (description || descriptionContent) && /* @__PURE__ */ jsxRuntime.jsx("div", { id: descriptionId, className: descriptionClasses, children: descriptionContent || description })
192
- ] })
193
- ] }),
194
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: buttonsClasses, children: [
195
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cancelButtonClasses, onClick: handleCancel, children: cancelText }),
196
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: okButtonClasses, onClick: handleConfirm, children: okText })
197
- ] })
198
- ]
199
- }
200
- )
201
- ] }) })
202
- ] });
203
- };
204
-
205
- exports.Popconfirm = Popconfirm;
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var tigercatCore = require('@expcat/tigercat-core');
4
- var jsxRuntime = require('react/jsx-runtime');
5
-
6
- // src/components/DropdownMenu.tsx
7
- var DropdownMenu = ({
8
- className,
9
- style,
10
- children,
11
- role,
12
- ...divProps
13
- }) => {
14
- const menuClasses = tigercatCore.classNames(tigercatCore.getDropdownMenuClasses(), className);
15
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: menuClasses, style, role: role ?? "menu", ...divProps, children });
16
- };
17
-
18
- exports.DropdownMenu = DropdownMenu;
@@ -1,267 +0,0 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
- var client = require('react-dom/client');
5
- var reactDom = require('react-dom');
6
- var tigercatCore = require('@expcat/tigercat-core');
7
- var jsxRuntime = require('react/jsx-runtime');
8
-
9
- // src/components/Message.tsx
10
- var MESSAGE_CONTAINER_ID = "tiger-message-container";
11
- var MESSAGE_CLOSE_ARIA_LABEL = "Close message";
12
- var messageInstances = [];
13
- var instanceIdCounter = 0;
14
- var containerRoot = null;
15
- var updateCallback = null;
16
- function getNextInstanceId() {
17
- return ++instanceIdCounter;
18
- }
19
- var Icon = ({ path, className, isLoading = false }) => {
20
- const iconClass = tigercatCore.classNames(className, isLoading ? tigercatCore.messageLoadingSpinnerClasses : "");
21
- return /* @__PURE__ */ jsxRuntime.jsx(
22
- "svg",
23
- {
24
- className: iconClass,
25
- xmlns: "http://www.w3.org/2000/svg",
26
- fill: "none",
27
- viewBox: tigercatCore.icon24ViewBox,
28
- stroke: "currentColor",
29
- strokeWidth: tigercatCore.icon24StrokeWidth,
30
- children: /* @__PURE__ */ jsxRuntime.jsx(
31
- "path",
32
- {
33
- strokeLinecap: tigercatCore.icon24PathStrokeLinecap,
34
- strokeLinejoin: tigercatCore.icon24PathStrokeLinejoin,
35
- d: path
36
- }
37
- )
38
- }
39
- );
40
- };
41
- var MessageItem = ({ message: message2, onClose }) => {
42
- const [isVisible, setIsVisible] = react.useState(false);
43
- react.useEffect(() => {
44
- setTimeout(() => setIsVisible(true), 10);
45
- }, []);
46
- const colorScheme = tigercatCore.getMessageTypeClasses(message2.type, tigercatCore.defaultMessageThemeColors);
47
- const messageClasses = tigercatCore.classNames(
48
- tigercatCore.messageBaseClasses,
49
- colorScheme.bg,
50
- colorScheme.border,
51
- colorScheme.text,
52
- message2.className,
53
- isVisible ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-2"
54
- );
55
- const iconPath = message2.icon || tigercatCore.getMessageIconPath(message2.type);
56
- const iconClass = tigercatCore.classNames(tigercatCore.messageIconClasses, colorScheme.icon);
57
- const handleClose = react.useCallback(() => {
58
- setIsVisible(false);
59
- setTimeout(() => onClose(message2.id), 300);
60
- }, [message2.id, onClose]);
61
- const a11yRole = message2.type === "error" ? "alert" : "status";
62
- const ariaLive = message2.type === "error" ? "assertive" : "polite";
63
- return /* @__PURE__ */ jsxRuntime.jsxs(
64
- "div",
65
- {
66
- className: messageClasses,
67
- role: a11yRole,
68
- "aria-live": ariaLive,
69
- "aria-atomic": "true",
70
- "aria-busy": message2.type === "loading" || void 0,
71
- "data-tiger-message": true,
72
- "data-tiger-message-type": message2.type,
73
- "data-tiger-message-id": String(message2.id),
74
- children: [
75
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { path: iconPath, className: iconClass, isLoading: message2.type === "loading" }),
76
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.messageContentClasses, children: message2.content }),
77
- message2.closable && /* @__PURE__ */ jsxRuntime.jsx(
78
- "button",
79
- {
80
- className: tigercatCore.messageCloseButtonClasses,
81
- onClick: handleClose,
82
- "aria-label": MESSAGE_CLOSE_ARIA_LABEL,
83
- type: "button",
84
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { path: tigercatCore.messageCloseIconPath, className: "w-4 h-4" })
85
- }
86
- )
87
- ]
88
- }
89
- );
90
- };
91
- var MessageContainer = ({ position = "top" }) => {
92
- const [messages, setMessages] = react.useState(() => [...messageInstances]);
93
- react.useEffect(() => {
94
- updateCallback = () => {
95
- reactDom.flushSync(() => {
96
- setMessages([...messageInstances]);
97
- });
98
- };
99
- updateCallback();
100
- return () => {
101
- updateCallback = null;
102
- };
103
- }, []);
104
- const containerClasses = tigercatCore.classNames(tigercatCore.messageContainerBaseClasses, tigercatCore.messagePositionClasses[position]);
105
- const handleRemove = react.useCallback((id) => {
106
- const index = messageInstances.findIndex((msg) => msg.id === id);
107
- if (index !== -1) {
108
- const instance = messageInstances[index];
109
- messageInstances.splice(index, 1);
110
- if (instance.onClose) {
111
- instance.onClose();
112
- }
113
- if (updateCallback) {
114
- updateCallback();
115
- }
116
- }
117
- }, []);
118
- return /* @__PURE__ */ jsxRuntime.jsx(
119
- "div",
120
- {
121
- className: containerClasses,
122
- id: MESSAGE_CONTAINER_ID,
123
- "aria-live": "polite",
124
- "aria-relevant": "additions",
125
- "data-tiger-message-container": true,
126
- children: messages.map((message2) => /* @__PURE__ */ jsxRuntime.jsx(MessageItem, { message: message2, onClose: handleRemove }, message2.id))
127
- }
128
- );
129
- };
130
- function ensureContainer() {
131
- if (!tigercatCore.isBrowser()) {
132
- return;
133
- }
134
- const rootId = `${MESSAGE_CONTAINER_ID}-root`;
135
- const existingRootEl = document.getElementById(rootId);
136
- if (containerRoot && !existingRootEl) {
137
- containerRoot = null;
138
- updateCallback = null;
139
- }
140
- if (containerRoot) {
141
- return;
142
- }
143
- let rootEl = existingRootEl;
144
- if (!rootEl) {
145
- rootEl = document.createElement("div");
146
- rootEl.id = rootId;
147
- document.body.appendChild(rootEl);
148
- }
149
- containerRoot = client.createRoot(rootEl);
150
- reactDom.flushSync(() => {
151
- containerRoot?.render(/* @__PURE__ */ jsxRuntime.jsx(MessageContainer, {}));
152
- });
153
- }
154
- function addMessage(config) {
155
- const id = getNextInstanceId();
156
- const instance = {
157
- id,
158
- type: config.type || "info",
159
- content: config.content,
160
- duration: config.duration !== void 0 ? config.duration : 3e3,
161
- closable: config.closable || false,
162
- onClose: config.onClose,
163
- icon: config.icon,
164
- className: config.className
165
- };
166
- messageInstances.push(instance);
167
- ensureContainer();
168
- if (updateCallback) {
169
- updateCallback();
170
- }
171
- if (instance.duration > 0) {
172
- setTimeout(() => {
173
- removeMessage(id);
174
- }, instance.duration);
175
- }
176
- return () => removeMessage(id);
177
- }
178
- function removeMessage(id) {
179
- const index = messageInstances.findIndex((msg) => msg.id === id);
180
- if (index !== -1) {
181
- const instance = messageInstances[index];
182
- messageInstances.splice(index, 1);
183
- if (instance.onClose) {
184
- instance.onClose();
185
- }
186
- if (updateCallback) {
187
- updateCallback();
188
- }
189
- }
190
- }
191
- function clearAll() {
192
- messageInstances.forEach((instance) => {
193
- if (instance.onClose) {
194
- instance.onClose();
195
- }
196
- });
197
- messageInstances = [];
198
- if (updateCallback) {
199
- updateCallback();
200
- }
201
- if (containerRoot) {
202
- containerRoot.unmount();
203
- containerRoot = null;
204
- }
205
- updateCallback = null;
206
- const rootId = `${MESSAGE_CONTAINER_ID}-root`;
207
- if (tigercatCore.isBrowser()) {
208
- const rootEl = document.getElementById(rootId);
209
- if (rootEl?.parentNode) {
210
- rootEl.parentNode.removeChild(rootEl);
211
- }
212
- }
213
- }
214
- function normalizeOptions(options) {
215
- if (typeof options === "string") {
216
- return { content: options };
217
- }
218
- return options;
219
- }
220
- var message = {
221
- /**
222
- * Show an info message
223
- */
224
- info(options) {
225
- const config = normalizeOptions(options);
226
- return addMessage({ ...config, type: "info" });
227
- },
228
- /**
229
- * Show a success message
230
- */
231
- success(options) {
232
- const config = normalizeOptions(options);
233
- return addMessage({ ...config, type: "success" });
234
- },
235
- /**
236
- * Show a warning message
237
- */
238
- warning(options) {
239
- const config = normalizeOptions(options);
240
- return addMessage({ ...config, type: "warning" });
241
- },
242
- /**
243
- * Show an error message
244
- */
245
- error(options) {
246
- const config = normalizeOptions(options);
247
- return addMessage({ ...config, type: "error" });
248
- },
249
- /**
250
- * Show a loading message
251
- */
252
- loading(options) {
253
- const config = normalizeOptions(options);
254
- return addMessage({ ...config, type: "loading", duration: 0 });
255
- },
256
- /**
257
- * Clear all messages
258
- */
259
- clear() {
260
- clearAll();
261
- }
262
- };
263
- var Message_default = message;
264
-
265
- exports.MessageContainer = MessageContainer;
266
- exports.Message_default = Message_default;
267
- exports.message = message;
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- var tigercatCore = require('@expcat/tigercat-core');
4
- var jsxRuntime = require('react/jsx-runtime');
5
-
6
- // src/components/Button.tsx
7
- var spinnerSvg = tigercatCore.getSpinnerSVG("spinner");
8
- var Button = ({
9
- variant = "primary",
10
- size = "md",
11
- disabled = false,
12
- loading = false,
13
- block = false,
14
- onClick,
15
- children,
16
- type = "button",
17
- className,
18
- ...props
19
- }) => {
20
- const isDisabled = disabled || loading;
21
- const ariaBusy = props["aria-busy"] ?? (loading ? true : void 0);
22
- const ariaDisabled = props["aria-disabled"] ?? (isDisabled ? true : void 0);
23
- const buttonClasses = tigercatCore.classNames(
24
- tigercatCore.buttonBaseClasses,
25
- tigercatCore.getButtonVariantClasses(variant),
26
- tigercatCore.buttonSizeClasses[size],
27
- isDisabled && tigercatCore.buttonDisabledClasses,
28
- block && "w-full",
29
- className
30
- );
31
- return /* @__PURE__ */ jsxRuntime.jsxs(
32
- "button",
33
- {
34
- className: buttonClasses,
35
- "aria-busy": ariaBusy,
36
- "aria-disabled": ariaDisabled,
37
- disabled: isDisabled,
38
- onClick: (event) => {
39
- if (isDisabled) return;
40
- onClick?.(event);
41
- },
42
- type,
43
- ...props,
44
- children: [
45
- loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-2", children: /* @__PURE__ */ jsxRuntime.jsx(
46
- "svg",
47
- {
48
- className: "animate-spin h-4 w-4",
49
- xmlns: "http://www.w3.org/2000/svg",
50
- fill: "none",
51
- viewBox: spinnerSvg.viewBox,
52
- "aria-hidden": "true",
53
- focusable: "false",
54
- children: spinnerSvg.elements.map((el, index) => {
55
- if (el.type === "circle") return /* @__PURE__ */ jsxRuntime.jsx("circle", { ...el.attrs }, index);
56
- if (el.type === "path") return /* @__PURE__ */ jsxRuntime.jsx("path", { ...el.attrs }, index);
57
- return null;
58
- })
59
- }
60
- ) }),
61
- children
62
- ]
63
- }
64
- );
65
- };
66
-
67
- exports.Button = Button;