@j2-health/design-system 0.1.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.
Files changed (112) hide show
  1. package/README.md +113 -0
  2. package/dist/favicon.png +0 -0
  3. package/dist/index.cjs +3624 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +43 -0
  6. package/dist/index.js +3606 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib.d.ts +2 -0
  9. package/dist/src/AppConfigProvider.d.ts +4 -0
  10. package/dist/src/appTheme.d.ts +2 -0
  11. package/dist/src/components/alert/Alert.d.ts +11 -0
  12. package/dist/src/components/alert/index.d.ts +1 -0
  13. package/dist/src/components/barchart/BarChart.d.ts +30 -0
  14. package/dist/src/components/barchart/index.d.ts +2 -0
  15. package/dist/src/components/breadcrumb/Breadcrumb.d.ts +14 -0
  16. package/dist/src/components/breadcrumb/index.d.ts +1 -0
  17. package/dist/src/components/bulkActionBar/BulkActionBar.d.ts +38 -0
  18. package/dist/src/components/bulkActionBar/index.d.ts +1 -0
  19. package/dist/src/components/button/Button.d.ts +4 -0
  20. package/dist/src/components/button/index.d.ts +1 -0
  21. package/dist/src/components/card/Card.d.ts +19 -0
  22. package/dist/src/components/card/index.d.ts +1 -0
  23. package/dist/src/components/checkbox/Checkbox.d.ts +7 -0
  24. package/dist/src/components/checkbox/index.d.ts +1 -0
  25. package/dist/src/components/checkboxTree/CheckboxTree.d.ts +27 -0
  26. package/dist/src/components/checkboxTree/TreeNode.d.ts +13 -0
  27. package/dist/src/components/checkboxTree/index.d.ts +1 -0
  28. package/dist/src/components/checkboxTree/utils.d.ts +9 -0
  29. package/dist/src/components/collapse/Collapse.d.ts +9 -0
  30. package/dist/src/components/collapse/index.d.ts +1 -0
  31. package/dist/src/components/drawer/Drawer.d.ts +9 -0
  32. package/dist/src/components/drawer/index.d.ts +1 -0
  33. package/dist/src/components/dropdown/Dropdown.d.ts +17 -0
  34. package/dist/src/components/dropdown/index.d.ts +1 -0
  35. package/dist/src/components/filterform/FilterGroup.d.ts +16 -0
  36. package/dist/src/components/filterform/FilterInput.d.ts +14 -0
  37. package/dist/src/components/filterform/FiltersForm.d.ts +10 -0
  38. package/dist/src/components/filterform/filterHelpers.d.ts +11 -0
  39. package/dist/src/components/filterform/index.d.ts +2 -0
  40. package/dist/src/components/filterform/types.d.ts +52 -0
  41. package/dist/src/components/filterform/useFilterField.d.ts +43 -0
  42. package/dist/src/components/filterform/useFiltersForm.d.ts +59 -0
  43. package/dist/src/components/form/Form.d.ts +7 -0
  44. package/dist/src/components/form/index.d.ts +1 -0
  45. package/dist/src/components/icons/index.d.ts +1 -0
  46. package/dist/src/components/input/AntdInput.d.ts +322 -0
  47. package/dist/src/components/input/AntdSearchInput.d.ts +327 -0
  48. package/dist/src/components/input/Input.d.ts +4 -0
  49. package/dist/src/components/input/index.d.ts +3 -0
  50. package/dist/src/components/inputnumber/InputNumber.d.ts +9 -0
  51. package/dist/src/components/inputnumber/index.d.ts +1 -0
  52. package/dist/src/components/legacyNavMenu/LegacyNavMenu.d.ts +27 -0
  53. package/dist/src/components/legacyNavMenu/UserProfile.d.ts +9 -0
  54. package/dist/src/components/legacyNavMenu/index.d.ts +4 -0
  55. package/dist/src/components/listpopover/ListPopover.d.ts +17 -0
  56. package/dist/src/components/listpopover/index.d.ts +1 -0
  57. package/dist/src/components/menu/Menu.d.ts +7 -0
  58. package/dist/src/components/menu/index.d.ts +2 -0
  59. package/dist/src/components/message/index.d.ts +2 -0
  60. package/dist/src/components/message/useMessage.d.ts +7 -0
  61. package/dist/src/components/modal/Modal.d.ts +6 -0
  62. package/dist/src/components/modal/index.d.ts +2 -0
  63. package/dist/src/components/navMenu/NavMenu.d.ts +14 -0
  64. package/dist/src/components/navMenu/index.d.ts +1 -0
  65. package/dist/src/components/notification/index.d.ts +2 -0
  66. package/dist/src/components/notification/useNotification.d.ts +10 -0
  67. package/dist/src/components/notificationModal/NotificationModal.d.ts +11 -0
  68. package/dist/src/components/notificationModal/index.d.ts +2 -0
  69. package/dist/src/components/pagination/Pagination.d.ts +18 -0
  70. package/dist/src/components/pagination/index.d.ts +1 -0
  71. package/dist/src/components/popover/Popover.d.ts +10 -0
  72. package/dist/src/components/popover/index.d.ts +1 -0
  73. package/dist/src/components/progress/Progress.d.ts +3 -0
  74. package/dist/src/components/progress/index.d.ts +1 -0
  75. package/dist/src/components/radio/Radio.d.ts +10 -0
  76. package/dist/src/components/radio/index.d.ts +1 -0
  77. package/dist/src/components/rate/Rate.d.ts +3 -0
  78. package/dist/src/components/rate/index.d.ts +1 -0
  79. package/dist/src/components/select/AntdSelect.d.ts +5 -0
  80. package/dist/src/components/select/Select.d.ts +7 -0
  81. package/dist/src/components/select/SummarizedSelect.d.ts +44 -0
  82. package/dist/src/components/select/index.d.ts +4 -0
  83. package/dist/src/components/skeleton/Skeleton.d.ts +11 -0
  84. package/dist/src/components/skeleton/index.d.ts +1 -0
  85. package/dist/src/components/spinner/Spinner.d.ts +6 -0
  86. package/dist/src/components/spinner/index.d.ts +1 -0
  87. package/dist/src/components/steps/Steps.d.ts +10 -0
  88. package/dist/src/components/steps/index.d.ts +2 -0
  89. package/dist/src/components/steps/useSteps.d.ts +17 -0
  90. package/dist/src/components/switch/Switch.d.ts +11 -0
  91. package/dist/src/components/switch/index.d.ts +1 -0
  92. package/dist/src/components/table/Table.d.ts +24 -0
  93. package/dist/src/components/table/index.d.ts +1 -0
  94. package/dist/src/components/tabs/Tabs.d.ts +3 -0
  95. package/dist/src/components/tabs/index.d.ts +1 -0
  96. package/dist/src/components/tag/Tag.d.ts +20 -0
  97. package/dist/src/components/tag/index.d.ts +1 -0
  98. package/dist/src/components/tooltip/Tooltip.d.ts +4 -0
  99. package/dist/src/components/tooltip/index.d.ts +1 -0
  100. package/dist/src/components/vennDiagram/VennDiagram.d.ts +9 -0
  101. package/dist/src/components/vennDiagram/index.d.ts +1 -0
  102. package/dist/src/index.d.ts +11 -0
  103. package/dist/src/vite-env.d.ts +1 -0
  104. package/dist/style.css +1254 -0
  105. package/dist/tailwind.cjs +170 -0
  106. package/dist/tailwind.cjs.map +1 -0
  107. package/dist/tailwind.config.d.ts +305 -0
  108. package/dist/tailwind.js +170 -0
  109. package/dist/tailwind.js.map +1 -0
  110. package/dist/vite.svg +1 -0
  111. package/package.json +125 -0
  112. package/src/stylesheets/index.css +327 -0
package/dist/index.js ADDED
@@ -0,0 +1,3606 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useMemo, useState, useEffect, useCallback, useReducer, forwardRef, useRef } from "react";
4
+ import { ConfigProvider, theme, Alert as Alert$1, Breadcrumb as Breadcrumb$1, Button as Button$1, Card as Card$1, Checkbox as Checkbox$1, Collapse as Collapse$1, Drawer as Drawer$1, Space, Dropdown as Dropdown$1, Typography, Select as Select$1, Input as Input$1, InputNumber as InputNumber$1, Popover as Popover$1, Tooltip as Tooltip$1, Menu as Menu$1, message, Modal as Modal$1, notification, Pagination as Pagination$1, Progress as Progress$1, Radio as Radio$1, Rate as Rate$1, Spin, Tag as Tag$1, Skeleton as Skeleton$1, Steps as Steps$1, Switch as Switch$1, Table as Table$1, Tabs as Tabs$1 } from "antd";
5
+ import * as react from "@phosphor-icons/react";
6
+ import { IconContext, XIcon, CircleNotchIcon, WarningCircleIcon, InfoIcon, XCircleIcon, CheckCircleIcon, CaretDownIcon, TrashIcon, PlusCircleIcon, CaretUpIcon, CopyIcon, CaretLeftIcon, CaretRightIcon, CaretDoubleLeftIcon, DotsThreeIcon, CaretDoubleRightIcon, StarIcon, MagnifyingGlassIcon, GearIcon, ArrowsClockwiseIcon, CheckIcon, CaretUpDownIcon } from "@phosphor-icons/react";
7
+ import Icon, { LoadingOutlined } from "@ant-design/icons";
8
+ import { Chart } from "@highcharts/react";
9
+ import { Chart as Chart2 } from "@highcharts/react";
10
+ import "@highcharts/react/options/Accessibility.js";
11
+ import "@highcharts/react/options/Exporting.js";
12
+ import { renderToString } from "react-dom/server";
13
+ import cx from "classnames";
14
+ import { cloneDeep } from "lodash";
15
+ import { Form as Form$1, FormItem, Input as Input$2, InputNumber as InputNumber$2, Select as Select$2 } from "formik-antd";
16
+ import { useField } from "formik";
17
+ import "@highcharts/react/series/Venn.js";
18
+ import { tailwindPreset } from "./tailwind.js";
19
+ function _mergeNamespaces(n, m) {
20
+ for (var i = 0; i < m.length; i++) {
21
+ const e = m[i];
22
+ if (typeof e !== "string" && !Array.isArray(e)) {
23
+ for (const k in e) {
24
+ if (k !== "default" && !(k in n)) {
25
+ const d = Object.getOwnPropertyDescriptor(e, k);
26
+ if (d) {
27
+ Object.defineProperty(n, k, d.get ? d : {
28
+ enumerable: true,
29
+ get: () => e[k]
30
+ });
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
37
+ }
38
+ const appTheme = {
39
+ token: {
40
+ // Colors
41
+ colorText: "var(--j2-color-text)",
42
+ colorTextSecondary: "var(--j2-color-text-secondary)",
43
+ colorTextTertiary: "var(--j2-color-text-tertiary)",
44
+ colorTextQuaternary: "var(--j2-color-text-quaternary)",
45
+ colorTextHeading: "var(--j2-color-text-heading)",
46
+ colorTextLabel: "var(--j2-color-text-label)",
47
+ colorTextDescription: "var(--j2-color-text-description)",
48
+ colorTextDisabled: "var(--j2-color-text-disabled)",
49
+ colorTextPlaceholder: "var(--j2-color-text-placeholder)",
50
+ colorIcon: "var(--j2-color-icon)",
51
+ colorIconHover: "var(--j2-color-icon-hover)",
52
+ colorBgLayout: "var(--j2-color-bg-layout)",
53
+ colorBorder: "var(--j2-color-border)",
54
+ colorBorderSecondary: "var(--j2-color-border-secondary)",
55
+ colorPrimary: "#253761",
56
+ // var(--j2-blue-9)
57
+ colorSuccess: "#57a45e",
58
+ // var(--j2-green-9)
59
+ colorWarning: "#9e6e00",
60
+ // var(--j2-gold-11)
61
+ colorInfo: "#253761",
62
+ // var(--j2-blue-9)
63
+ colorLink: "#253761",
64
+ // var(--j2-blue-9)
65
+ colorError: "#bf6c6f",
66
+ // var(--j2-red-9)
67
+ colorErrorBg: "var(--j2-color-error-bg)",
68
+ colorErrorBgHover: "var(--j2-color-error-bg-hover)",
69
+ colorErrorBorder: "var(--j2-color-error-border)",
70
+ colorErrorBorderHover: "var(--j2-color-error-border-hover)",
71
+ colorErrorHover: "var(--j2-color-error-hover)",
72
+ colorErrorActive: "var(--j2-color-error-active)",
73
+ colorErrorTextHover: "var(--j2-color-error-text-hover)",
74
+ colorErrorText: "var(--j2-color-error-text)",
75
+ colorErrorTextActive: "var(--j2-color-error-text-active)",
76
+ colorLinkHover: "var(--j2-color-link-hover)",
77
+ colorInfoBg: "var(--j2-color-info-bg)",
78
+ colorInfoBgHover: "var(--j2-color-info-bg-hover)",
79
+ colorInfoBorder: "var(--j2-color-info-border)",
80
+ colorInfoBorderHover: "var(--j2-color-info-border-hover)",
81
+ colorInfoHover: "var(--j2-color-info-hover)",
82
+ colorInfoActive: "var(--j2-color-info-active)",
83
+ colorInfoTextHover: "var(--j2-color-info-text-hover)",
84
+ colorInfoText: "var(--j2-color-info-text)",
85
+ colorInfoTextActive: "var(--j2-color-info-text-active)",
86
+ colorLinkActive: "var(--j2-color-link-active)",
87
+ colorPrimaryBg: "var(--j2-color-primary-bg)",
88
+ colorPrimaryBgHover: "var(--j2-color-primary-bg-hover)",
89
+ colorPrimaryBorder: "var(--j2-color-primary-border)",
90
+ colorPrimaryBorderHover: "var(--j2-color-primary-border-hover)",
91
+ colorPrimaryHover: "var(--j2-color-primary-hover)",
92
+ colorPrimaryActive: "var(--j2-color-primary-active)",
93
+ colorPrimaryTextHover: "var(--j2-color-primary-text-hover)",
94
+ colorPrimaryText: "var(--j2-color-primary-text)",
95
+ colorPrimaryTextActive: "var(--j2-color-primary-text-active)",
96
+ colorSuccessBg: "var(--j2-color-success-bg)",
97
+ colorSuccessBgHover: "var(--j2-color-success-bg-hover)",
98
+ colorSuccessBorder: "var(--j2-color-success-border)",
99
+ colorSuccessBorderHover: "var(--j2-color-success-border-hover)",
100
+ colorSuccessHover: "var(--j2-color-success-hover)",
101
+ colorSuccessActive: "var(--j2-color-success-active)",
102
+ colorSuccessTextHover: "var(--j2-color-success-text-hover)",
103
+ colorSuccessText: "var(--j2-color-success-text)",
104
+ colorSuccessTextActive: "var(--j2-color-success-text-active)",
105
+ colorWarningBg: "var(--j2-color-warning-bg)",
106
+ colorWarningBgHover: "var(--j2-color-warning-bg-hover)",
107
+ colorWarningBorder: "var(--j2-color-warning-border)",
108
+ colorWarningBorderHover: "var(--j2-color-warning-border-hover)",
109
+ colorWarningHover: "var(--j2-color-warning-hover)",
110
+ colorWarningActive: "var(--j2-color-warning-active)",
111
+ colorWarningTextHover: "var(--j2-color-warning-text-hover)",
112
+ colorWarningText: "var(--j2-color-warning-text)",
113
+ colorWarningTextActive: "var(--j2-color-warning-text-active)",
114
+ controlItemBgActive: "var(--j2-control-item-bg-active)",
115
+ controlItemBgActiveHover: "var(--j2-control-item-bg-active-hover)",
116
+ colorFill: "var(--j2-color-fill)",
117
+ colorFillSecondary: "var(--j2-color-fill-secondary)",
118
+ colorFillTertiary: "var(--j2-color-fill-tertiary)",
119
+ colorFillQuaternary: "var(--j2-color-fill-quaternary)",
120
+ colorFillContent: "var(--j2-color-fill-content)",
121
+ colorFillContentHover: "var(--j2-color-fill-content-hover)",
122
+ colorBgMask: "var(--j2-color-bg-mask)",
123
+ colorBgSpotlight: "var(--j2-color-bg-spotlight)",
124
+ colorBgContainerDisabled: "var(--j2-color-bg-container-disabled)",
125
+ colorBgTextActive: "var(--j2-color-bg-text-active)",
126
+ colorBgTextHover: "var(--j2-color-bg-text-hover)",
127
+ colorFillAlter: "var(--j2-color-fill-alter)",
128
+ colorSplit: "var(--j2-color-split)",
129
+ colorErrorOutline: "var(--j2-color-error-outline)",
130
+ colorWarningOutline: "var(--j2-color-warning-outline)",
131
+ controlItemBgActiveDisabled: "var(--j2-control-item-bg-active-disabled)",
132
+ controlItemBgHover: "var(--j2-control-item-bg-hover)",
133
+ controlOutline: "var(--j2-control-outline)",
134
+ controlTmpOutline: "var(--j2-control-tmp-outline)",
135
+ // Typography
136
+ fontFamily: "Rubik, sans-serif",
137
+ fontFamilyCode: "Rubik, sans-serif",
138
+ fontSize: 14,
139
+ fontSizeLG: 16,
140
+ fontSizeSM: 12,
141
+ fontSizeXL: 20,
142
+ fontSizeHeading1: 38,
143
+ fontSizeHeading2: 30,
144
+ fontSizeHeading3: 24,
145
+ fontSizeHeading4: 20,
146
+ fontSizeHeading5: 16,
147
+ lineHeight: 1.5714285714285714,
148
+ lineHeightHeading1: 1.2105263157894737,
149
+ lineHeightHeading2: 1.2666666666666666,
150
+ lineHeightHeading3: 1.3333333333333333,
151
+ lineHeightHeading4: 1.4,
152
+ lineHeightHeading5: 1.5,
153
+ lineHeightLG: 1.5,
154
+ lineHeightSM: 1.6666666666666667,
155
+ fontSizeIcon: 12,
156
+ fontWeightStrong: 600,
157
+ // Border
158
+ borderRadius: 8,
159
+ borderRadiusLG: 10,
160
+ borderRadiusSM: 6,
161
+ borderRadiusXS: 2,
162
+ // Spacing and sizing
163
+ sizeStep: 4,
164
+ sizeUnit: 4,
165
+ controlInteractiveSize: 16,
166
+ size: 16,
167
+ sizeLG: 24,
168
+ sizeMD: 20,
169
+ sizeMS: 16,
170
+ sizeSM: 12,
171
+ sizeXL: 32,
172
+ sizeXS: 8,
173
+ sizeXXL: 48,
174
+ controlHeight: 32,
175
+ sizeXXS: 4,
176
+ controlHeightLG: 40,
177
+ controlHeightSM: 24,
178
+ controlHeightXS: 16,
179
+ lineWidth: 1,
180
+ lineWidthBold: 2,
181
+ lineWidthFocus: 4,
182
+ controlOutlineWidth: 2,
183
+ screenLG: 992,
184
+ screenLGMax: 1199,
185
+ screenLGMin: 992,
186
+ screenMD: 768,
187
+ screenMDMax: 991,
188
+ screenMDMin: 768,
189
+ screenSM: 576,
190
+ screenSMMax: 767,
191
+ screenSMMin: 576,
192
+ screenXL: 1200,
193
+ screenXLMax: 1599,
194
+ screenXLMin: 1200,
195
+ screenXS: 480,
196
+ screenXSMax: 575,
197
+ screenXSMin: 480,
198
+ screenXXL: 1600,
199
+ screenXXLMin: 1600,
200
+ sizePopupArrow: 16,
201
+ margin: 16,
202
+ marginLG: 24,
203
+ marginMD: 20,
204
+ marginSM: 12,
205
+ marginXL: 32,
206
+ marginXS: 8,
207
+ marginXXL: 48,
208
+ marginXXS: 4,
209
+ padding: 16,
210
+ paddingLG: 24,
211
+ paddingMD: 20,
212
+ paddingSM: 12,
213
+ paddingXL: 32,
214
+ paddingXS: 8,
215
+ paddingXXS: 4,
216
+ paddingContentHorizontal: 16,
217
+ paddingContentHorizontalLG: 24,
218
+ paddingContentHorizontalSM: 16,
219
+ paddingContentVertical: 12,
220
+ paddingContentVerticalLG: 16,
221
+ paddingContentVerticalSM: 8,
222
+ controlPaddingHorizontal: 12,
223
+ controlPaddingHorizontalSM: 8
224
+ },
225
+ components: {
226
+ Alert: {
227
+ paddingContentHorizontalLG: 16
228
+ // Use standard padding instead of paddingLG when description is present
229
+ },
230
+ Breadcrumb: {
231
+ itemColor: "var(--j2-color-text-label)",
232
+ lastItemColor: "var(--j2-color-primary)",
233
+ linkColor: "inherit",
234
+ linkHoverColor: "var(--j2-color-link-hover)",
235
+ colorBgTextHover: "var(--j2-color-primary-bg-hover)"
236
+ },
237
+ Button: {
238
+ defaultColor: "var(--j2-color-primary-text)",
239
+ defaultBorderColor: "var(--j2-color-border)",
240
+ defaultHoverBorderColor: "var(--j2-color-primary-active)",
241
+ defaultActiveBorderColor: "var(--j2-color-primary-active)",
242
+ ghostBg: "#fff",
243
+ defaultGhostBorderColor: "var(--j2-color-primary)",
244
+ defaultGhostColor: "var(--j2-color-primary-text)",
245
+ textTextColor: "var(--j2-color-primary-text)",
246
+ textHoverBg: "var(--j2-gray-2)",
247
+ textTextHoverColor: "var(--j2-color-primary-text-hover)",
248
+ textTextActiveColor: "var(--j2-color-primary-text-active)"
249
+ },
250
+ Form: {
251
+ itemMarginBottom: 0,
252
+ labelHeight: "100%"
253
+ },
254
+ Input: {
255
+ activeBorderColor: "var(--j2-color-primary-active)"
256
+ },
257
+ InputNumber: {
258
+ handleVisible: true,
259
+ handleHoverColor: "var(--j2-color-primary-text)",
260
+ handleBorderColor: "var(--j2-color-border)",
261
+ handleBg: "var(--j2-color-bg-container-disabled)"
262
+ },
263
+ Menu: {
264
+ itemColor: "var(--j2-color-primary-text)",
265
+ itemSelectedBg: "var(--j2-color-primary)",
266
+ itemSelectedColor: "#fff",
267
+ itemMarginInline: 12
268
+ },
269
+ Progress: {
270
+ defaultColor: "var(--j2-color-primary)"
271
+ },
272
+ Rate: {
273
+ marginXS: 0
274
+ },
275
+ Radio: {
276
+ // Unselected outlined radio-button labels default to colorText (near-black);
277
+ // align them with the selected label's primary blue so the control reads as
278
+ // a single cohesive outlined-blue selector.
279
+ buttonColor: "var(--j2-color-primary)"
280
+ },
281
+ Select: {
282
+ multipleItemBg: "var(--j2-gray-2)",
283
+ multipleItemBorderColor: "var(--j2-gray-4)",
284
+ colorText: "var(--j2-color-primary-text)"
285
+ },
286
+ Tooltip: {
287
+ colorBgSpotlight: "var(--j2-color-primary-active)"
288
+ },
289
+ Table: {
290
+ headerBg: "var(--j2-color-bg-layout)",
291
+ rowHoverBg: "var(--j2-color-bg-layout)",
292
+ bodySortBg: "var(--j2-gray-2)",
293
+ headerSortHoverBg: "var(--j2-gray-3)",
294
+ headerSortActiveBg: "var(--j2-gray-3)",
295
+ fixedHeaderSortActiveBg: "var(--j2-gray-3)"
296
+ },
297
+ Tag: {
298
+ defaultBg: "var(--j2-color-fill-secondary)"
299
+ }
300
+ }
301
+ };
302
+ const AppConfigProvider = ({
303
+ children
304
+ }) => {
305
+ return /* @__PURE__ */ jsx(ConfigProvider, { theme: appTheme, children: /* @__PURE__ */ jsx(IconContext.Provider, { value: { weight: "duotone", size: 16 }, children }) });
306
+ };
307
+ const alert = "_alert_1yhxg_2";
308
+ const styles$b = {
309
+ alert
310
+ };
311
+ const Alert = ({
312
+ description,
313
+ type,
314
+ closable = false,
315
+ showIcon = true,
316
+ banner = false,
317
+ ...props
318
+ }) => {
319
+ const { token } = theme.useToken();
320
+ const icon = React.useMemo(() => {
321
+ const size = description ? token.sizeLG : token.size;
322
+ const iconStyle = !description ? { display: "flex", alignItems: "center" } : void 0;
323
+ const iconElement = (() => {
324
+ switch (type) {
325
+ case "success":
326
+ return /* @__PURE__ */ jsx(CheckCircleIcon, { fill: "var(--j2-color-success-text)", size });
327
+ case "error":
328
+ return /* @__PURE__ */ jsx(XCircleIcon, { fill: "var(--j2-color-error-text)", size });
329
+ case "info":
330
+ return /* @__PURE__ */ jsx(InfoIcon, { fill: "var(--j2-color-info-text)", size });
331
+ case "warning":
332
+ return /* @__PURE__ */ jsx(
333
+ WarningCircleIcon,
334
+ {
335
+ fill: "var(--j2-color-warning-text)",
336
+ size
337
+ }
338
+ );
339
+ case "loading":
340
+ return /* @__PURE__ */ jsx(
341
+ CircleNotchIcon,
342
+ {
343
+ fill: "var(--j2-color-info-text)",
344
+ size,
345
+ weight: "regular",
346
+ style: {
347
+ animation: "spin 1s linear infinite"
348
+ }
349
+ }
350
+ );
351
+ default:
352
+ return null;
353
+ }
354
+ })();
355
+ return iconStyle ? /* @__PURE__ */ jsx("span", { style: iconStyle, children: iconElement }) : iconElement;
356
+ }, [type, description, token.size, token.sizeLG]);
357
+ const antDType = React.useMemo(() => {
358
+ switch (type) {
359
+ case "loading":
360
+ return "info";
361
+ default:
362
+ return type;
363
+ }
364
+ }, [type]);
365
+ return /* @__PURE__ */ jsx(
366
+ Alert$1,
367
+ {
368
+ className: styles$b.alert,
369
+ icon,
370
+ closable,
371
+ showIcon,
372
+ type: antDType,
373
+ banner,
374
+ description,
375
+ closeIcon: /* @__PURE__ */ jsx(XIcon, { size: token.size, weight: "regular" }),
376
+ ...props
377
+ }
378
+ );
379
+ };
380
+ const tooltip = "_tooltip_1g39l_1";
381
+ const styles$a = {
382
+ tooltip
383
+ };
384
+ const BarChart = ({
385
+ categories,
386
+ series,
387
+ min,
388
+ max,
389
+ tickInterval,
390
+ tickFormat,
391
+ xAxisTitle,
392
+ yAxisTitle,
393
+ gridLineColor,
394
+ gridLineDashStyle,
395
+ xAxisLabelMaxLines,
396
+ tooltip: tooltip2,
397
+ exporting,
398
+ chartRef,
399
+ height,
400
+ width,
401
+ maxBars = 50,
402
+ barsWidth = void 0
403
+ }) => {
404
+ var _a, _b, _c, _d, _e;
405
+ const limitedCategories = categories.slice(0, maxBars);
406
+ const limitedSeries = series.map((s2) => ({
407
+ ...s2,
408
+ data: s2.data.slice(0, maxBars)
409
+ }));
410
+ const { token } = theme.useToken();
411
+ const baseFont = {
412
+ fontSize: `${token.fontSize}px`,
413
+ fontFamily: token.fontFamily,
414
+ color: token.colorText
415
+ };
416
+ const options = {
417
+ credits: {
418
+ enabled: false
419
+ },
420
+ chart: {
421
+ type: "column",
422
+ ...height ? { height } : {},
423
+ ...width ? { width } : {}
424
+ },
425
+ plotOptions: {
426
+ column: {
427
+ borderRadius: series[0].data.length > 5 ? "20%" : "15%",
428
+ ...barsWidth !== void 0 ? { pointWidth: barsWidth } : {}
429
+ }
430
+ },
431
+ exporting: {
432
+ ...exporting,
433
+ enabled: false,
434
+ chartOptions: {
435
+ ...exporting == null ? void 0 : exporting.chartOptions,
436
+ title: {
437
+ align: "left",
438
+ text: (_b = (_a = exporting == null ? void 0 : exporting.chartOptions) == null ? void 0 : _a.title) == null ? void 0 : _b.text,
439
+ style: {
440
+ fontSize: `${token.fontSize}px`,
441
+ fontFamily: "sans-serif",
442
+ color: token.colorText,
443
+ ...(_d = (_c = exporting == null ? void 0 : exporting.chartOptions) == null ? void 0 : _c.title) == null ? void 0 : _d.style
444
+ }
445
+ },
446
+ series: limitedSeries.map((s2) => ({
447
+ type: "column",
448
+ color: s2.color ? s2.color : "#253761"
449
+ // --j2-blue-9
450
+ })),
451
+ legend: ((_e = exporting == null ? void 0 : exporting.chartOptions) == null ? void 0 : _e.legend) || { enabled: false }
452
+ }
453
+ },
454
+ title: {
455
+ text: ""
456
+ },
457
+ xAxis: {
458
+ categories: limitedCategories,
459
+ title: xAxisTitle ? {
460
+ text: xAxisTitle,
461
+ style: { ...baseFont, color: token.colorTextDescription }
462
+ } : void 0,
463
+ labels: {
464
+ y: 30,
465
+ style: baseFont,
466
+ ...xAxisLabelMaxLines ? {
467
+ useHTML: true,
468
+ formatter: function() {
469
+ return `<div style="overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: ${xAxisLabelMaxLines}; -webkit-box-orient: vertical; text-align: center;">${this.value}</div>`;
470
+ }
471
+ } : {}
472
+ }
473
+ },
474
+ yAxis: {
475
+ min,
476
+ max,
477
+ endOnTick: true,
478
+ gridLineDashStyle: gridLineDashStyle || "Dot",
479
+ gridLineColor: gridLineColor || "white",
480
+ title: yAxisTitle ? {
481
+ text: yAxisTitle,
482
+ style: { ...baseFont, color: token.colorTextDescription },
483
+ x: -10
484
+ } : void 0,
485
+ tickInterval,
486
+ labels: {
487
+ formatter: tickFormat ? ({ value }) => tickFormat(value) : void 0,
488
+ style: baseFont
489
+ }
490
+ },
491
+ legend: {
492
+ enabled: false
493
+ },
494
+ series: limitedSeries.map((s2) => ({
495
+ data: s2.data,
496
+ name: s2.name,
497
+ type: "column",
498
+ color: s2.color || "var(--j2-blue-11)",
499
+ states: {
500
+ hover: {
501
+ color: s2.hoverColor || token.colorPrimaryTextHover
502
+ }
503
+ }
504
+ })),
505
+ tooltip: {
506
+ useHTML: true,
507
+ outside: true,
508
+ backgroundColor: "transparent",
509
+ shadow: false,
510
+ padding: 0,
511
+ style: { zIndex: 9999 },
512
+ formatter: function() {
513
+ return renderToString(
514
+ /* @__PURE__ */ jsx("div", { className: styles$a.tooltip, children: tooltip2(this.key, this.y, this.series.name) })
515
+ );
516
+ }
517
+ }
518
+ };
519
+ return /* @__PURE__ */ jsx(Chart, { ref: chartRef, options });
520
+ };
521
+ const Breadcrumb = ({ items, ...props }) => {
522
+ const antDItems = React.useMemo(
523
+ () => items.map((item) => ({
524
+ href: item.href,
525
+ onClick: item.onClick,
526
+ title: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
527
+ item.icon && /* @__PURE__ */ jsx(item.icon, { size: 14 }),
528
+ item.title
529
+ ] })
530
+ })),
531
+ [items]
532
+ );
533
+ return /* @__PURE__ */ jsx(Breadcrumb$1, { ...props, items: antDItems });
534
+ };
535
+ const Button = ({ type, size, ghost, danger, shape, ...props }) => {
536
+ return /* @__PURE__ */ jsx(
537
+ Button$1,
538
+ {
539
+ ...props,
540
+ type,
541
+ size,
542
+ ghost,
543
+ danger,
544
+ shape,
545
+ children: props.children
546
+ }
547
+ );
548
+ };
549
+ const BulkActionBar = ({
550
+ count,
551
+ action,
552
+ secondaryActions,
553
+ onCancel,
554
+ cancelLabel = "Cancel"
555
+ }) => {
556
+ const visible = count > 0;
557
+ const label = `${count} selected`;
558
+ return /* @__PURE__ */ jsx(
559
+ "div",
560
+ {
561
+ role: "region",
562
+ "aria-label": "Bulk actions",
563
+ "aria-hidden": !visible,
564
+ className: cx(
565
+ "pointer-events-none fixed bottom-6 left-1/2 z-50",
566
+ "-translate-x-1/2 transition duration-200 ease-out",
567
+ visible ? "translate-y-0 opacity-100" : "pointer-events-none translate-y-4 opacity-0"
568
+ ),
569
+ children: /* @__PURE__ */ jsxs(
570
+ "div",
571
+ {
572
+ className: cx(
573
+ "pointer-events-auto flex items-center gap-3 rounded-full",
574
+ "bg-j2-primary-active py-2 pl-4 pr-2 text-white shadow-lg"
575
+ ),
576
+ children: [
577
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: label }),
578
+ /* @__PURE__ */ jsx("div", { className: "h-5 w-px bg-white/20" }),
579
+ /* @__PURE__ */ jsx(
580
+ Button,
581
+ {
582
+ type: "text",
583
+ shape: "round",
584
+ size: "small",
585
+ icon: action.icon,
586
+ loading: action.loading,
587
+ onClick: action.onClick,
588
+ className: "!text-white hover:!bg-white/10 hover:!text-white",
589
+ children: action.label
590
+ }
591
+ ),
592
+ secondaryActions == null ? void 0 : secondaryActions.map((sec) => /* @__PURE__ */ jsx(
593
+ Button,
594
+ {
595
+ type: "text",
596
+ shape: "round",
597
+ size: "small",
598
+ icon: sec.icon,
599
+ loading: sec.loading,
600
+ onClick: sec.onClick,
601
+ className: "!text-white hover:!bg-white/10 hover:!text-white",
602
+ children: sec.label
603
+ },
604
+ sec.label
605
+ )),
606
+ /* @__PURE__ */ jsx(
607
+ Button,
608
+ {
609
+ type: "text",
610
+ shape: "round",
611
+ size: "small",
612
+ onClick: onCancel,
613
+ className: "!text-white hover:!bg-white/10 hover:!text-white",
614
+ children: cancelLabel
615
+ }
616
+ )
617
+ ]
618
+ }
619
+ )
620
+ }
621
+ );
622
+ };
623
+ const Card = ({
624
+ title,
625
+ children,
626
+ loading,
627
+ size = "default",
628
+ innerVariant = "default",
629
+ className,
630
+ ...props
631
+ }) => {
632
+ const isInner = props.type === "inner";
633
+ const isInnerBasic = isInner && innerVariant === "basic";
634
+ return /* @__PURE__ */ jsx(
635
+ Card$1,
636
+ {
637
+ className: cx(
638
+ "j2-card",
639
+ `j2-card-${size}`,
640
+ isInnerBasic && "inner-basic",
641
+ className
642
+ ),
643
+ ...props,
644
+ size: size === "large" || size === "compact" ? "default" : size,
645
+ title,
646
+ loading,
647
+ children
648
+ }
649
+ );
650
+ };
651
+ const Checkbox = (props) => {
652
+ return /* @__PURE__ */ jsx(Checkbox$1, { ...props });
653
+ };
654
+ Checkbox.Group = Checkbox$1.Group;
655
+ const getLeafKeys = (node) => {
656
+ const keys = [];
657
+ const traverse = (currentNode) => {
658
+ if (!currentNode.children || currentNode.children.length === 0) {
659
+ keys.push(currentNode.key);
660
+ } else {
661
+ currentNode.children.forEach((child) => traverse(child));
662
+ }
663
+ };
664
+ traverse(node);
665
+ return keys;
666
+ };
667
+ const getAllLeafKeys = (nodes) => {
668
+ const keys = [];
669
+ nodes.forEach((node) => {
670
+ keys.push(...getLeafKeys(node));
671
+ });
672
+ return keys;
673
+ };
674
+ const getNodeCheckState = (node, leafNodeStates) => {
675
+ let hasChecked = false;
676
+ let hasUnchecked = false;
677
+ const visit = (current) => {
678
+ if (!current.children || current.children.length === 0) {
679
+ if (leafNodeStates[current.key] === true) {
680
+ hasChecked = true;
681
+ } else {
682
+ hasUnchecked = true;
683
+ }
684
+ return hasChecked && hasUnchecked;
685
+ }
686
+ return current.children.some(visit);
687
+ };
688
+ visit(node);
689
+ return {
690
+ checked: hasChecked && !hasUnchecked,
691
+ indeterminate: hasChecked && hasUnchecked
692
+ };
693
+ };
694
+ const getAllParentKeys = (nodes) => {
695
+ const keys = [];
696
+ const traverse = (currentNodes) => {
697
+ currentNodes.forEach((node) => {
698
+ if (node.children && node.children.length > 0) {
699
+ keys.push(node.key);
700
+ traverse(node.children);
701
+ }
702
+ });
703
+ };
704
+ traverse(nodes);
705
+ return keys;
706
+ };
707
+ const TreeNode = ({
708
+ node,
709
+ level,
710
+ leafNodeValues,
711
+ onCheck,
712
+ disabled,
713
+ expandedKeys,
714
+ onToggleExpand,
715
+ lazyChildren
716
+ }) => {
717
+ const { checked: isChecked, indeterminate } = getNodeCheckState(
718
+ node,
719
+ leafNodeValues
720
+ );
721
+ const isIndeterminate = lazyChildren && indeterminate;
722
+ const isDisabled = disabled || node.disabled;
723
+ const hasChildren = node.children && node.children.length > 0;
724
+ const isExpanded = expandedKeys.has(node.key);
725
+ return /* @__PURE__ */ jsxs("div", { children: [
726
+ /* @__PURE__ */ jsxs(
727
+ "div",
728
+ {
729
+ className: "flex items-center min-h-6 mb-1",
730
+ style: { paddingLeft: level * 20 },
731
+ children: [
732
+ /* @__PURE__ */ jsx(
733
+ Checkbox,
734
+ {
735
+ checked: isChecked,
736
+ indeterminate: isIndeterminate,
737
+ disabled: isDisabled,
738
+ onChange: (e) => onCheck(node.key, e.target.checked, node),
739
+ children: node.title
740
+ }
741
+ ),
742
+ hasChildren && !isDisabled && /* @__PURE__ */ jsx(
743
+ "button",
744
+ {
745
+ type: "button",
746
+ onClick: () => onToggleExpand(node.key),
747
+ className: "flex items-center justify-center ml-auto cursor-pointer bg-transparent border-none p-0",
748
+ "aria-expanded": isExpanded,
749
+ "aria-label": `${isExpanded ? "Collapse" : "Expand"}${typeof node.title === "string" ? ` ${node.title}` : ""}`,
750
+ children: /* @__PURE__ */ jsx(
751
+ CaretDownIcon,
752
+ {
753
+ size: 14,
754
+ style: {
755
+ transform: `rotate(${isExpanded ? 0 : -90}deg)`,
756
+ transition: "transform 150ms ease"
757
+ }
758
+ }
759
+ )
760
+ }
761
+ )
762
+ ]
763
+ }
764
+ ),
765
+ hasChildren && /* @__PURE__ */ jsx(
766
+ "div",
767
+ {
768
+ style: {
769
+ display: "grid",
770
+ gridTemplateRows: isExpanded ? "1fr" : "0fr",
771
+ transition: "grid-template-rows 150ms ease"
772
+ },
773
+ children: /* @__PURE__ */ jsx("div", { style: { overflow: "hidden" }, children: (!lazyChildren || isExpanded) && node.children.map((childNode) => /* @__PURE__ */ jsx(
774
+ TreeNode,
775
+ {
776
+ node: childNode,
777
+ level: level + 1,
778
+ leafNodeValues,
779
+ onCheck,
780
+ disabled,
781
+ expandedKeys,
782
+ onToggleExpand,
783
+ lazyChildren
784
+ },
785
+ childNode.key
786
+ )) })
787
+ }
788
+ )
789
+ ] });
790
+ };
791
+ const CheckboxTree = ({
792
+ treeData,
793
+ defaultCheckedKeys = [],
794
+ checkedKeys: controlledCheckedKeys,
795
+ onCheck,
796
+ disabled = false,
797
+ defaultExpandAll = true,
798
+ defaultExpandedKeys,
799
+ expandedKeys: controlledExpandedKeys,
800
+ onExpand,
801
+ className,
802
+ style,
803
+ lazyChildren = false
804
+ }) => {
805
+ const allLeafKeys = useMemo(() => getAllLeafKeys(treeData), [treeData]);
806
+ const leafKeySet = useMemo(() => new Set(allLeafKeys), [allLeafKeys]);
807
+ const [internalLeafNodeValues, setInternalLeafNodeValues] = useState(() => {
808
+ const defaultLeafKeySet = new Set(
809
+ defaultCheckedKeys.filter((key) => leafKeySet.has(key))
810
+ );
811
+ const values = {};
812
+ for (const key of allLeafKeys) {
813
+ values[key] = defaultLeafKeySet.has(key);
814
+ }
815
+ return values;
816
+ });
817
+ const [internalExpandedKeys, setInternalExpandedKeys] = useState(() => {
818
+ if (defaultExpandedKeys) return defaultExpandedKeys;
819
+ if (defaultExpandAll) return getAllParentKeys(treeData);
820
+ return [];
821
+ });
822
+ useEffect(() => {
823
+ if (controlledExpandedKeys || !defaultExpandAll || defaultExpandedKeys)
824
+ return;
825
+ const allParentKeys = getAllParentKeys(treeData);
826
+ setInternalExpandedKeys((prev) => {
827
+ const prevSet = new Set(prev);
828
+ const newKeys = allParentKeys.filter((key) => !prevSet.has(key));
829
+ if (newKeys.length === 0) return prev;
830
+ return [...prev, ...newKeys];
831
+ });
832
+ }, [treeData, defaultExpandAll, controlledExpandedKeys, defaultExpandedKeys]);
833
+ const expandedKeysSet = useMemo(() => {
834
+ const keys = controlledExpandedKeys ?? internalExpandedKeys;
835
+ return new Set(keys);
836
+ }, [controlledExpandedKeys, internalExpandedKeys]);
837
+ const handleToggleExpand = useCallback(
838
+ (key) => {
839
+ const currentKeys = controlledExpandedKeys ?? internalExpandedKeys;
840
+ const newKeys = currentKeys.includes(key) ? currentKeys.filter((k) => k !== key) : [...currentKeys, key];
841
+ if (!controlledExpandedKeys) {
842
+ setInternalExpandedKeys(newKeys);
843
+ }
844
+ onExpand == null ? void 0 : onExpand(newKeys);
845
+ },
846
+ [controlledExpandedKeys, internalExpandedKeys, onExpand]
847
+ );
848
+ const leafNodeValues = useMemo(() => {
849
+ if (!controlledCheckedKeys) {
850
+ return internalLeafNodeValues;
851
+ }
852
+ const controlledLeafKeySet = new Set(
853
+ controlledCheckedKeys.filter((key) => leafKeySet.has(key))
854
+ );
855
+ const values = {};
856
+ for (const key of allLeafKeys) {
857
+ values[key] = controlledLeafKeySet.has(key);
858
+ }
859
+ return values;
860
+ }, [allLeafKeys, leafKeySet, controlledCheckedKeys, internalLeafNodeValues]);
861
+ const handleCheck = useCallback(
862
+ (_key, checked, node) => {
863
+ const newLeafNodeValues = { ...leafNodeValues };
864
+ if (checked) {
865
+ const leafKeys = getLeafKeys(node);
866
+ leafKeys.forEach((leafKey) => newLeafNodeValues[leafKey] = true);
867
+ } else {
868
+ const leafKeys = getLeafKeys(node);
869
+ leafKeys.forEach((leafKey) => newLeafNodeValues[leafKey] = false);
870
+ }
871
+ if (!controlledCheckedKeys) {
872
+ setInternalLeafNodeValues(newLeafNodeValues);
873
+ }
874
+ if (onCheck) {
875
+ const checkedLeafNodes = {};
876
+ const allCheckedNodes = [];
877
+ const collectChecked = (current) => {
878
+ let isChecked;
879
+ if (!current.children || current.children.length === 0) {
880
+ isChecked = newLeafNodeValues[current.key] === true;
881
+ if (isChecked) {
882
+ checkedLeafNodes[current.key] = current;
883
+ }
884
+ } else {
885
+ isChecked = true;
886
+ for (const child of current.children) {
887
+ if (!collectChecked(child)) {
888
+ isChecked = false;
889
+ }
890
+ }
891
+ }
892
+ if (isChecked) {
893
+ allCheckedNodes.push(current);
894
+ }
895
+ return isChecked;
896
+ };
897
+ treeData.forEach(collectChecked);
898
+ onCheck(newLeafNodeValues, {
899
+ checked,
900
+ checkedLeafNodes,
901
+ allCheckedNodes,
902
+ node
903
+ });
904
+ }
905
+ },
906
+ [controlledCheckedKeys, onCheck, treeData, leafNodeValues]
907
+ );
908
+ return /* @__PURE__ */ jsx("div", { className, style, children: treeData.map((node) => /* @__PURE__ */ jsx(
909
+ TreeNode,
910
+ {
911
+ node,
912
+ level: 0,
913
+ leafNodeValues,
914
+ onCheck: handleCheck,
915
+ disabled,
916
+ expandedKeys: expandedKeysSet,
917
+ onToggleExpand: handleToggleExpand,
918
+ lazyChildren
919
+ },
920
+ node.key
921
+ )) });
922
+ };
923
+ const warning = "_warning_yukjt_2";
924
+ const error = "_error_yukjt_3";
925
+ const styles$9 = {
926
+ "default": "_default_yukjt_1",
927
+ warning,
928
+ error
929
+ };
930
+ const stateConfig = {
931
+ default: {
932
+ className: styles$9.default,
933
+ Icon: InfoIcon,
934
+ color: "var(--j2-color-text)"
935
+ },
936
+ warning: {
937
+ className: styles$9.warning,
938
+ Icon: WarningCircleIcon,
939
+ color: "var(--j2-color-warning-text)"
940
+ },
941
+ error: {
942
+ className: styles$9.error,
943
+ Icon: XCircleIcon,
944
+ color: "var(--j2-color-error-text)"
945
+ }
946
+ };
947
+ const Collapse = ({
948
+ state = "default",
949
+ showIcon = false,
950
+ className,
951
+ items,
952
+ ...props
953
+ }) => {
954
+ const { className: stateClass, Icon: Icon2, color } = stateConfig[state];
955
+ const icon = React.useMemo(() => {
956
+ if (!showIcon) return null;
957
+ return /* @__PURE__ */ jsx(Icon2, { size: 14, fill: color, style: { flexShrink: 0 } });
958
+ }, [state, showIcon]);
959
+ const itemsWithIcon = React.useMemo(() => {
960
+ if (!icon || !items) return items;
961
+ return items.map((item) => ({
962
+ ...item,
963
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
964
+ icon,
965
+ item.label
966
+ ] })
967
+ }));
968
+ }, [items, icon]);
969
+ return /* @__PURE__ */ jsx(
970
+ Collapse$1,
971
+ {
972
+ ...props,
973
+ items: itemsWithIcon,
974
+ className: [stateClass, className].filter(Boolean).join(" "),
975
+ expandIcon: ({ isActive: isActive2 }) => /* @__PURE__ */ jsx(
976
+ CaretDownIcon,
977
+ {
978
+ size: 14,
979
+ style: { transform: `rotate(${isActive2 ? 0 : -90}deg)` }
980
+ }
981
+ )
982
+ }
983
+ );
984
+ };
985
+ const Drawer = ({
986
+ fillPage = false,
987
+ footer,
988
+ extraContent,
989
+ ...props
990
+ }) => {
991
+ return /* @__PURE__ */ jsx(
992
+ Drawer$1,
993
+ {
994
+ ...props,
995
+ closable: false,
996
+ ...fillPage && { height: "100vh", width: "100vw" },
997
+ ...footer && { footer },
998
+ extra: /* @__PURE__ */ jsxs(Space, { children: [
999
+ extraContent,
1000
+ /* @__PURE__ */ jsx(
1001
+ Button,
1002
+ {
1003
+ className: "p-0",
1004
+ type: "link",
1005
+ onClick: props.onClose,
1006
+ "aria-label": "Close",
1007
+ children: /* @__PURE__ */ jsx(XIcon, { size: 22, weight: "regular" })
1008
+ }
1009
+ )
1010
+ ] }),
1011
+ className: "j2-drawer"
1012
+ }
1013
+ );
1014
+ };
1015
+ const { Link } = Typography;
1016
+ const LabelWithCaret = ({ label }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1017
+ label,
1018
+ /* @__PURE__ */ jsx(CaretDownIcon, { weight: "regular" })
1019
+ ] });
1020
+ const Target = ({ label, type, disabled, icon, className }) => {
1021
+ if (type === "basic-inline") {
1022
+ return /* @__PURE__ */ jsx(Link, { disabled, className: cx("flex gap-1", className), children: icon ? /* @__PURE__ */ jsxs(Fragment, { children: [
1023
+ icon,
1024
+ label
1025
+ ] }) : /* @__PURE__ */ jsx(LabelWithCaret, { label }) });
1026
+ }
1027
+ return /* @__PURE__ */ jsx(Button, { disabled, icon, className, children: icon ? label : /* @__PURE__ */ jsx(LabelWithCaret, { label }) });
1028
+ };
1029
+ const Dropdown = ({
1030
+ label,
1031
+ type,
1032
+ icon,
1033
+ menu,
1034
+ menuType = "default",
1035
+ targetClassName,
1036
+ ...props
1037
+ }) => {
1038
+ let menuProp = menu;
1039
+ if (menuType === "slim" && typeof menu === "object") {
1040
+ menuProp = {
1041
+ ...menu,
1042
+ className: cx(menu.className, "j2-dropdown-slim-menu")
1043
+ };
1044
+ }
1045
+ if (type === "twofold") {
1046
+ return /* @__PURE__ */ jsx(Dropdown$1.Button, { ...props, menu: menuProp, children: icon ? /* @__PURE__ */ jsxs(Fragment, { children: [
1047
+ icon,
1048
+ " ",
1049
+ label
1050
+ ] }) : label });
1051
+ }
1052
+ return /* @__PURE__ */ jsx(Dropdown$1, { ...props, menu: menuProp, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1053
+ Target,
1054
+ {
1055
+ label,
1056
+ type,
1057
+ disabled: props.disabled,
1058
+ icon,
1059
+ className: targetClassName
1060
+ }
1061
+ ) }) });
1062
+ };
1063
+ const j2FilterForm = "_j2FilterForm_rdja9_1";
1064
+ const filterFormTitle = "_filterFormTitle_rdja9_2";
1065
+ const filterFormConjunction = "_filterFormConjunction_rdja9_6";
1066
+ const filterFormFieldsContainer = "_filterFormFieldsContainer_rdja9_10";
1067
+ const filterFormGroupContainer = "_filterFormGroupContainer_rdja9_15";
1068
+ const s$4 = {
1069
+ j2FilterForm,
1070
+ filterFormTitle,
1071
+ filterFormConjunction,
1072
+ filterFormFieldsContainer,
1073
+ filterFormGroupContainer
1074
+ };
1075
+ const isEmptyFilter = (filter) => {
1076
+ if (filter.operator === "blank" || filter.operator === "notBlank") {
1077
+ return false;
1078
+ }
1079
+ if (filter.values && filter.values.length > 0 && filter.values.every(
1080
+ (value) => value !== "" && value !== void 0 && value !== null
1081
+ )) {
1082
+ return false;
1083
+ }
1084
+ return true;
1085
+ };
1086
+ const isEmptyFormFilter = (filter) => {
1087
+ if (filter.operator === "blank" || filter.operator === "notBlank") {
1088
+ return false;
1089
+ }
1090
+ if (filter.values && filter.values.length > 0 && filter.values.every(
1091
+ (value) => value !== "" && value !== void 0 && value !== null
1092
+ )) {
1093
+ return false;
1094
+ }
1095
+ return true;
1096
+ };
1097
+ const validateFormFilter = (filter) => {
1098
+ const errors = [];
1099
+ if (!filter.operator) {
1100
+ errors.push("Operator is required");
1101
+ return errors;
1102
+ }
1103
+ if (isEmptyFormFilter(filter)) {
1104
+ errors.push("Value is required");
1105
+ }
1106
+ if (filter.type === "number" && filter.operator === "inRange") {
1107
+ if (filter.values && filter.values.length !== 2) {
1108
+ errors.push("Value is required");
1109
+ }
1110
+ }
1111
+ return errors;
1112
+ };
1113
+ const isFilter = (filter) => {
1114
+ return filter.operator !== void 0 && filter.field !== void 0 && filter.type !== void 0;
1115
+ };
1116
+ const TypeToOperatorOptions = {
1117
+ select: [
1118
+ { label: "is any of", value: "equals" },
1119
+ { label: "is not any of", value: "notEqual" },
1120
+ { label: "has no value", value: "blank" },
1121
+ { label: "has any value", value: "notBlank" }
1122
+ ],
1123
+ number: [
1124
+ { label: "is", value: "equals" },
1125
+ { label: "is not", value: "notEqual" },
1126
+ { label: "is greater than", value: "greaterThan" },
1127
+ { label: "is greater than or equal to", value: "greaterThanOrEqual" },
1128
+ { label: "is less than", value: "lessThan" },
1129
+ { label: "is less than or equal to", value: "lessThanOrEqual" },
1130
+ { label: "has no value", value: "blank" },
1131
+ { label: "has any value", value: "notBlank" },
1132
+ { label: "is between", value: "inRange" }
1133
+ ],
1134
+ text: [
1135
+ { label: "contains", value: "contains" },
1136
+ { label: "does not contain", value: "notContains" },
1137
+ { label: "starts with", value: "startsWith" },
1138
+ { label: "ends with", value: "endsWith" },
1139
+ { label: "has no value", value: "blank" },
1140
+ { label: "has any value", value: "notBlank" }
1141
+ ]
1142
+ };
1143
+ const buildValueInputConfig = (config, operator) => {
1144
+ if (config.type === "select") {
1145
+ if (operator === "blank" || operator === "notBlank") return;
1146
+ return {
1147
+ type: "select",
1148
+ valueOptions: config.options || []
1149
+ };
1150
+ }
1151
+ if (config.type === "number") {
1152
+ if (operator === "blank" || operator === "notBlank") return;
1153
+ return {
1154
+ type: "number",
1155
+ inputCount: operator === "inRange" ? 2 : 1,
1156
+ numberOptions: config.options
1157
+ };
1158
+ }
1159
+ if (config.type === "text") {
1160
+ if (operator === "blank" || operator === "notBlank") return;
1161
+ return {
1162
+ type: "text"
1163
+ };
1164
+ }
1165
+ };
1166
+ const filterFieldReducer = (state, action) => {
1167
+ var _a, _b, _c;
1168
+ switch (action.type) {
1169
+ case "setField": {
1170
+ const config = state.filterConfigs.find(
1171
+ (config2) => config2.field === action.payload
1172
+ );
1173
+ if (!config) return state;
1174
+ const operatorOptions = config ? TypeToOperatorOptions[config.type] : [];
1175
+ const newFilter = {
1176
+ ...state.filter,
1177
+ type: config.type,
1178
+ field: action.payload,
1179
+ operator: operatorOptions[0].value,
1180
+ values: []
1181
+ };
1182
+ const pendingFilter = {
1183
+ ...newFilter,
1184
+ errors: validateFormFilter(newFilter)
1185
+ };
1186
+ return {
1187
+ ...state,
1188
+ filter: pendingFilter,
1189
+ config,
1190
+ operatorOptions,
1191
+ valueInputConfig: operatorOptions.length > 0 ? buildValueInputConfig(config, operatorOptions[0].value) : void 0
1192
+ };
1193
+ }
1194
+ case "setOperator": {
1195
+ if (!state.config) return state;
1196
+ if (!action.payload) return state;
1197
+ const pendingFilter = {
1198
+ ...state.filter,
1199
+ operator: action.payload,
1200
+ values: []
1201
+ };
1202
+ return {
1203
+ ...state,
1204
+ filter: {
1205
+ ...pendingFilter,
1206
+ errors: validateFormFilter(pendingFilter)
1207
+ },
1208
+ valueInputConfig: buildValueInputConfig(state.config, action.payload)
1209
+ };
1210
+ }
1211
+ case "setValues": {
1212
+ if (!state.filter) return state;
1213
+ const values = state.filter.type === "number" ? action.payload.map((value) => Number(value)) : action.payload.filter(
1214
+ (value) => value !== null && value !== void 0
1215
+ );
1216
+ const pendingFilter = {
1217
+ ...state.filter,
1218
+ values
1219
+ };
1220
+ pendingFilter.errors = validateFormFilter(pendingFilter);
1221
+ return {
1222
+ ...state,
1223
+ filter: pendingFilter
1224
+ };
1225
+ }
1226
+ case "initialize": {
1227
+ const field = ((_a = state.filter) == null ? void 0 : _a.field) || ((_b = state.filterConfigs.find((config2) => !config2.disabled)) == null ? void 0 : _b.field);
1228
+ const config = state.filterConfigs.find(
1229
+ (config2) => config2.field === field
1230
+ );
1231
+ if (!config) return state;
1232
+ const operatorOptions = config ? TypeToOperatorOptions[config.type] : [];
1233
+ const operator = ((_c = state.filter) == null ? void 0 : _c.operator) || operatorOptions[0].value;
1234
+ const filter = state.filter ?? {
1235
+ field,
1236
+ type: config.type,
1237
+ operator,
1238
+ values: []
1239
+ };
1240
+ const errors = validateFormFilter(filter);
1241
+ filter.errors = errors;
1242
+ return {
1243
+ ...state,
1244
+ config,
1245
+ filter,
1246
+ operatorOptions,
1247
+ valueInputConfig: operatorOptions.length > 0 ? buildValueInputConfig(config, operator) : void 0
1248
+ };
1249
+ }
1250
+ default:
1251
+ return state;
1252
+ }
1253
+ };
1254
+ const useFilterField = ({
1255
+ filterConfigs,
1256
+ filter: initialFilter
1257
+ }) => {
1258
+ const [{ filter, config, operatorOptions, valueInputConfig }, dispatch] = React.useReducer(
1259
+ filterFieldReducer,
1260
+ {
1261
+ filter: initialFilter,
1262
+ filterConfigs,
1263
+ config: void 0,
1264
+ operatorOptions: [],
1265
+ valueInputConfig: void 0
1266
+ },
1267
+ (state) => {
1268
+ return filterFieldReducer(state, {
1269
+ type: "initialize",
1270
+ payload: void 0
1271
+ });
1272
+ }
1273
+ );
1274
+ const handleFieldChange = (value) => {
1275
+ dispatch({
1276
+ type: "setField",
1277
+ payload: value
1278
+ });
1279
+ };
1280
+ const handleOperatorChange = (value) => {
1281
+ dispatch({
1282
+ type: "setOperator",
1283
+ payload: value
1284
+ });
1285
+ };
1286
+ const handleValuesChange = (value) => {
1287
+ dispatch({
1288
+ type: "setValues",
1289
+ payload: value
1290
+ });
1291
+ };
1292
+ return {
1293
+ filter,
1294
+ config,
1295
+ operatorOptions,
1296
+ valueInputConfig,
1297
+ handleFieldChange,
1298
+ handleOperatorChange,
1299
+ handleValuesChange
1300
+ };
1301
+ };
1302
+ const FilterInput = ({
1303
+ value,
1304
+ filterConfigs,
1305
+ onChange,
1306
+ onBlur,
1307
+ className,
1308
+ size = "middle"
1309
+ }) => {
1310
+ const {
1311
+ filter,
1312
+ operatorOptions,
1313
+ valueInputConfig,
1314
+ handleFieldChange,
1315
+ handleOperatorChange,
1316
+ handleValuesChange
1317
+ } = useFilterField({
1318
+ filterConfigs,
1319
+ filter: value
1320
+ });
1321
+ const fieldOptions = filterConfigs.map((config) => ({
1322
+ label: config.label,
1323
+ value: config.field,
1324
+ disabled: config.disabled
1325
+ }));
1326
+ const handleBlur = () => {
1327
+ if (filter) {
1328
+ onBlur == null ? void 0 : onBlur(filter);
1329
+ }
1330
+ };
1331
+ const isInitialMount = React.useRef(true);
1332
+ const prevFilterRef = React.useRef(filter);
1333
+ React.useEffect(() => {
1334
+ if (isInitialMount.current) {
1335
+ isInitialMount.current = false;
1336
+ prevFilterRef.current = filter;
1337
+ return;
1338
+ }
1339
+ if (filter && filter !== prevFilterRef.current) {
1340
+ prevFilterRef.current = filter;
1341
+ onChange == null ? void 0 : onChange(filter);
1342
+ }
1343
+ }, [filter, onChange]);
1344
+ return /* @__PURE__ */ jsxs("div", { className: cx("grid grid-cols-3 gap-2", className), children: [
1345
+ /* @__PURE__ */ jsx(
1346
+ Select$1,
1347
+ {
1348
+ options: fieldOptions,
1349
+ value: filter == null ? void 0 : filter.field,
1350
+ showSearch: true,
1351
+ optionFilterProp: "label",
1352
+ onChange: handleFieldChange,
1353
+ size
1354
+ }
1355
+ ),
1356
+ /* @__PURE__ */ jsxs("div", { className: "col-span-2 flex gap-2", children: [
1357
+ /* @__PURE__ */ jsx(
1358
+ Select$1,
1359
+ {
1360
+ options: operatorOptions,
1361
+ value: filter == null ? void 0 : filter.operator,
1362
+ onChange: handleOperatorChange,
1363
+ onBlur: handleBlur,
1364
+ size,
1365
+ popupMatchSelectWidth: false
1366
+ }
1367
+ ),
1368
+ valueInputConfig && /* @__PURE__ */ jsx(
1369
+ ValueInput,
1370
+ {
1371
+ valueInputConfig,
1372
+ values: filter == null ? void 0 : filter.values,
1373
+ onChange: handleValuesChange,
1374
+ onBlur: handleBlur,
1375
+ size
1376
+ }
1377
+ )
1378
+ ] })
1379
+ ] });
1380
+ };
1381
+ const ValueInput = ({
1382
+ valueInputConfig,
1383
+ values,
1384
+ onChange,
1385
+ onBlur,
1386
+ size
1387
+ }) => {
1388
+ const handleChange = (value) => {
1389
+ if (value === null) {
1390
+ onChange([]);
1391
+ } else {
1392
+ onChange([value]);
1393
+ }
1394
+ };
1395
+ const handleNumberChange = (value, index2) => {
1396
+ const newValues = [
1397
+ ...values ?? []
1398
+ ];
1399
+ newValues[index2] = value;
1400
+ onChange(newValues);
1401
+ };
1402
+ switch (valueInputConfig.type) {
1403
+ case "select":
1404
+ return /* @__PURE__ */ jsx(
1405
+ Select$1,
1406
+ {
1407
+ options: valueInputConfig.valueOptions,
1408
+ onChange,
1409
+ showSearch: true,
1410
+ allowClear: true,
1411
+ mode: "multiple",
1412
+ onBlur,
1413
+ value: values,
1414
+ className: "w-full truncate",
1415
+ size,
1416
+ optionFilterProp: "label"
1417
+ }
1418
+ );
1419
+ case "number":
1420
+ return /* @__PURE__ */ jsx("div", { className: "flex gap-2 grow", children: Array.from({ length: valueInputConfig.inputCount }).map(
1421
+ (_, index2) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
1422
+ index2 !== 0 && /* @__PURE__ */ jsx("span", { className: "my-auto", children: "and" }),
1423
+ /* @__PURE__ */ jsx(
1424
+ InputNumber$1,
1425
+ {
1426
+ onChange: (value) => handleNumberChange(value, index2),
1427
+ onBlur,
1428
+ value: values == null ? void 0 : values[index2],
1429
+ className: "basis-1/2",
1430
+ size,
1431
+ ...valueInputConfig.numberOptions ?? {}
1432
+ }
1433
+ )
1434
+ ] }, `number-input-${index2}`)
1435
+ ) });
1436
+ case "text":
1437
+ return /* @__PURE__ */ jsx(
1438
+ Input$1,
1439
+ {
1440
+ onBlur,
1441
+ value: (values == null ? void 0 : values[0]) ?? void 0,
1442
+ onChange: (e) => handleChange(e.target.value),
1443
+ className: "w-full",
1444
+ size
1445
+ }
1446
+ );
1447
+ default:
1448
+ return null;
1449
+ }
1450
+ };
1451
+ const copyFilterGroups = (filterGroups) => {
1452
+ return cloneDeep(filterGroups);
1453
+ };
1454
+ const addFilter = (filter, filterGroups) => {
1455
+ const copy = copyFilterGroups(filterGroups);
1456
+ const filterGroupIndex = copy.findIndex(
1457
+ (filterGroup) => filterGroup.field === filter.field
1458
+ );
1459
+ if (filterGroupIndex === -1) {
1460
+ copy.push({ field: filter.field, filters: [filter] });
1461
+ } else {
1462
+ copy[filterGroupIndex].filters.push(filter);
1463
+ }
1464
+ return copy;
1465
+ };
1466
+ const removeFilter = (groupIndex, filterIndex, filterGroups) => {
1467
+ const copy = copyFilterGroups(filterGroups);
1468
+ copy[groupIndex].filters.splice(filterIndex, 1);
1469
+ return copy.filter((group) => group.filters.length > 0);
1470
+ };
1471
+ const filterFormReducer = (state, action) => {
1472
+ var _a;
1473
+ switch (action.type) {
1474
+ case "initialize": {
1475
+ const filterGroups = (_a = action.payload) == null ? void 0 : _a.filters.reduce(
1476
+ (acc, filter) => {
1477
+ return addFilter(filter, acc);
1478
+ },
1479
+ [...state.filterGroups]
1480
+ );
1481
+ return {
1482
+ ...state,
1483
+ filterGroups: filterGroups ?? [],
1484
+ isNewFilterInputOpen: !(filterGroups == null ? void 0 : filterGroups.length)
1485
+ };
1486
+ }
1487
+ case "openNewFilterInput": {
1488
+ return {
1489
+ ...state,
1490
+ isNewFilterInputOpen: true
1491
+ };
1492
+ }
1493
+ case "addNewFilter": {
1494
+ if (action.payload.errors && action.payload.errors.length > 0) {
1495
+ return state;
1496
+ }
1497
+ const filterGroups = addFilter(action.payload, state.filterGroups);
1498
+ return {
1499
+ ...state,
1500
+ filterGroups,
1501
+ newFilter: void 0,
1502
+ isNewFilterInputOpen: false
1503
+ };
1504
+ }
1505
+ case "changeNewFilter": {
1506
+ return {
1507
+ ...state,
1508
+ newFilter: action.payload
1509
+ };
1510
+ }
1511
+ case "removeNewFilter": {
1512
+ const allFiltersRemoved = state.filterGroups.every(
1513
+ (group) => group.filters.length === 0
1514
+ );
1515
+ return {
1516
+ ...state,
1517
+ newFilter: void 0,
1518
+ isNewFilterInputOpen: allFiltersRemoved
1519
+ };
1520
+ }
1521
+ case "updateFilter": {
1522
+ const { groupIndex, filterIndex, filter } = action.payload;
1523
+ let filterGroups = copyFilterGroups(state.filterGroups);
1524
+ const groupField = filterGroups[groupIndex].field;
1525
+ if (groupField === filter.field) {
1526
+ filterGroups[groupIndex].filters[filterIndex] = filter;
1527
+ } else {
1528
+ filterGroups = removeFilter(groupIndex, filterIndex, filterGroups);
1529
+ filterGroups = addFilter(filter, filterGroups);
1530
+ }
1531
+ return {
1532
+ ...state,
1533
+ filterGroups
1534
+ };
1535
+ }
1536
+ case "changeFilter": {
1537
+ const { groupIndex, filterIndex, filter } = action.payload;
1538
+ const filterGroups = copyFilterGroups(state.filterGroups);
1539
+ const group = filterGroups[groupIndex];
1540
+ if (group) {
1541
+ group.filters[filterIndex] = filter;
1542
+ }
1543
+ return {
1544
+ ...state,
1545
+ filterGroups
1546
+ };
1547
+ }
1548
+ case "removeFilter": {
1549
+ const { groupIndex, filterIndex } = action.payload;
1550
+ const filterGroups = removeFilter(
1551
+ groupIndex,
1552
+ filterIndex,
1553
+ state.filterGroups
1554
+ );
1555
+ return {
1556
+ ...state,
1557
+ filterGroups,
1558
+ isNewFilterInputOpen: state.isNewFilterInputOpen || filterGroups.length === 0
1559
+ };
1560
+ }
1561
+ case "clearAllFilters": {
1562
+ return {
1563
+ ...state,
1564
+ filterGroups: [],
1565
+ isNewFilterInputOpen: true
1566
+ };
1567
+ }
1568
+ default:
1569
+ return state;
1570
+ }
1571
+ };
1572
+ const useFiltersForm = ({
1573
+ initialValues
1574
+ }) => {
1575
+ const [{ filterGroups, newFilter, isNewFilterInputOpen }, dispatch] = useReducer(
1576
+ filterFormReducer,
1577
+ {
1578
+ filterGroups: [],
1579
+ newFilter: void 0,
1580
+ isNewFilterInputOpen: true
1581
+ },
1582
+ (state) => {
1583
+ return filterFormReducer(state, {
1584
+ type: "initialize",
1585
+ payload: initialValues
1586
+ });
1587
+ }
1588
+ );
1589
+ const isValid = (filterGroups.length === 0 || filterGroups.every(
1590
+ (group) => group.filters.every(
1591
+ (filter) => filter.errors && filter.errors.length === 0
1592
+ )
1593
+ )) && ((newFilter == null ? void 0 : newFilter.errors) ? newFilter.errors.length === 0 : true);
1594
+ const isEmpty = filterGroups.length === 0 && (newFilter ? isEmptyFormFilter(newFilter) : true);
1595
+ return {
1596
+ dispatch,
1597
+ filterGroups,
1598
+ newFilter,
1599
+ isNewFilterInputOpen,
1600
+ isValid,
1601
+ isEmpty
1602
+ };
1603
+ };
1604
+ const FilterGroup = ({
1605
+ filterGroup,
1606
+ groupIndex,
1607
+ filterConfigs,
1608
+ className,
1609
+ onRemove,
1610
+ onChange,
1611
+ onDone
1612
+ }) => {
1613
+ return /* @__PURE__ */ jsx(
1614
+ "div",
1615
+ {
1616
+ className: cx(
1617
+ "flex flex-col gap-4",
1618
+ {
1619
+ [s$4.filterFormGroupContainer]: filterGroup.filters.length > 1,
1620
+ "p-3": filterGroup.filters.length > 1,
1621
+ "pr-3": filterGroup.filters.length === 1
1622
+ },
1623
+ className
1624
+ ),
1625
+ children: filterGroup.filters.map((filter, filterIndex) => /* @__PURE__ */ jsxs(
1626
+ "div",
1627
+ {
1628
+ className: "flex items-center justify-between",
1629
+ children: [
1630
+ filterIndex >= 1 && /* @__PURE__ */ jsx("span", { className: cx(s$4.filterFormConjunction, "mr-3"), children: "and" }),
1631
+ /* @__PURE__ */ jsx(
1632
+ FilterInput,
1633
+ {
1634
+ value: filter,
1635
+ filterConfigs,
1636
+ className: "flex-1",
1637
+ onChange: (filter2) => onChange(filter2, filterIndex),
1638
+ onBlur: (filter2) => onDone(filter2, filterIndex)
1639
+ },
1640
+ `${groupIndex}:${filterIndex}`
1641
+ ),
1642
+ /* @__PURE__ */ jsx(
1643
+ Button,
1644
+ {
1645
+ type: "text",
1646
+ icon: /* @__PURE__ */ jsx(TrashIcon, {}),
1647
+ onClick: () => onRemove(filterIndex)
1648
+ }
1649
+ )
1650
+ ]
1651
+ },
1652
+ `${groupIndex}:${filterIndex}-input-container`
1653
+ ))
1654
+ },
1655
+ filterGroup.field
1656
+ );
1657
+ };
1658
+ const FiltersForm = ({
1659
+ title,
1660
+ filterConfigs,
1661
+ onSubmit,
1662
+ initialValues,
1663
+ maxFiltersPerField = 5
1664
+ }) => {
1665
+ const { dispatch, filterGroups, isNewFilterInputOpen, isValid, isEmpty } = useFiltersForm({
1666
+ initialValues
1667
+ });
1668
+ const handleSubmit = () => {
1669
+ onSubmit({
1670
+ filters: filterGroups.flatMap((group) => group.filters).filter((filter) => isFilter(filter)).filter((filter) => !isEmptyFilter(filter))
1671
+ });
1672
+ };
1673
+ const availableFilterConfigs = useMemo(() => {
1674
+ const filterFieldCounts = filterGroups.reduce(
1675
+ (acc, filterGroup) => {
1676
+ acc[filterGroup.field] = filterGroup.filters.length;
1677
+ return acc;
1678
+ },
1679
+ {}
1680
+ );
1681
+ return filterConfigs.map((config) => ({
1682
+ ...config,
1683
+ disabled: (filterFieldCounts[config.field] || 0) >= maxFiltersPerField
1684
+ }));
1685
+ }, [
1686
+ filterConfigs,
1687
+ filterGroups.map((g) => `${g.field}-${g.filters.length}`).join(","),
1688
+ maxFiltersPerField
1689
+ ]);
1690
+ return /* @__PURE__ */ jsxs("div", { className: cx(s$4.j2FilterForm), children: [
1691
+ /* @__PURE__ */ jsxs(
1692
+ "div",
1693
+ {
1694
+ className: cx(
1695
+ s$4.filterFormFieldsContainer,
1696
+ "flex flex-col gap-4",
1697
+ "p-4 mb-6"
1698
+ ),
1699
+ children: [
1700
+ title && /* @__PURE__ */ jsx("span", { className: s$4.filterFormTitle, children: title }),
1701
+ filterGroups.map((filterGroup, groupIndex) => /* @__PURE__ */ jsxs(
1702
+ "div",
1703
+ {
1704
+ className: cx("flex gap-3", {
1705
+ "items-center": filterGroup.filters.length === 1
1706
+ }),
1707
+ children: [
1708
+ groupIndex > 0 ? /* @__PURE__ */ jsx(
1709
+ "span",
1710
+ {
1711
+ className: cx(s$4.filterFormConjunction, {
1712
+ "pt-4": filterGroup.filters.length > 1
1713
+ }),
1714
+ children: "and"
1715
+ }
1716
+ ) : null,
1717
+ /* @__PURE__ */ jsx(
1718
+ FilterGroup,
1719
+ {
1720
+ filterGroup,
1721
+ groupIndex,
1722
+ filterConfigs: availableFilterConfigs,
1723
+ className: "grow",
1724
+ onChange: (filter, filterIndex) => {
1725
+ dispatch({
1726
+ type: "changeFilter",
1727
+ payload: { groupIndex, filterIndex, filter }
1728
+ });
1729
+ },
1730
+ onDone: (filter, filterIndex) => {
1731
+ dispatch({
1732
+ type: "updateFilter",
1733
+ payload: { groupIndex, filterIndex, filter }
1734
+ });
1735
+ },
1736
+ onRemove: (filterIndex) => {
1737
+ dispatch({
1738
+ type: "removeFilter",
1739
+ payload: { groupIndex, filterIndex }
1740
+ });
1741
+ }
1742
+ }
1743
+ )
1744
+ ]
1745
+ },
1746
+ `filter-group-${filterGroup.field}-${filterGroup.filters.length}`
1747
+ )),
1748
+ isNewFilterInputOpen && /* @__PURE__ */ jsxs("div", { className: cx("flex gap-3 items-center"), children: [
1749
+ filterGroups.length > 0 ? /* @__PURE__ */ jsx("span", { className: cx(s$4.filterFormConjunction), children: "and" }) : null,
1750
+ /* @__PURE__ */ jsxs("div", { className: cx("flex items-center justify-between", "grow"), children: [
1751
+ /* @__PURE__ */ jsx(
1752
+ FilterInput,
1753
+ {
1754
+ filterConfigs: availableFilterConfigs,
1755
+ className: "flex-1",
1756
+ onChange: (filter) => {
1757
+ dispatch({ type: "changeNewFilter", payload: filter });
1758
+ },
1759
+ onBlur: (filter) => {
1760
+ dispatch({ type: "addNewFilter", payload: filter });
1761
+ }
1762
+ },
1763
+ JSON.stringify(filterGroups)
1764
+ ),
1765
+ /* @__PURE__ */ jsx("div", { className: "mr-3", children: filterGroups.length > 0 ? /* @__PURE__ */ jsx(
1766
+ Button,
1767
+ {
1768
+ type: "text",
1769
+ icon: /* @__PURE__ */ jsx(TrashIcon, {}),
1770
+ onClick: () => dispatch({ type: "removeNewFilter" })
1771
+ }
1772
+ ) : /* @__PURE__ */ jsx("div", { className: "w-8" }) })
1773
+ ] })
1774
+ ] }),
1775
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
1776
+ /* @__PURE__ */ jsx(
1777
+ Button,
1778
+ {
1779
+ icon: /* @__PURE__ */ jsx(PlusCircleIcon, {}),
1780
+ onClick: () => dispatch({ type: "openNewFilterInput" }),
1781
+ disabled: !isValid,
1782
+ children: "Add Rule"
1783
+ }
1784
+ ),
1785
+ /* @__PURE__ */ jsx(
1786
+ Button,
1787
+ {
1788
+ type: "text",
1789
+ onClick: () => {
1790
+ dispatch({
1791
+ type: "clearAllFilters"
1792
+ });
1793
+ },
1794
+ children: "Clear All Rules"
1795
+ }
1796
+ )
1797
+ ] })
1798
+ ]
1799
+ }
1800
+ ),
1801
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
1802
+ Button,
1803
+ {
1804
+ onClick: handleSubmit,
1805
+ type: "primary",
1806
+ disabled: isEmpty ? false : !isValid,
1807
+ children: "Apply Filters"
1808
+ }
1809
+ ) })
1810
+ ] });
1811
+ };
1812
+ const Form = ({ children, ...props }) => {
1813
+ return /* @__PURE__ */ jsx(Form$1, { ...props, children });
1814
+ };
1815
+ Form.Item = FormItem;
1816
+ const Input = ({ size = "large", ...props }) => {
1817
+ return /* @__PURE__ */ jsx(Input$2, { size, ...props });
1818
+ };
1819
+ const AntdInput = forwardRef(
1820
+ ({ size = "large", ...props }, ref) => {
1821
+ return /* @__PURE__ */ jsx(Input$1, { ref, size, ...props });
1822
+ }
1823
+ );
1824
+ AntdInput.displayName = "AntdInput";
1825
+ const AntdSearchInput = forwardRef(
1826
+ ({ size = "large", ...props }, ref) => {
1827
+ return /* @__PURE__ */ jsx(Input$1.Search, { ref, size, ...props });
1828
+ }
1829
+ );
1830
+ AntdSearchInput.displayName = "AntdSearchInput";
1831
+ const j2InputNumber = "_j2InputNumber_1jmfn_1";
1832
+ const styles$8 = {
1833
+ j2InputNumber
1834
+ };
1835
+ const InputNumber = ({
1836
+ size = "large",
1837
+ step = 1,
1838
+ name,
1839
+ max,
1840
+ min,
1841
+ ...props
1842
+ }) => {
1843
+ return /* @__PURE__ */ jsx(
1844
+ InputNumber$2,
1845
+ {
1846
+ name,
1847
+ max,
1848
+ min,
1849
+ step,
1850
+ className: cx(styles$8.j2InputNumber, props.className),
1851
+ upHandler: /* @__PURE__ */ jsx(CaretUpIcon, { weight: "bold", size: 12 }),
1852
+ downHandler: /* @__PURE__ */ jsx(CaretDownIcon, { weight: "bold", size: 12 }),
1853
+ size,
1854
+ ...props
1855
+ }
1856
+ );
1857
+ };
1858
+ const j2Popover = "_j2Popover_1egkj_1";
1859
+ const smallPadding = "_smallPadding_1egkj_6";
1860
+ const smPadding = "_smPadding_1egkj_7";
1861
+ const xxsPadding = "_xxsPadding_1egkj_11";
1862
+ const xsPadding = "_xsPadding_1egkj_15";
1863
+ const mdPadding = "_mdPadding_1egkj_19";
1864
+ const xlPadding = "_xlPadding_1egkj_23";
1865
+ const popoverHeader = "_popoverHeader_1egkj_34";
1866
+ const scrollable = "_scrollable_1egkj_40";
1867
+ const styles$7 = {
1868
+ j2Popover,
1869
+ smallPadding,
1870
+ smPadding,
1871
+ xxsPadding,
1872
+ xsPadding,
1873
+ mdPadding,
1874
+ xlPadding,
1875
+ popoverHeader,
1876
+ scrollable
1877
+ };
1878
+ const Popover = ({
1879
+ children,
1880
+ placement = "top",
1881
+ scrollable: scrollable2 = false,
1882
+ contentPadding = true,
1883
+ content,
1884
+ smallPadding: smallPadding2 = false,
1885
+ paddingSize,
1886
+ arrow = false,
1887
+ ...props
1888
+ }) => {
1889
+ return /* @__PURE__ */ jsx(
1890
+ Popover$1,
1891
+ {
1892
+ overlayClassName: cx(
1893
+ styles$7.j2Popover,
1894
+ scrollable2 && styles$7.scrollable,
1895
+ smallPadding2 && styles$7.smallPadding,
1896
+ paddingSize && styles$7[`${paddingSize}Padding`]
1897
+ ),
1898
+ ...props,
1899
+ placement,
1900
+ arrow,
1901
+ content: () => {
1902
+ if (!contentPadding) {
1903
+ return /* @__PURE__ */ jsx("div", { children: typeof content == "function" ? content() : content });
1904
+ }
1905
+ return typeof content == "function" ? content() : content;
1906
+ },
1907
+ children: /* @__PURE__ */ jsx("div", { children })
1908
+ }
1909
+ );
1910
+ };
1911
+ const Tooltip = ({
1912
+ children,
1913
+ placement = "top",
1914
+ arrow = false,
1915
+ ...props
1916
+ }) => {
1917
+ return /* @__PURE__ */ jsx(Tooltip$1, { ...props, placement, arrow, children: /* @__PURE__ */ jsx("div", { children }) });
1918
+ };
1919
+ const categoryName = "_categoryName_jejns_1";
1920
+ const s$3 = {
1921
+ categoryName
1922
+ };
1923
+ const CopyButton = ({
1924
+ openMessage,
1925
+ textToCopy
1926
+ }) => /* @__PURE__ */ jsx(Tooltip, { title: "Copy to Clipboard", className: "ml-2", arrow: false, children: /* @__PURE__ */ jsx(
1927
+ Button,
1928
+ {
1929
+ type: "text",
1930
+ icon: /* @__PURE__ */ jsx(
1931
+ CopyIcon,
1932
+ {
1933
+ onClick: () => {
1934
+ navigator.clipboard.writeText(textToCopy);
1935
+ openMessage("success", "Copied to Clipboard");
1936
+ }
1937
+ }
1938
+ )
1939
+ }
1940
+ ) });
1941
+ const StringListItem = ({
1942
+ item,
1943
+ openMessage,
1944
+ renderItem
1945
+ }) => {
1946
+ return /* @__PURE__ */ jsxs("div", { className: cx("flex items-center"), children: [
1947
+ /* @__PURE__ */ jsx("div", { className: cx("overflow-hidden text-nowrap text-ellipsis"), children: renderItem ? renderItem(item) : item }),
1948
+ /* @__PURE__ */ jsx(CopyButton, { openMessage, textToCopy: item })
1949
+ ] }, item);
1950
+ };
1951
+ const ObjectListItem = ({
1952
+ item,
1953
+ openMessage,
1954
+ index: index2,
1955
+ renderItem
1956
+ }) => {
1957
+ return /* @__PURE__ */ jsxs("div", { className: cx({ "mt-2": index2 != 0 }), children: [
1958
+ /* @__PURE__ */ jsx(
1959
+ "p",
1960
+ {
1961
+ className: cx(
1962
+ "overflow-hidden text-nowrap text-ellipsis",
1963
+ s$3.categoryName
1964
+ ),
1965
+ title: item.categoryName,
1966
+ children: item.categoryName
1967
+ }
1968
+ ),
1969
+ item.items.map((subItem, index22) => /* @__PURE__ */ jsxs("div", { className: cx("flex items-center"), children: [
1970
+ /* @__PURE__ */ jsx("div", { className: cx("overflow-hidden text-nowrap text-ellipsis"), children: renderItem ? renderItem(subItem) : subItem }),
1971
+ /* @__PURE__ */ jsx(CopyButton, { openMessage, textToCopy: subItem })
1972
+ ] }, `${subItem}:${index22}`))
1973
+ ] });
1974
+ };
1975
+ const PopoverContent = ({
1976
+ items,
1977
+ openMessage,
1978
+ renderItem
1979
+ }) => {
1980
+ return /* @__PURE__ */ jsx("div", { className: cx("max-w-[400px] max-h-[198px]"), children: items.map(
1981
+ (item, i) => typeof item === "string" ? /* @__PURE__ */ jsx(
1982
+ StringListItem,
1983
+ {
1984
+ item,
1985
+ openMessage,
1986
+ renderItem
1987
+ },
1988
+ item
1989
+ ) : /* @__PURE__ */ jsx(
1990
+ ObjectListItem,
1991
+ {
1992
+ index: i,
1993
+ item,
1994
+ openMessage,
1995
+ renderItem
1996
+ },
1997
+ item.categoryName
1998
+ )
1999
+ ) });
2000
+ };
2001
+ const ListPopover = ({
2002
+ children,
2003
+ items,
2004
+ column,
2005
+ openMessage,
2006
+ renderItem
2007
+ }) => {
2008
+ return /* @__PURE__ */ jsx(
2009
+ Popover,
2010
+ {
2011
+ title: `${column} (${items.length})`,
2012
+ content: /* @__PURE__ */ jsx(
2013
+ PopoverContent,
2014
+ {
2015
+ items,
2016
+ openMessage,
2017
+ renderItem
2018
+ }
2019
+ ),
2020
+ trigger: "click",
2021
+ scrollable: true,
2022
+ arrow: false,
2023
+ contentPadding: false,
2024
+ children: /* @__PURE__ */ jsx("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ jsx(
2025
+ Button,
2026
+ {
2027
+ className: cx(
2028
+ "p-0 h-auto w-full overflow-hidden text-left justify-start"
2029
+ ),
2030
+ type: items.length > 0 ? "link" : "text",
2031
+ children
2032
+ }
2033
+ ) })
2034
+ }
2035
+ );
2036
+ };
2037
+ const j2Menu = "_j2Menu_11mko_1";
2038
+ const compact = "_compact_11mko_15";
2039
+ const styles$6 = {
2040
+ j2Menu,
2041
+ compact
2042
+ };
2043
+ const Menu = ({ compact: compact2 = false, ...props }) => {
2044
+ return /* @__PURE__ */ jsx(
2045
+ Menu$1,
2046
+ {
2047
+ className: cx(styles$6.j2Menu, compact2 && styles$6.compact),
2048
+ ...props,
2049
+ inlineCollapsed: compact2
2050
+ }
2051
+ );
2052
+ };
2053
+ const messageIcon = "_messageIcon_1k9xp_1";
2054
+ const styles$5 = {
2055
+ messageIcon
2056
+ };
2057
+ const getIcon$1 = (type) => {
2058
+ switch (type) {
2059
+ case "success":
2060
+ return /* @__PURE__ */ jsx(
2061
+ CheckCircleIcon,
2062
+ {
2063
+ weight: "fill",
2064
+ color: "var(--j2-color-success)",
2065
+ size: 16,
2066
+ className: cx(styles$5.messageIcon)
2067
+ }
2068
+ );
2069
+ case "warning":
2070
+ return /* @__PURE__ */ jsx(
2071
+ WarningCircleIcon,
2072
+ {
2073
+ weight: "fill",
2074
+ color: "var(--j2-color-warning)",
2075
+ size: 16,
2076
+ className: cx(styles$5.messageIcon)
2077
+ }
2078
+ );
2079
+ case "error":
2080
+ return /* @__PURE__ */ jsx(
2081
+ XCircleIcon,
2082
+ {
2083
+ weight: "fill",
2084
+ color: "var(--j2-color-error)",
2085
+ size: 16,
2086
+ className: cx(styles$5.messageIcon)
2087
+ }
2088
+ );
2089
+ }
2090
+ };
2091
+ const useMessage = () => {
2092
+ const [messageApi, contextHolder] = message.useMessage();
2093
+ const openMessage = (type, messageContent) => {
2094
+ messageApi.open({
2095
+ type,
2096
+ icon: getIcon$1(type),
2097
+ content: messageContent,
2098
+ className: cx({ styles: styles$5 })
2099
+ });
2100
+ };
2101
+ return { openMessage, contextHolder };
2102
+ };
2103
+ const Modal = ({
2104
+ open,
2105
+ title,
2106
+ children,
2107
+ onCancel,
2108
+ withContentPadding: withPadding = true,
2109
+ ...props
2110
+ }) => {
2111
+ return /* @__PURE__ */ jsx(
2112
+ Modal$1,
2113
+ {
2114
+ title,
2115
+ className: cx("j2-modal"),
2116
+ maskClosable: true,
2117
+ centered: true,
2118
+ closeIcon: /* @__PURE__ */ jsx(XIcon, { size: 22, weight: "regular" }),
2119
+ onCancel,
2120
+ open,
2121
+ ...props,
2122
+ children: /* @__PURE__ */ jsx("div", { className: cx(withPadding ? "px-6 py-3" : "px-0 py-0"), children })
2123
+ }
2124
+ );
2125
+ };
2126
+ const SvgJ2LogoMenuCollapse = (props) => /* @__PURE__ */ React.createElement("svg", { width: 32, height: 32, viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M30.3968 25.6H27.392C26.9664 25.6 26.56 25.7696 26.2592 26.0672L26.064 26.2624C25.7632 26.5632 25.5968 26.9696 25.5968 27.3952V30.4C25.5968 31.2832 24.88 32 23.9968 32H20.7968C19.9136 32 19.1968 31.2832 19.1968 30.4V27.3952C19.1968 26.9696 19.0272 26.5632 18.7296 26.2624L18.5344 26.0672C18.2336 25.7664 17.8272 25.6 17.4016 25.6H14.3968C13.5136 25.6 12.7968 24.8832 12.7968 24V20.8C12.7968 19.9168 13.5136 19.2 14.3968 19.2H17.5968C18.48 19.2 19.1968 19.9168 19.1968 20.8V23.8048C19.1968 24.2304 19.3664 24.6368 19.664 24.9376L19.8592 25.1328C20.16 25.4336 20.5664 25.6 20.992 25.6H23.8048C24.2304 25.6 24.6368 25.4304 24.9376 25.1328L25.1328 24.9376C25.4336 24.6368 25.6 24.2304 25.6 23.8048V8.00002C25.6 7.11682 26.3168 6.40002 27.2 6.40002H30.4C31.2832 6.40002 32 7.11682 32 8.00002V24C32 24.8832 31.2832 25.6 30.4 25.6H30.3968Z", fill: "#253761" }), /* @__PURE__ */ React.createElement("path", { d: "M8.192 6.39999H11.0048C11.4304 6.39999 11.8368 6.56959 12.1376 6.86719L12.3328 7.06239C12.6336 7.36319 12.8 7.76959 12.8 8.19519V11.2C12.8 12.0832 13.5168 12.8 14.4 12.8H17.6C18.4832 12.8 19.2 12.0832 19.2 11.2V7.99999C19.2 7.11679 18.4832 6.39999 17.6 6.39999H14.5952C14.1696 6.39999 13.7632 6.23039 13.4624 5.93279L13.2672 5.73759C12.9664 5.43679 12.8 5.03039 12.8 4.60479V1.6C12.8 0.716799 12.0832 0 11.2 0H8C7.1168 0 6.4 0.716799 6.4 1.6V4.60479C6.4 5.03039 6.2304 5.43679 5.9328 5.73759L5.7376 5.93279C5.4368 6.23359 5.0304 6.39999 4.6048 6.39999H1.6C0.7168 6.39999 0 7.11679 0 7.99999V24C0 24.8832 0.7168 25.6 1.6 25.6H4.8C5.6832 25.6 6.4 24.8832 6.4 24V8.19519C6.4 7.76959 6.5696 7.36319 6.8672 7.06239L7.0624 6.86719C7.3632 6.56639 7.7696 6.39999 8.1952 6.39999H8.192Z", fill: "#253761" }));
2127
+ const SvgJ2LogoMenu = (props) => /* @__PURE__ */ React.createElement("svg", { width: 152, height: 32, viewBox: "0 0 152 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M44.9576 22.7691C46.6563 22.7691 47.6449 21.8637 47.6449 19.5891V6.39841H50.8536V20.4113C50.8536 23.8121 48.7966 25.8149 45.8629 25.8149C45.4502 25.8149 44.8488 25.8149 44.3561 25.7061V22.7723H44.9608L44.9576 22.7691Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M53.3582 23.2619L60.0476 16.6522C62.0215 14.7038 62.9812 13.5809 62.9812 12.074C62.9812 10.4296 61.6376 9.24902 59.8557 9.24902C57.6898 9.24902 56.3462 10.7303 56.4294 13.0882H53.195C53.0575 8.8939 55.9367 6.12332 59.9132 6.12332C63.5891 6.12332 66.2763 8.56438 66.2763 11.9908C66.2763 14.3775 64.7152 16.4346 62.3286 18.6805L58.544 22.4653H66.4139V25.591H53.3614V23.2587L53.3582 23.2619Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M89.7255 6.39844V25.5941H86.5168V17.1768H77.2201V25.5941H74.0114V6.39844H77.2201V14.1055H86.5168V6.39844H89.7255Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M91.5684 18.847C91.5684 14.9247 94.614 11.9078 98.4786 11.9078C102.097 11.9078 105.005 14.7327 105.005 18.4631C105.005 18.7382 104.976 19.3141 104.95 19.6149H94.4476C94.7228 21.8096 96.284 23.262 98.5074 23.262C100.235 23.262 101.55 22.4398 101.825 21.1793H104.842C104.375 24.0299 101.796 25.8695 98.5362 25.8695C94.614 25.8695 91.5716 22.8237 91.5716 18.8502L91.5684 18.847ZM101.77 17.3945C101.607 15.7213 100.181 14.4864 98.3442 14.4864C96.5079 14.4864 95.1099 15.5294 94.614 17.3945H101.77Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M120.773 25.5944H117.702V23.1821C116.743 24.8809 115.098 25.8695 112.932 25.8695C109.34 25.8695 106.515 22.7438 106.515 18.8759C106.515 15.0079 109.34 11.911 112.932 11.911C115.098 11.911 116.743 12.8996 117.702 14.5984V12.1862H120.773V25.5944ZM113.591 22.9614C115.924 22.9614 117.677 21.2082 117.677 18.8759C117.677 16.5436 115.92 14.816 113.591 14.816C111.262 14.816 109.532 16.6268 109.532 18.8759C109.532 21.125 111.314 22.9614 113.591 22.9614Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M126.708 25.5942H123.666V6.39847H126.708V25.5942Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M130.688 20.549V15.091H128.138V12.1828H130.688V8.59003H133.759V12.1828H137.268V15.091H133.759V20.4946C133.759 22.1934 134.802 22.8812 136.283 22.8812C136.612 22.8812 136.968 22.8524 137.271 22.7725V25.5974C136.804 25.7062 136.12 25.7606 135.627 25.7606C132.665 25.7606 130.691 23.9498 130.691 20.549H130.688Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M142.403 6.39847V14.2975C143.254 12.7906 144.652 11.9108 146.434 11.9108C149.889 11.9108 152 14.2143 152 17.9447V25.5942H148.954V18.3286C148.954 16.2171 147.665 14.8446 145.691 14.8446C143.717 14.8446 142.399 16.2171 142.399 18.3286V25.5942H139.357V6.39847H142.399H142.403Z", fill: "#383842" }), /* @__PURE__ */ React.createElement("path", { d: "M30.3971 25.6H27.3926C26.967 25.6 26.5607 25.7696 26.2599 26.0672L26.0647 26.2624C25.7639 26.5632 25.5976 26.9696 25.5976 27.3952V30.4C25.5976 31.2832 24.8808 32 23.9977 32H20.798C19.9149 32 19.1982 31.2832 19.1982 30.4V27.3952C19.1982 26.9696 19.0286 26.5632 18.731 26.2624L18.5359 26.0672C18.2351 25.7664 17.8287 25.6 17.4032 25.6H14.3987C13.5156 25.6 12.7988 24.8832 12.7988 24V20.8C12.7988 19.9168 13.5156 19.2 14.3987 19.2H17.5984C18.4815 19.2 19.1982 19.9168 19.1982 20.8V23.8048C19.1982 24.2304 19.3678 24.6368 19.6654 24.9376L19.8605 25.1328C20.1613 25.4336 20.5677 25.6 20.9932 25.6H23.8057C24.2313 25.6 24.6377 25.4304 24.9384 25.1328L25.1336 24.9376C25.4344 24.6368 25.6008 24.2304 25.6008 23.8048V8C25.6008 7.1168 26.3175 6.4 27.2006 6.4H30.4003C31.2834 6.4 32.0001 7.1168 32.0001 8V24C32.0001 24.8832 31.2834 25.6 30.4003 25.6H30.3971ZM8.1945 6.4H11.007C11.4326 6.4 11.8389 6.5696 12.1397 6.8672L12.3349 7.0624C12.6357 7.3632 12.802 7.7696 12.802 8.1952V11.2C12.802 12.0832 13.5188 12.8 14.4019 12.8H17.6016C18.4847 12.8 19.2014 12.0832 19.2014 11.2V8C19.2014 7.1168 18.4847 6.4 17.6016 6.4H14.5971C14.1715 6.4 13.7651 6.2304 13.4644 5.9328L13.2692 5.7376C12.9684 5.4368 12.802 5.0304 12.802 4.6048V1.6C12.802 0.7168 12.0853 0 11.2022 0H8.00252C7.11941 0 6.40268 0.7168 6.40268 1.6V4.6048C6.40268 5.0304 6.2331 5.4368 5.93553 5.7376L5.74035 5.9328C5.43958 6.2336 5.03322 6.4 4.60766 6.4H1.59996C0.71685 6.4 0.00012207 7.1168 0.00012207 8V24C0.00012207 24.8832 0.71685 25.6 1.59996 25.6H4.79964C5.68275 25.6 6.39948 24.8832 6.39948 24V8.1952C6.39948 7.7696 6.56906 7.3632 6.86663 7.0624L7.06182 6.8672C7.36259 6.5664 7.76894 6.4 8.1945 6.4Z", fill: "#253761" }));
2128
+ const SvgMenuSidebarExpand = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { opacity: 0.2, d: "M3.75049 19.5C3.55158 19.5 3.36081 19.421 3.22016 19.2803C3.07951 19.1397 3.00049 18.9489 3.00049 18.75V5.25C3.00049 5.05109 3.07951 4.86032 3.22016 4.71967C3.36081 4.57902 3.55158 4.5 3.75049 4.5H8.25049V19.5H3.75049Z", fill: "#364975" }), /* @__PURE__ */ React.createElement("path", { d: "M8.25049 4.5V19.5", stroke: "#364975", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M20.2505 4.5H3.75049C3.33627 4.5 3.00049 4.83579 3.00049 5.25V18.75C3.00049 19.1642 3.33627 19.5 3.75049 19.5H20.2505C20.6647 19.5 21.0005 19.1642 21.0005 18.75V5.25C21.0005 4.83579 20.6647 4.5 20.2505 4.5Z", stroke: "#364975", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M3.00049 7.5H5.25049", stroke: "#364975", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M3.00049 10.5H5.25049", stroke: "#364975", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M3.00049 13.5H5.25049", stroke: "#364975", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { opacity: 0.2, d: "M15.0002 14.7002L17.7002 12.0002L15.0002 9.3002V14.7002Z", fill: "#364975" }), /* @__PURE__ */ React.createElement("path", { d: "M11.1 12.0002H15", stroke: "#364975", strokeWidth: 0.6, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M15.0002 14.7002L17.7002 12.0002L15.0002 9.3002V14.7002Z", stroke: "#364975", strokeWidth: 0.6, strokeLinecap: "round", strokeLinejoin: "round" }));
2129
+ const SvgMenuSidebarCollapse = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { opacity: 0.2, d: "M3.75049 19.5C3.55158 19.5 3.36081 19.421 3.22016 19.2803C3.07951 19.1397 3.00049 18.9489 3.00049 18.75V5.25C3.00049 5.05109 3.07951 4.86032 3.22016 4.71967C3.36081 4.57902 3.55158 4.5 3.75049 4.5H8.25049V19.5H3.75049Z", fill: "#253761" }), /* @__PURE__ */ React.createElement("path", { d: "M8.25049 4.5V19.5", stroke: "#253761", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M20.2505 4.5H3.75049C3.33627 4.5 3.00049 4.83579 3.00049 5.25V18.75C3.00049 19.1642 3.33627 19.5 3.75049 19.5H20.2505C20.6647 19.5 21.0005 19.1642 21.0005 18.75V5.25C21.0005 4.83579 20.6647 4.5 20.2505 4.5Z", stroke: "#253761", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M3.00049 7.5H5.25049", stroke: "#253761", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M3.00049 10.5H5.25049", stroke: "#253761", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M3.00049 13.5H5.25049", stroke: "#253761", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { opacity: 0.2, d: "M13.8001 9.30029L11.1001 12.0003L13.8001 14.7003V9.30029Z", fill: "#253761" }), /* @__PURE__ */ React.createElement("path", { d: "M17.7005 12.0002H13.8005", stroke: "#253761", strokeWidth: 0.6, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M13.8001 9.30029L11.1001 12.0003L13.8001 14.7003V9.30029Z", stroke: "#253761", strokeWidth: 0.6, strokeLinecap: "round", strokeLinejoin: "round" }));
2130
+ const navMenuContainer = "_navMenuContainer_1ul3o_1";
2131
+ const collapsed = "_collapsed_1ul3o_5";
2132
+ const headerContainer = "_headerContainer_1ul3o_8";
2133
+ const logo$1 = "_logo_1ul3o_9";
2134
+ const styles$4 = {
2135
+ navMenuContainer,
2136
+ collapsed,
2137
+ headerContainer,
2138
+ logo: logo$1
2139
+ };
2140
+ const NavMenu = ({
2141
+ href = "/",
2142
+ items,
2143
+ headerSlot,
2144
+ defaultOpenKeys,
2145
+ defaultSelectedKeys,
2146
+ footerItems,
2147
+ className,
2148
+ onCollapse
2149
+ }) => {
2150
+ const [isCollapsed, setIsCollapsed] = React.useState(false);
2151
+ const [isToggleTooltipOpen, setToggleTooltipOpen] = React.useState(false);
2152
+ const toggleCollapse = React.useCallback(() => {
2153
+ setIsCollapsed(!isCollapsed);
2154
+ setToggleTooltipOpen(false);
2155
+ onCollapse == null ? void 0 : onCollapse(!isCollapsed);
2156
+ }, [isCollapsed]);
2157
+ return /* @__PURE__ */ jsx(
2158
+ "div",
2159
+ {
2160
+ className: cx(
2161
+ styles$4.navMenuContainer,
2162
+ isCollapsed && styles$4.collapsed,
2163
+ "bg-white",
2164
+ className
2165
+ ),
2166
+ children: /* @__PURE__ */ jsxs("div", { className: cx("flex", "flex-col", "h-full"), children: [
2167
+ /* @__PURE__ */ jsxs("div", { className: "py-5 px-3", children: [
2168
+ /* @__PURE__ */ jsxs(
2169
+ "div",
2170
+ {
2171
+ className: cx(
2172
+ "flex",
2173
+ "items-center",
2174
+ isCollapsed ? "justify-center" : "justify-between",
2175
+ styles$4.headerContainer,
2176
+ "min-h-9"
2177
+ ),
2178
+ children: [
2179
+ /* @__PURE__ */ jsx(
2180
+ "a",
2181
+ {
2182
+ href,
2183
+ className: cx("flex", "items-center", "gap-2", styles$4.logo),
2184
+ children: isCollapsed ? /* @__PURE__ */ jsx(SvgJ2LogoMenuCollapse, {}) : /* @__PURE__ */ jsx(SvgJ2LogoMenu, {})
2185
+ }
2186
+ ),
2187
+ /* @__PURE__ */ jsx(
2188
+ Tooltip,
2189
+ {
2190
+ title: isCollapsed ? "Expand Menu" : "Collapse Menu",
2191
+ placement: "right",
2192
+ arrow: false,
2193
+ onOpenChange: (shouldBeOpen) => {
2194
+ setToggleTooltipOpen(shouldBeOpen);
2195
+ },
2196
+ open: isToggleTooltipOpen,
2197
+ children: /* @__PURE__ */ jsx(
2198
+ Button,
2199
+ {
2200
+ type: "text",
2201
+ icon: isCollapsed ? /* @__PURE__ */ jsx(SvgMenuSidebarExpand, {}) : /* @__PURE__ */ jsx(SvgMenuSidebarCollapse, {}),
2202
+ onClick: toggleCollapse,
2203
+ className: cx("toggle-button")
2204
+ }
2205
+ )
2206
+ }
2207
+ )
2208
+ ]
2209
+ }
2210
+ ),
2211
+ headerSlot && /* @__PURE__ */ jsx("div", { className: cx("mt-5"), children: headerSlot })
2212
+ ] }),
2213
+ /* @__PURE__ */ jsxs("div", { className: cx("flex", "flex-col", "justify-between", "flex-1"), children: [
2214
+ /* @__PURE__ */ jsx(
2215
+ Menu,
2216
+ {
2217
+ mode: "inline",
2218
+ compact: isCollapsed,
2219
+ items,
2220
+ defaultOpenKeys: isCollapsed ? void 0 : defaultOpenKeys,
2221
+ defaultSelectedKeys
2222
+ },
2223
+ `nav-menu-main-${isCollapsed}`
2224
+ ),
2225
+ /* @__PURE__ */ jsx(
2226
+ Menu,
2227
+ {
2228
+ mode: "inline",
2229
+ compact: isCollapsed,
2230
+ selectable: false,
2231
+ items: footerItems
2232
+ },
2233
+ `nav-menu-footer-${isCollapsed}`
2234
+ )
2235
+ ] })
2236
+ ] })
2237
+ }
2238
+ );
2239
+ };
2240
+ const messageOnly = "_messageOnly_1pxqk_14";
2241
+ const s$2 = {
2242
+ messageOnly
2243
+ };
2244
+ const getIcon = (type) => {
2245
+ switch (type) {
2246
+ case "error":
2247
+ return /* @__PURE__ */ jsx(XCircleIcon, { color: "var(--j2-color-error)", weight: "duotone", size: 24 });
2248
+ case "success":
2249
+ return /* @__PURE__ */ jsx(
2250
+ CheckCircleIcon,
2251
+ {
2252
+ color: "var(--j2-color-success)",
2253
+ weight: "duotone",
2254
+ size: 24
2255
+ }
2256
+ );
2257
+ case "info":
2258
+ return /* @__PURE__ */ jsx(InfoIcon, { color: "var(--j2-color-info)", weight: "duotone", size: 24 });
2259
+ case "warning":
2260
+ return /* @__PURE__ */ jsx(
2261
+ WarningCircleIcon,
2262
+ {
2263
+ color: "var(--j2-color-warning)",
2264
+ weight: "duotone",
2265
+ size: 24
2266
+ }
2267
+ );
2268
+ }
2269
+ };
2270
+ const useNotification = () => {
2271
+ const [api, contextHolder] = notification.useNotification();
2272
+ const openNotification = (type, config) => {
2273
+ api[type]({
2274
+ icon: getIcon(type),
2275
+ ...config,
2276
+ closeIcon: /* @__PURE__ */ jsx(XIcon, { color: "var(--j2-color-icon)", size: 22, weight: "regular" }),
2277
+ className: cx({
2278
+ [s$2.messageOnly]: config.message && !config.description
2279
+ })
2280
+ });
2281
+ };
2282
+ const closeNotification = (key) => {
2283
+ api.destroy(key);
2284
+ };
2285
+ return { openNotification, closeNotification, contextHolder };
2286
+ };
2287
+ const modalTitleWithIcon = "_modalTitleWithIcon_5g0kf_1";
2288
+ const modalIcon = "_modalIcon_5g0kf_7";
2289
+ const modalTitleContent = "_modalTitleContent_5g0kf_16";
2290
+ const modalTitleText = "_modalTitleText_5g0kf_21";
2291
+ const modalContentWithIcon = "_modalContentWithIcon_5g0kf_30";
2292
+ const styles$3 = {
2293
+ modalTitleWithIcon,
2294
+ modalIcon,
2295
+ modalTitleContent,
2296
+ modalTitleText,
2297
+ modalContentWithIcon
2298
+ };
2299
+ const getNotificationIcon = (type) => {
2300
+ switch (type) {
2301
+ case "error":
2302
+ return /* @__PURE__ */ jsx(XCircleIcon, { color: "var(--j2-color-error)", weight: "fill", size: 24 });
2303
+ case "success":
2304
+ return /* @__PURE__ */ jsx(
2305
+ CheckCircleIcon,
2306
+ {
2307
+ color: "var(--j2-color-success)",
2308
+ weight: "fill",
2309
+ size: 24
2310
+ }
2311
+ );
2312
+ case "info":
2313
+ return /* @__PURE__ */ jsx(InfoIcon, { color: "var(--j2-color-info)", weight: "fill", size: 24 });
2314
+ case "warning":
2315
+ return /* @__PURE__ */ jsx(
2316
+ WarningCircleIcon,
2317
+ {
2318
+ color: "var(--j2-color-warning)",
2319
+ weight: "fill",
2320
+ size: 24
2321
+ }
2322
+ );
2323
+ }
2324
+ };
2325
+ const NotificationModal = ({
2326
+ type,
2327
+ title,
2328
+ children,
2329
+ withContentPadding = true,
2330
+ ...props
2331
+ }) => {
2332
+ const icon = useMemo(() => getNotificationIcon(type), [type]);
2333
+ const titleWithIcon = /* @__PURE__ */ jsxs("div", { className: styles$3.modalTitleWithIcon, children: [
2334
+ /* @__PURE__ */ jsx("div", { className: styles$3.modalIcon, children: icon }),
2335
+ /* @__PURE__ */ jsx("div", { className: styles$3.modalTitleContent, children: /* @__PURE__ */ jsx("div", { className: styles$3.modalTitleText, children: title }) })
2336
+ ] });
2337
+ return /* @__PURE__ */ jsx(
2338
+ Modal,
2339
+ {
2340
+ title: titleWithIcon,
2341
+ withContentPadding,
2342
+ ...props,
2343
+ children: /* @__PURE__ */ jsx("div", { className: styles$3.modalContentWithIcon, children })
2344
+ }
2345
+ );
2346
+ };
2347
+ const s$1 = {
2348
+ "jump-button": "_jump-button_bwjnt_41"
2349
+ };
2350
+ const renderIconButton = (icon, isSmall, customClassName) => /* @__PURE__ */ jsx(
2351
+ Button$1,
2352
+ {
2353
+ type: "link",
2354
+ size: isSmall ? "small" : "middle",
2355
+ className: cx(customClassName, isSmall ? "!w-6" : "!w-8"),
2356
+ children: icon
2357
+ }
2358
+ );
2359
+ const renderJumpItem = (icon, doubleIcon, isSmall) => /* @__PURE__ */ jsx("a", { className: "ant-pagination-item-link", children: /* @__PURE__ */ jsxs("div", { className: "ant-pagination-item-container", children: [
2360
+ /* @__PURE__ */ jsx("span", { className: "ant-pagination-item-ellipsis", children: renderIconButton(icon, isSmall, s$1["jump-button"]) }),
2361
+ /* @__PURE__ */ jsx("span", { className: "ant-pagination-item-link-icon", children: renderIconButton(doubleIcon, isSmall, s$1["jump-button"]) })
2362
+ ] }) });
2363
+ const buildItemRender = ({ paginationTextLabels, isSmall }) => (_page, type, element) => {
2364
+ if (type === "prev") {
2365
+ return /* @__PURE__ */ jsx("a", { children: paginationTextLabels ? "Previous" : renderIconButton(/* @__PURE__ */ jsx(CaretLeftIcon, {}), isSmall) });
2366
+ }
2367
+ if (type === "next") {
2368
+ return /* @__PURE__ */ jsx("a", { children: paginationTextLabels ? "Next" : renderIconButton(/* @__PURE__ */ jsx(CaretRightIcon, {}), isSmall) });
2369
+ }
2370
+ if (type === "jump-prev") {
2371
+ return renderJumpItem(/* @__PURE__ */ jsx(DotsThreeIcon, {}), /* @__PURE__ */ jsx(CaretDoubleLeftIcon, {}), isSmall);
2372
+ }
2373
+ if (type === "jump-next") {
2374
+ return renderJumpItem(
2375
+ /* @__PURE__ */ jsx(DotsThreeIcon, {}),
2376
+ /* @__PURE__ */ jsx(CaretDoubleRightIcon, {}),
2377
+ isSmall
2378
+ );
2379
+ }
2380
+ return element;
2381
+ };
2382
+ const paginationSelectComponentClass = (selectProps) => /* @__PURE__ */ jsx(Select$1, { ...selectProps, suffixIcon: /* @__PURE__ */ jsx(CaretDownIcon, {}) });
2383
+ const getPaginationLocale = (isSmall) => ({
2384
+ jump_to: `Go to ${isSmall ? ":   " : ""}`,
2385
+ page: isSmall ? "" : "page"
2386
+ });
2387
+ const withDesignSystemPaginationOverrides = (pagination, { paginationTextLabels = false, isSmall } = {}) => {
2388
+ const small = isSmall ?? pagination.size === "small";
2389
+ return {
2390
+ ...pagination,
2391
+ locale: { ...getPaginationLocale(small), ...pagination.locale },
2392
+ selectComponentClass: paginationSelectComponentClass,
2393
+ itemRender: buildItemRender({
2394
+ paginationTextLabels,
2395
+ isSmall: small
2396
+ })
2397
+ };
2398
+ };
2399
+ const Pagination = ({ paginationTextLabels = false, ...props }) => {
2400
+ const enriched = withDesignSystemPaginationOverrides(props, {
2401
+ paginationTextLabels
2402
+ });
2403
+ return /* @__PURE__ */ jsx(Pagination$1, { ...enriched });
2404
+ };
2405
+ const Progress = ({ ...props }) => {
2406
+ return /* @__PURE__ */ jsx(Progress$1, { ...props });
2407
+ };
2408
+ const Radio = (props) => {
2409
+ return /* @__PURE__ */ jsx(Radio$1, { ...props });
2410
+ };
2411
+ const RadioGroup = ({
2412
+ buttonStyle = "solid",
2413
+ optionType = "button",
2414
+ ...props
2415
+ }) => {
2416
+ return /* @__PURE__ */ jsx(
2417
+ Radio$1.Group,
2418
+ {
2419
+ ...props,
2420
+ buttonStyle,
2421
+ optionType
2422
+ }
2423
+ );
2424
+ };
2425
+ const Rate = ({ count = 5, ...props }) => {
2426
+ return /* @__PURE__ */ jsx(
2427
+ Rate$1,
2428
+ {
2429
+ ...props,
2430
+ className: "j2-rate",
2431
+ count,
2432
+ disabled: true,
2433
+ allowHalf: true,
2434
+ allowClear: true,
2435
+ character: /* @__PURE__ */ jsx(StarIcon, { weight: "fill" })
2436
+ }
2437
+ );
2438
+ };
2439
+ const isGroupOption$1 = (opt) => "options" in opt && Array.isArray(opt.options);
2440
+ const flattenOptions = (opts) => {
2441
+ if (!opts) return [];
2442
+ return opts.flatMap(
2443
+ (o) => isGroupOption$1(o) ? flattenOptions(o.options) : [o]
2444
+ );
2445
+ };
2446
+ const Select = (props) => {
2447
+ var _a;
2448
+ const [isFocused, setIsFocused] = useState(false);
2449
+ const [isSearching, setIsSearching] = useState(false);
2450
+ const [field, , helpers] = useField(props.name);
2451
+ const isMultiple = props.mode === "multiple";
2452
+ const hasOptions = (((_a = props.options) == null ? void 0 : _a.length) ?? 0) > 0;
2453
+ const currentValue = Array.isArray(field.value) ? field.value : [];
2454
+ const showSelectAllFooter = isMultiple && !props.loading && !props.disabled && hasOptions && !isSearching;
2455
+ const handleSearch = (value) => {
2456
+ setIsSearching(value.length > 0);
2457
+ if (props.onSearch) {
2458
+ props.onSearch(value);
2459
+ }
2460
+ };
2461
+ const handleToggleAll = () => {
2462
+ var _a2, _b;
2463
+ if (props.disabled) return;
2464
+ if (currentValue.length === 0) {
2465
+ const flat = flattenOptions(
2466
+ props.options
2467
+ );
2468
+ const allOptions = flat.filter(
2469
+ (opt) => opt.value !== void 0 && opt.value !== null && !opt.disabled
2470
+ );
2471
+ const payload = props.labelInValue ? allOptions.map((opt) => ({ value: opt.value, label: opt.label })) : allOptions.map((opt) => opt.value);
2472
+ void helpers.setValue(payload);
2473
+ (_a2 = props.onChange) == null ? void 0 : _a2.call(props, payload, allOptions);
2474
+ } else {
2475
+ void helpers.setValue([]);
2476
+ (_b = props.onChange) == null ? void 0 : _b.call(props, [], []);
2477
+ }
2478
+ };
2479
+ const dropdownRender = (menu) => {
2480
+ if (props.loading) {
2481
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-1", children: [
2482
+ /* @__PURE__ */ jsx("span", { children: "Loading..." }),
2483
+ /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(LoadingOutlined, { spin: true }), size: "small" })
2484
+ ] });
2485
+ }
2486
+ if (!props.options || props.options && props.options.length === 0) {
2487
+ return /* @__PURE__ */ jsx("div", { className: "px-3 py-1", children: "No options" });
2488
+ }
2489
+ if (!showSelectAllFooter) return menu;
2490
+ const label = currentValue.length === 0 ? "Select all" : "Clear all";
2491
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2492
+ menu,
2493
+ /* @__PURE__ */ jsx("div", { className: "mt-1 pt-1 border-t border-j2-border-secondary", children: /* @__PURE__ */ jsx(
2494
+ "button",
2495
+ {
2496
+ type: "button",
2497
+ "aria-label": label,
2498
+ title: label,
2499
+ onMouseDown: (e) => e.preventDefault(),
2500
+ onClick: handleToggleAll,
2501
+ className: "w-full text-center font-semibold text-sm py-1.5 rounded cursor-pointer text-j2-primary hover:bg-j2-primary-bg-hover bg-transparent border-0",
2502
+ children: label
2503
+ }
2504
+ ) })
2505
+ ] });
2506
+ };
2507
+ return /* @__PURE__ */ jsx(
2508
+ Select$2,
2509
+ {
2510
+ suffixIcon: props.loading ? /* @__PURE__ */ jsx(
2511
+ Spin,
2512
+ {
2513
+ indicator: /* @__PURE__ */ jsx(LoadingOutlined, { spin: true }),
2514
+ size: "small",
2515
+ "data-testid": "loading-spinner"
2516
+ }
2517
+ ) : props.showSearch && isFocused ? /* @__PURE__ */ jsx(MagnifyingGlassIcon, { size: 14, "data-testid": "magnifying-glass" }) : /* @__PURE__ */ jsx(CaretDownIcon, { size: 14, "data-testid": "caret-down" }),
2518
+ ...props,
2519
+ popupRender: dropdownRender,
2520
+ removeIcon: /* @__PURE__ */ jsx(XCircleIcon, { size: 12 }),
2521
+ allowClear: props.allowClear ? { clearIcon: /* @__PURE__ */ jsx(XCircleIcon, { size: 14 }) } : false,
2522
+ showSearch: props.showSearch,
2523
+ onSearch: handleSearch,
2524
+ onFocus: () => {
2525
+ setIsFocused(true);
2526
+ },
2527
+ onBlur: () => {
2528
+ setIsFocused(false);
2529
+ setIsSearching(false);
2530
+ },
2531
+ size: props.size || "large"
2532
+ }
2533
+ );
2534
+ };
2535
+ const AntdSelect = (props) => {
2536
+ var _a;
2537
+ const [isFocused, setIsFocused] = useState(false);
2538
+ const handleSearch = (value) => {
2539
+ if (props.onSearch) {
2540
+ props.onSearch(value);
2541
+ }
2542
+ };
2543
+ const dropdownRender = React.useCallback(
2544
+ (menu) => {
2545
+ if (props.loading) {
2546
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-1", children: [
2547
+ /* @__PURE__ */ jsx("span", { children: "Loading..." }),
2548
+ /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(LoadingOutlined, { spin: true }), size: "small" })
2549
+ ] });
2550
+ }
2551
+ if (!props.options || props.options && props.options.length === 0) {
2552
+ return /* @__PURE__ */ jsx("div", { className: "px-3 py-1", children: "No options" });
2553
+ }
2554
+ return menu;
2555
+ },
2556
+ [props.loading, (_a = props.options) == null ? void 0 : _a.length]
2557
+ );
2558
+ return /* @__PURE__ */ jsx(
2559
+ Select$1,
2560
+ {
2561
+ suffixIcon: props.loading ? /* @__PURE__ */ jsx(
2562
+ Spin,
2563
+ {
2564
+ indicator: /* @__PURE__ */ jsx(LoadingOutlined, { spin: true }),
2565
+ size: "small",
2566
+ "data-testid": "loading-spinner"
2567
+ }
2568
+ ) : props.showSearch && isFocused ? /* @__PURE__ */ jsx(MagnifyingGlassIcon, { size: 14, "data-testid": "magnifying-glass" }) : /* @__PURE__ */ jsx(CaretDownIcon, { size: 14, "data-testid": "caret-down" }),
2569
+ ...props,
2570
+ popupRender: dropdownRender,
2571
+ removeIcon: /* @__PURE__ */ jsx(XCircleIcon, { size: 12 }),
2572
+ allowClear: props.allowClear ? { clearIcon: /* @__PURE__ */ jsx(XCircleIcon, { size: 14 }) } : false,
2573
+ showSearch: props.showSearch,
2574
+ onSearch: props.onSearch ? handleSearch : void 0,
2575
+ onFocus: () => {
2576
+ setIsFocused(true);
2577
+ },
2578
+ onBlur: () => {
2579
+ setIsFocused(false);
2580
+ },
2581
+ size: props.size || "large"
2582
+ }
2583
+ );
2584
+ };
2585
+ const index = /* @__PURE__ */ _mergeNamespaces({
2586
+ __proto__: null
2587
+ }, [react]);
2588
+ const colorToIcon = {
2589
+ error: XCircleIcon,
2590
+ success: CheckCircleIcon,
2591
+ warning: WarningCircleIcon,
2592
+ processing: ArrowsClockwiseIcon,
2593
+ default: GearIcon
2594
+ };
2595
+ const statusToColor = {
2596
+ error: "var(--j2-color-error-text)",
2597
+ success: "var(--j2-color-success)",
2598
+ warning: "var(--j2-color-warning-text)",
2599
+ processing: "var(--j2-color-primary)",
2600
+ default: "var(--j2-color-text)"
2601
+ };
2602
+ const Tag = ({
2603
+ status,
2604
+ showIcon = false,
2605
+ icon,
2606
+ size = "default",
2607
+ ...props
2608
+ }) => {
2609
+ const iconComponent = React.useMemo(() => {
2610
+ if (!showIcon || size === "small") return null;
2611
+ const baseProps = {
2612
+ size: 12
2613
+ };
2614
+ const iconName = icon ?? colorToIcon[status];
2615
+ const color = statusToColor[status];
2616
+ return /* @__PURE__ */ jsx("span", { role: "img", className: "anticon", "aria-label": `${status} icon`, children: React.createElement(iconName, { color, ...baseProps }) });
2617
+ }, [status, showIcon, icon]);
2618
+ const statusToClassName = {
2619
+ default: "bg-[var(--j2-color-fill-quaternary)]"
2620
+ };
2621
+ return /* @__PURE__ */ jsx(
2622
+ Tag$1,
2623
+ {
2624
+ ...props,
2625
+ color: status,
2626
+ icon: iconComponent,
2627
+ className: cx(
2628
+ props.className,
2629
+ statusToClassName[status],
2630
+ size === "small" && "!px-1 !py-0 !h-auto !text-j2-xs !rounded-j2-sm"
2631
+ )
2632
+ }
2633
+ );
2634
+ };
2635
+ const hemisphericSelect = "_hemisphericSelect_2ivoh_1";
2636
+ const summarizedSelect = "_summarizedSelect_2ivoh_11";
2637
+ const isActive = "_isActive_2ivoh_22";
2638
+ const menuContainer = "_menuContainer_2ivoh_36";
2639
+ const menuContainerMultiple = "_menuContainerMultiple_2ivoh_46";
2640
+ const headlinedSelect = "_headlinedSelect_2ivoh_61";
2641
+ const headlinedMenuContainer = "_headlinedMenuContainer_2ivoh_105";
2642
+ const clearAllButton = "_clearAllButton_2ivoh_116";
2643
+ const styles$2 = {
2644
+ hemisphericSelect,
2645
+ summarizedSelect,
2646
+ isActive,
2647
+ menuContainer,
2648
+ menuContainerMultiple,
2649
+ headlinedSelect,
2650
+ headlinedMenuContainer,
2651
+ clearAllButton
2652
+ };
2653
+ const isGroupOption = (option) => {
2654
+ return "options" in option;
2655
+ };
2656
+ const getAllOptions = (options) => {
2657
+ if (!options) return [];
2658
+ return options.flatMap(
2659
+ (option) => isGroupOption(option) ? option.options : [option]
2660
+ );
2661
+ };
2662
+ const filterOptions = (options, searchValue) => {
2663
+ if (!options) return [];
2664
+ if (!searchValue) return options;
2665
+ return options.map((option) => {
2666
+ var _a;
2667
+ if (isGroupOption(option)) {
2668
+ const filteredSubOptions = option.options.filter(
2669
+ (subOption) => {
2670
+ var _a2;
2671
+ return (_a2 = subOption.label) == null ? void 0 : _a2.toString().toLowerCase().includes(searchValue.toLowerCase());
2672
+ }
2673
+ );
2674
+ return filteredSubOptions.length > 0 ? { ...option, options: filteredSubOptions } : null;
2675
+ } else {
2676
+ return ((_a = option.label) == null ? void 0 : _a.toString().toLowerCase().includes(searchValue.toLowerCase())) ? option : null;
2677
+ }
2678
+ }).filter((option) => option !== null);
2679
+ };
2680
+ function SummarizedSelect({
2681
+ searchPlaceholder,
2682
+ formControlPlaceholder,
2683
+ loading,
2684
+ multiple,
2685
+ value,
2686
+ onChange,
2687
+ options,
2688
+ renderLabel,
2689
+ rootClassName,
2690
+ popupClassName,
2691
+ variant,
2692
+ trigger = "select",
2693
+ defaultOpen = false,
2694
+ ...props
2695
+ }) {
2696
+ const isHeadline = variant === "headlined";
2697
+ const antVariant = isHeadline ? "borderless" : variant;
2698
+ const [searchValue, setSearchValue] = useState("");
2699
+ const [focusTrigger, setFocusTrigger] = useState(defaultOpen ? 1 : 0);
2700
+ const [isOpen, setIsOpen] = useState(defaultOpen);
2701
+ const inputRef = useRef(null);
2702
+ const measureSpanRef = useRef(null);
2703
+ const [measuredWidth, setMeasuredWidth] = useState();
2704
+ const displayText = useMemo(() => {
2705
+ if (multiple && value.length > 0) {
2706
+ return renderLabel(value.length);
2707
+ }
2708
+ if (!multiple && value) {
2709
+ const option = getAllOptions(options).find((opt) => opt.value === value);
2710
+ return option ? String(option.label) : String(value);
2711
+ }
2712
+ return formControlPlaceholder ?? "";
2713
+ }, [multiple, value, options, renderLabel, formControlPlaceholder]);
2714
+ useEffect(() => {
2715
+ if (!measureSpanRef.current) return;
2716
+ setMeasuredWidth(Math.ceil(measureSpanRef.current.offsetWidth) + 46);
2717
+ }, [displayText]);
2718
+ useEffect(() => {
2719
+ if (focusTrigger > 0) {
2720
+ requestAnimationFrame(() => {
2721
+ requestAnimationFrame(() => {
2722
+ setTimeout(() => {
2723
+ var _a;
2724
+ (_a = inputRef.current) == null ? void 0 : _a.focus({ cursor: "end" });
2725
+ }, 100);
2726
+ });
2727
+ });
2728
+ }
2729
+ }, [focusTrigger]);
2730
+ const filteredOptions = useMemo(() => {
2731
+ return filterOptions(options, searchValue);
2732
+ }, [searchValue, options]);
2733
+ const flatFilteredOptions = useMemo(() => {
2734
+ return getAllOptions(filteredOptions);
2735
+ }, [filteredOptions]);
2736
+ const allFlatOptions = useMemo(() => {
2737
+ return getAllOptions(options);
2738
+ }, [options]);
2739
+ const handleTagClose = (removedValue) => {
2740
+ if (!multiple) return;
2741
+ onChange(value.filter((x) => x !== removedValue));
2742
+ };
2743
+ const handleToggleAll = () => {
2744
+ if (!multiple) return;
2745
+ const allFilteredValues = getAllOptions(filteredOptions).map(
2746
+ (opt) => opt.value
2747
+ );
2748
+ const someSelected = allFilteredValues.some((val) => value.includes(val));
2749
+ if (someSelected) {
2750
+ onChange(value.filter((val) => !allFilteredValues.includes(val)));
2751
+ }
2752
+ };
2753
+ const handleSelectFirstOption = () => {
2754
+ if (flatFilteredOptions.length === 0) return;
2755
+ const firstOption = flatFilteredOptions[0];
2756
+ if (!firstOption) return;
2757
+ const optionValue = firstOption.value;
2758
+ if (multiple) {
2759
+ if (value.includes(optionValue)) {
2760
+ onChange(value.filter((v) => v !== optionValue));
2761
+ } else {
2762
+ onChange([...value, optionValue]);
2763
+ }
2764
+ } else {
2765
+ onChange(optionValue);
2766
+ setIsOpen(false);
2767
+ }
2768
+ };
2769
+ const handleOptionClick = (optionValue) => {
2770
+ if (multiple) {
2771
+ if (value.includes(optionValue)) {
2772
+ onChange(value.filter((v) => v !== optionValue));
2773
+ } else {
2774
+ onChange([...value, optionValue]);
2775
+ }
2776
+ } else {
2777
+ onChange(optionValue);
2778
+ setIsOpen(false);
2779
+ }
2780
+ };
2781
+ const handleKeyDown = (e) => {
2782
+ const navigationKeys = ["ArrowUp", "ArrowDown"];
2783
+ if (e.key === "Enter") {
2784
+ e.preventDefault();
2785
+ e.stopPropagation();
2786
+ handleSelectFirstOption();
2787
+ return;
2788
+ }
2789
+ if (e.key === "Escape") {
2790
+ e.preventDefault();
2791
+ e.stopPropagation();
2792
+ setIsOpen(false);
2793
+ return;
2794
+ }
2795
+ if (navigationKeys.includes(e.key)) {
2796
+ e.preventDefault();
2797
+ return;
2798
+ }
2799
+ e.stopPropagation();
2800
+ };
2801
+ const optionRender = (option) => {
2802
+ if ("logo" in option.data && option.data.logo) {
2803
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2804
+ /* @__PURE__ */ jsx("div", { className: "h-4 shrink-0", children: option.data.logo }),
2805
+ /* @__PURE__ */ jsx("span", { className: "overflow-ellipsis overflow-hidden", children: option.label })
2806
+ ] });
2807
+ }
2808
+ return /* @__PURE__ */ jsx("div", { children: option.label });
2809
+ };
2810
+ const popupRender = (menu) => {
2811
+ const valueToLabel = (val) => {
2812
+ const option = allFlatOptions.find((opt) => opt.value === val);
2813
+ return option ? option.label : val;
2814
+ };
2815
+ return /* @__PURE__ */ jsxs("div", { children: [
2816
+ /* @__PURE__ */ jsx("div", { className: "mb-2 px-2 pb-2 border-b -mx-1 mt-1", children: /* @__PURE__ */ jsx(
2817
+ Input$1,
2818
+ {
2819
+ ref: inputRef,
2820
+ autoFocus: true,
2821
+ placeholder: searchPlaceholder || "Search...",
2822
+ value: searchValue,
2823
+ onChange: (e) => {
2824
+ setSearchValue(e.target.value);
2825
+ e.stopPropagation();
2826
+ e.preventDefault();
2827
+ },
2828
+ onKeyDown: handleKeyDown,
2829
+ onClick: (e) => e.stopPropagation(),
2830
+ prefix: /* @__PURE__ */ jsx(
2831
+ MagnifyingGlassIcon,
2832
+ {
2833
+ size: 16,
2834
+ className: "text-j2-text-placeholder"
2835
+ }
2836
+ ),
2837
+ allowClear: true
2838
+ },
2839
+ focusTrigger
2840
+ ) }),
2841
+ multiple && value.length > 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-y-1", children: value.map((value2) => /* @__PURE__ */ jsx(
2842
+ Tag,
2843
+ {
2844
+ className: "opacity-100 z-10 flex max-w-full",
2845
+ status: "default",
2846
+ closable: true,
2847
+ onClose: () => handleTagClose(value2),
2848
+ children: /* @__PURE__ */ jsx(
2849
+ "span",
2850
+ {
2851
+ className: "overflow-ellipsis overflow-hidden",
2852
+ title: valueToLabel(value2),
2853
+ children: valueToLabel(value2)
2854
+ }
2855
+ )
2856
+ },
2857
+ value2
2858
+ )) }) }) : null,
2859
+ /* @__PURE__ */ jsx(
2860
+ "div",
2861
+ {
2862
+ className: cx(styles$2.menuContainer, "rounded-lg", {
2863
+ [styles$2.headlinedMenuContainer]: isHeadline,
2864
+ [styles$2.menuContainerMultiple]: multiple
2865
+ }),
2866
+ children: menu
2867
+ }
2868
+ ),
2869
+ /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center", children: multiple && /* @__PURE__ */ jsx("div", { className: "w-full mt-1 pt-1 border-t border-j2-border-secondary", children: /* @__PURE__ */ jsx(
2870
+ "div",
2871
+ {
2872
+ "aria-selected": "false",
2873
+ className: cx(
2874
+ "ant-select-item ant-select-item-option w-full",
2875
+ styles$2.clearAllButton
2876
+ ),
2877
+ title: "Clear all",
2878
+ onClick: handleToggleAll,
2879
+ children: /* @__PURE__ */ jsx("div", { className: "ant-select-item-option-content text-center font-semibold", children: "Clear all" })
2880
+ }
2881
+ ) }) })
2882
+ ] });
2883
+ };
2884
+ const handleOpenChange = (open) => {
2885
+ setIsOpen(open);
2886
+ if (open) {
2887
+ setFocusTrigger((prev) => prev + 1);
2888
+ } else {
2889
+ setSearchValue("");
2890
+ }
2891
+ };
2892
+ const renderDropdownOptionRow = (option) => {
2893
+ const optionValue = option.value;
2894
+ const isSelected = multiple ? value.includes(optionValue) : value === optionValue;
2895
+ const hasLogo = "logo" in option && option.logo;
2896
+ return /* @__PURE__ */ jsx(
2897
+ "div",
2898
+ {
2899
+ role: "option",
2900
+ "aria-selected": isSelected,
2901
+ onClick: () => handleOptionClick(optionValue),
2902
+ className: cx(
2903
+ "px-3 py-1.5 rounded cursor-pointer text-sm",
2904
+ isSelected ? "bg-[var(--j2-color-primary)] text-white hover:bg-[var(--j2-color-primary)]" : "hover:bg-[var(--j2-color-bg-hover)]"
2905
+ ),
2906
+ children: hasLogo ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2907
+ /* @__PURE__ */ jsx("div", { className: "h-4 shrink-0", children: option.logo }),
2908
+ /* @__PURE__ */ jsx("span", { className: "overflow-hidden overflow-ellipsis", children: option.label })
2909
+ ] }) : option.label
2910
+ },
2911
+ optionValue
2912
+ );
2913
+ };
2914
+ const dropdownPopupRender = () => {
2915
+ const valueToLabel = (val) => {
2916
+ const option = allFlatOptions.find((opt) => opt.value === val);
2917
+ return option ? option.label : val;
2918
+ };
2919
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-lg shadow-md p-2 min-w-[240px]", children: [
2920
+ /* @__PURE__ */ jsx("div", { className: "pb-2 border-b border-j2-border-secondary", children: /* @__PURE__ */ jsx(
2921
+ Input$1,
2922
+ {
2923
+ ref: inputRef,
2924
+ autoFocus: true,
2925
+ placeholder: searchPlaceholder || "Search...",
2926
+ value: searchValue,
2927
+ onChange: (e) => {
2928
+ setSearchValue(e.target.value);
2929
+ e.stopPropagation();
2930
+ },
2931
+ onKeyDown: handleKeyDown,
2932
+ onClick: (e) => e.stopPropagation(),
2933
+ prefix: /* @__PURE__ */ jsx(
2934
+ MagnifyingGlassIcon,
2935
+ {
2936
+ size: 16,
2937
+ className: "text-j2-text-placeholder"
2938
+ }
2939
+ ),
2940
+ allowClear: true
2941
+ },
2942
+ focusTrigger
2943
+ ) }),
2944
+ multiple && value.length > 0 && /* @__PURE__ */ jsx("div", { className: "px-1 pt-2", children: /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-y-1", children: value.map((v) => /* @__PURE__ */ jsx(
2945
+ Tag,
2946
+ {
2947
+ className: "opacity-100 z-10 flex max-w-full",
2948
+ status: "default",
2949
+ closable: true,
2950
+ onClose: () => handleTagClose(v),
2951
+ children: /* @__PURE__ */ jsx(
2952
+ "span",
2953
+ {
2954
+ className: "overflow-ellipsis overflow-hidden",
2955
+ title: valueToLabel(v),
2956
+ children: valueToLabel(v)
2957
+ }
2958
+ )
2959
+ },
2960
+ v
2961
+ )) }) }),
2962
+ /* @__PURE__ */ jsx(
2963
+ "div",
2964
+ {
2965
+ className: "max-h-72 overflow-y-auto py-1",
2966
+ role: "listbox",
2967
+ "aria-multiselectable": multiple || void 0,
2968
+ children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-[var(--j2-color-text-secondary)]", children: "No options found" }) : filteredOptions.map((opt) => {
2969
+ if (isGroupOption(opt)) {
2970
+ return /* @__PURE__ */ jsxs("div", { children: [
2971
+ /* @__PURE__ */ jsx("div", { className: "px-3 pt-2 pb-1 text-xs font-semibold uppercase tracking-wide text-[var(--j2-color-text-tertiary)]", children: opt.label }),
2972
+ opt.options.map(renderDropdownOptionRow)
2973
+ ] }, `group-${opt.label}`);
2974
+ }
2975
+ return renderDropdownOptionRow(opt);
2976
+ })
2977
+ }
2978
+ ),
2979
+ multiple && value.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-1 pt-1 border-t border-j2-border-secondary", children: /* @__PURE__ */ jsx(
2980
+ "div",
2981
+ {
2982
+ role: "button",
2983
+ "aria-label": "Clear all",
2984
+ title: "Clear all",
2985
+ onClick: handleToggleAll,
2986
+ className: cx(
2987
+ "text-center font-semibold text-sm py-1.5 rounded cursor-pointer",
2988
+ styles$2.clearAllButton
2989
+ ),
2990
+ children: "Clear all"
2991
+ }
2992
+ ) })
2993
+ ] });
2994
+ };
2995
+ if (trigger === "dropdown") {
2996
+ const hasSelection = multiple ? value.length > 0 : Boolean(value);
2997
+ const triggerContent = /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
2998
+ hasSelection ? displayText : formControlPlaceholder ?? "Select",
2999
+ loading ? /* @__PURE__ */ jsx(
3000
+ Spin,
3001
+ {
3002
+ indicator: /* @__PURE__ */ jsx(LoadingOutlined, { spin: true }),
3003
+ size: "small",
3004
+ "data-testid": "loading-spinner"
3005
+ }
3006
+ ) : /* @__PURE__ */ jsx(CaretDownIcon, { weight: "regular", "data-testid": "caret-down" })
3007
+ ] });
3008
+ return /* @__PURE__ */ jsx(
3009
+ Dropdown$1,
3010
+ {
3011
+ open: isOpen,
3012
+ onOpenChange: handleOpenChange,
3013
+ trigger: ["click"],
3014
+ disabled: props.disabled,
3015
+ popupRender: dropdownPopupRender,
3016
+ children: /* @__PURE__ */ jsx(
3017
+ Typography.Link,
3018
+ {
3019
+ disabled: props.disabled,
3020
+ className: cx("inline-flex", rootClassName),
3021
+ children: triggerContent
3022
+ }
3023
+ )
3024
+ }
3025
+ );
3026
+ }
3027
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3028
+ /* @__PURE__ */ jsx(
3029
+ "span",
3030
+ {
3031
+ ref: measureSpanRef,
3032
+ "aria-hidden": true,
3033
+ style: {
3034
+ position: "absolute",
3035
+ visibility: "hidden",
3036
+ whiteSpace: "nowrap",
3037
+ fontSize: "inherit"
3038
+ },
3039
+ children: displayText
3040
+ }
3041
+ ),
3042
+ /* @__PURE__ */ jsx(
3043
+ Select$1,
3044
+ {
3045
+ open: isOpen,
3046
+ showSearch: false,
3047
+ style: { width: measuredWidth },
3048
+ suffixIcon: loading ? /* @__PURE__ */ jsx(
3049
+ Spin,
3050
+ {
3051
+ indicator: /* @__PURE__ */ jsx(LoadingOutlined, { spin: true }),
3052
+ size: "small",
3053
+ "data-testid": "loading-spinner"
3054
+ }
3055
+ ) : /* @__PURE__ */ jsx(CaretDownIcon, { size: 14, "data-testid": "caret-down" }),
3056
+ placeholder: formControlPlaceholder,
3057
+ mode: multiple ? "multiple" : void 0,
3058
+ value,
3059
+ maxTagCount: 0,
3060
+ maxTagPlaceholder: multiple ? () => renderLabel(value.length) : value,
3061
+ options: filteredOptions,
3062
+ onChange: (val) => {
3063
+ if (multiple) {
3064
+ if (Array.isArray(val)) {
3065
+ onChange(val);
3066
+ } else {
3067
+ throw new Error("Value should be an array in multiple mode");
3068
+ }
3069
+ } else {
3070
+ if (typeof val === "string") {
3071
+ onChange(val);
3072
+ } else {
3073
+ throw new Error(
3074
+ "Value should be a string in single selection mode"
3075
+ );
3076
+ }
3077
+ }
3078
+ },
3079
+ popupRender,
3080
+ optionRender,
3081
+ onOpenChange: handleOpenChange,
3082
+ classNames: {
3083
+ root: cx(rootClassName, styles$2.summarizedSelect, {
3084
+ [styles$2.hemisphericSelect]: variant !== "underlined" && variant !== "headlined",
3085
+ [styles$2.isActive]: multiple && value.length > 0 && variant !== "underlined" && variant !== "headlined",
3086
+ [styles$2.headlinedSelect]: isHeadline
3087
+ }),
3088
+ popup: { root: popupClassName }
3089
+ },
3090
+ variant: antVariant,
3091
+ ...props
3092
+ }
3093
+ )
3094
+ ] });
3095
+ }
3096
+ const Skeleton = (props) => {
3097
+ return /* @__PURE__ */ jsx(Skeleton$1, { ...props });
3098
+ };
3099
+ Skeleton.Node = Skeleton$1.Node;
3100
+ Skeleton.Avatar = Skeleton$1.Avatar;
3101
+ Skeleton.Input = Skeleton$1.Input;
3102
+ Skeleton.Image = Skeleton$1.Image;
3103
+ Skeleton.Button = Skeleton$1.Button;
3104
+ const SvgProgressCircle = (props) => /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 80 80", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("g", { clipPath: "url(#clip0_552_202130)" }, /* @__PURE__ */ React.createElement("circle", { cx: 40, cy: 40, r: 38, stroke: "black", strokeOpacity: 0.06, strokeWidth: 4 }), /* @__PURE__ */ React.createElement("path", { d: "M40 2C48.0248 2 55.8436 4.54049 62.3358 9.25736", stroke: "#253761", strokeWidth: 4, strokeLinecap: "round" })), /* @__PURE__ */ React.createElement("defs", null, /* @__PURE__ */ React.createElement("clipPath", { id: "clip0_552_202130" }, /* @__PURE__ */ React.createElement("rect", { width: 80, height: 80, fill: "white" }))));
3105
+ const SpinIcon = ({ height, width }) => {
3106
+ return /* @__PURE__ */ jsx(Icon, { spin: true, component: () => /* @__PURE__ */ jsx(SvgProgressCircle, {}), style: { height, width } });
3107
+ };
3108
+ const Spinner = ({ size = 80, className }) => {
3109
+ return /* @__PURE__ */ jsx(
3110
+ Spin,
3111
+ {
3112
+ className,
3113
+ indicator: /* @__PURE__ */ jsx(SpinIcon, { height: size, width: size })
3114
+ }
3115
+ );
3116
+ };
3117
+ const useSteps = ({
3118
+ current,
3119
+ setCurrent,
3120
+ totalSteps,
3121
+ initialStep = 0
3122
+ }) => {
3123
+ const [internalCurrent, setInternalCurrent] = useState(initialStep);
3124
+ const isControlled = current !== void 0 && setCurrent !== void 0;
3125
+ const currentStep = isControlled ? current : internalCurrent;
3126
+ const handleSetCurrent = useCallback(
3127
+ (newCurrent) => {
3128
+ if (isControlled) {
3129
+ setCurrent(newCurrent);
3130
+ } else {
3131
+ setInternalCurrent(newCurrent);
3132
+ }
3133
+ },
3134
+ [isControlled, setCurrent]
3135
+ );
3136
+ const next = useCallback(() => {
3137
+ if (currentStep < totalSteps - 1) {
3138
+ handleSetCurrent(currentStep + 1);
3139
+ }
3140
+ }, [currentStep, totalSteps, handleSetCurrent]);
3141
+ const previous = useCallback(() => {
3142
+ if (currentStep > 0) {
3143
+ handleSetCurrent(currentStep - 1);
3144
+ }
3145
+ }, [currentStep, handleSetCurrent]);
3146
+ const goToStep = useCallback(
3147
+ (step) => {
3148
+ if (step >= 0 && step < totalSteps) {
3149
+ handleSetCurrent(step);
3150
+ }
3151
+ },
3152
+ [totalSteps, handleSetCurrent]
3153
+ );
3154
+ const cancel = useCallback(() => {
3155
+ handleSetCurrent(initialStep);
3156
+ }, [handleSetCurrent, initialStep]);
3157
+ return {
3158
+ next,
3159
+ previous,
3160
+ goToStep,
3161
+ cancel,
3162
+ current: currentStep,
3163
+ setCurrent: handleSetCurrent,
3164
+ canGoNext: currentStep < totalSteps - 1,
3165
+ canGoPrevious: currentStep > 0
3166
+ };
3167
+ };
3168
+ const Steps = ({
3169
+ items,
3170
+ current,
3171
+ setCurrent,
3172
+ dot = false,
3173
+ ...props
3174
+ }) => {
3175
+ const isVertical = props.direction === "vertical";
3176
+ const totalSteps = (items == null ? void 0 : items.length) || 0;
3177
+ const { current: currentStep, setCurrent: setCurrentStep } = useSteps({
3178
+ current,
3179
+ setCurrent,
3180
+ totalSteps
3181
+ });
3182
+ return /* @__PURE__ */ jsx(
3183
+ Steps$1,
3184
+ {
3185
+ className: "j2Steps",
3186
+ ...props,
3187
+ current: currentStep,
3188
+ onChange: (curr) => setCurrentStep(curr),
3189
+ ...dot && { progressDot: true },
3190
+ items: items == null ? void 0 : items.map((item, index2) => {
3191
+ return {
3192
+ ...item,
3193
+ icon: !dot && currentStep > index2 ? /* @__PURE__ */ jsx(
3194
+ "div",
3195
+ {
3196
+ className: cx(
3197
+ `check-${props.size}`,
3198
+ isVertical ? `vertical-check-icon` : `check-icon`
3199
+ ),
3200
+ children: /* @__PURE__ */ jsx(CheckIcon, { size: 16 })
3201
+ }
3202
+ ) : item.icon
3203
+ };
3204
+ })
3205
+ }
3206
+ );
3207
+ };
3208
+ const Switch = ({
3209
+ small,
3210
+ loading = false,
3211
+ disabled = false,
3212
+ checked,
3213
+ onChange,
3214
+ ...props
3215
+ }) => {
3216
+ return /* @__PURE__ */ jsx(
3217
+ Switch$1,
3218
+ {
3219
+ ...props,
3220
+ size: small ? "small" : "default",
3221
+ loading,
3222
+ disabled,
3223
+ checked,
3224
+ onChange,
3225
+ className: "j2-switch"
3226
+ }
3227
+ );
3228
+ };
3229
+ const bordered = "_bordered_1vc5s_1";
3230
+ const alternatingRows = "_alternatingRows_1vc5s_49";
3231
+ const s = {
3232
+ bordered,
3233
+ alternatingRows
3234
+ };
3235
+ const defaultSortIcon = ({
3236
+ sortOrder
3237
+ }) => {
3238
+ if (sortOrder == "ascend") return /* @__PURE__ */ jsx(CaretUpIcon, {});
3239
+ if (sortOrder == "descend") return /* @__PURE__ */ jsx(CaretDownIcon, {});
3240
+ return /* @__PURE__ */ jsx(CaretUpDownIcon, {});
3241
+ };
3242
+ const Table = ({
3243
+ verticalBorders,
3244
+ alternatingRows: alternatingRows2,
3245
+ paginationTextLabels = false,
3246
+ ...props
3247
+ }) => {
3248
+ var _a, _b;
3249
+ const defaultLoadingProps = {
3250
+ indicator: /* @__PURE__ */ jsx(Spinner, { className: "!w-fit !h-fit !mx-0 translate-x-[-50%]" }),
3251
+ tip: /* @__PURE__ */ jsxs("div", { className: "mt-20", children: [
3252
+ /* @__PURE__ */ jsx("h4", { children: "Loading this chart" }),
3253
+ /* @__PURE__ */ jsx("span", { className: "text-lg", children: "Please wait a moment" })
3254
+ ] })
3255
+ };
3256
+ const loading = typeof props.loading == "object" ? { ...props.loading, ...defaultLoadingProps } : props.loading && defaultLoadingProps;
3257
+ const isSimpleValue = (value) => {
3258
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
3259
+ };
3260
+ const extractTextContent = (node) => {
3261
+ if (isSimpleValue(node)) {
3262
+ return String(node);
3263
+ }
3264
+ if (node && typeof node === "object" && "props" in node && node.props && typeof node.props === "object" && "children" in node.props) {
3265
+ const children = node.props.children;
3266
+ if (isSimpleValue(children)) {
3267
+ return String(children);
3268
+ }
3269
+ }
3270
+ return null;
3271
+ };
3272
+ const columns = (_a = props.columns) == null ? void 0 : _a.map((column) => {
3273
+ const hasEllipsis = column.ellipsis === true || typeof column.ellipsis === "object" && column.ellipsis;
3274
+ const originalRender = column.render;
3275
+ return {
3276
+ ...column,
3277
+ sortIcon: column.sortIcon ?? defaultSortIcon,
3278
+ ellipsis: hasEllipsis ? {
3279
+ showTitle: false
3280
+ // Disable default browser tooltip
3281
+ } : column.ellipsis,
3282
+ render: (value, record, index2) => {
3283
+ const renderedContent = originalRender ? originalRender(value, record, index2) : value;
3284
+ if (renderedContent == null) {
3285
+ return /* @__PURE__ */ jsx("span", { className: "text-j2-text-secondary", children: "--" });
3286
+ }
3287
+ const tooltipText = extractTextContent(renderedContent);
3288
+ if (tooltipText) {
3289
+ if (isSimpleValue(renderedContent)) {
3290
+ return /* @__PURE__ */ jsx(Tooltip$1, { title: tooltipText, arrow: false, children: /* @__PURE__ */ jsx("span", { className: hasEllipsis ? "block truncate" : void 0, children: renderedContent }) });
3291
+ }
3292
+ return /* @__PURE__ */ jsx(Tooltip$1, { title: tooltipText, arrow: false, children: /* @__PURE__ */ jsx("div", { children: renderedContent }) });
3293
+ }
3294
+ return renderedContent;
3295
+ }
3296
+ };
3297
+ });
3298
+ const paginationConfig = props.pagination ? withDesignSystemPaginationOverrides(
3299
+ typeof props.pagination === "object" ? props.pagination : {},
3300
+ {
3301
+ paginationTextLabels,
3302
+ isSmall: typeof props.pagination === "object" && props.pagination.size === "small" || props.size === "small"
3303
+ }
3304
+ ) : false;
3305
+ return /* @__PURE__ */ jsx(
3306
+ "div",
3307
+ {
3308
+ className: cx(props.className, {
3309
+ [s.bordered]: props.bordered && !verticalBorders,
3310
+ [s.alternatingRows]: alternatingRows2
3311
+ }),
3312
+ children: /* @__PURE__ */ jsx(
3313
+ Table$1,
3314
+ {
3315
+ showSorterTooltip: { target: "sorter-icon" },
3316
+ ...props,
3317
+ loading,
3318
+ columns,
3319
+ pagination: paginationConfig,
3320
+ rowKey: (record) => JSON.stringify(record),
3321
+ locale: {
3322
+ emptyText: /* @__PURE__ */ jsx(
3323
+ "div",
3324
+ {
3325
+ style: { height: ((_b = props.scroll) == null ? void 0 : _b.y) || 400, width: "content-fit" }
3326
+ }
3327
+ )
3328
+ }
3329
+ }
3330
+ )
3331
+ }
3332
+ );
3333
+ };
3334
+ const TableColumn = (props) => {
3335
+ return /* @__PURE__ */ jsx(Table$1.Column, { ...props, sortIcon: defaultSortIcon });
3336
+ };
3337
+ TableColumn.displayName = "Table.Column";
3338
+ Table.Column = TableColumn;
3339
+ Table.Summary = Table$1.Summary;
3340
+ const Tabs = (props) => {
3341
+ const destroyOnHidden = props.destroyOnHidden ?? true;
3342
+ return /* @__PURE__ */ jsx(Tabs$1, { ...props, destroyOnHidden });
3343
+ };
3344
+ const VennDiagram = ({ data, title, tooltip: tooltip2, onClick }) => {
3345
+ const { token } = theme.useToken();
3346
+ const baseFont = {
3347
+ fontSize: `${token.fontSize}px`,
3348
+ fontFamily: token.fontFamily,
3349
+ color: token.colorText,
3350
+ textOutline: "none",
3351
+ opacity: 1
3352
+ };
3353
+ const options = {
3354
+ title: {
3355
+ text: title
3356
+ },
3357
+ ...tooltip2 ? { tooltip: tooltip2 } : {},
3358
+ chart: {
3359
+ spacing: [36, 36, 36, 36]
3360
+ },
3361
+ series: [
3362
+ {
3363
+ type: "venn",
3364
+ data,
3365
+ events: {
3366
+ click: onClick
3367
+ },
3368
+ cursor: onClick ? "pointer" : void 0,
3369
+ dataLabels: {
3370
+ style: baseFont
3371
+ },
3372
+ states: {
3373
+ inactive: {
3374
+ opacity: 0.3
3375
+ }
3376
+ }
3377
+ }
3378
+ ]
3379
+ };
3380
+ return /* @__PURE__ */ jsx(Chart, { options });
3381
+ };
3382
+ const navContainer = "_navContainer_1eoor_2";
3383
+ const logoSection = "_logoSection_1eoor_14";
3384
+ const logoContainer = "_logoContainer_1eoor_18";
3385
+ const logoLink = "_logoLink_1eoor_25";
3386
+ const logo = "_logo_1eoor_14";
3387
+ const navContent = "_navContent_1eoor_46";
3388
+ const navSection = "_navSection_1eoor_54";
3389
+ const sectionHeader = "_sectionHeader_1eoor_59";
3390
+ const sectionTitle = "_sectionTitle_1eoor_63";
3391
+ const sectionItems = "_sectionItems_1eoor_73";
3392
+ const navItem = "_navItem_1eoor_79";
3393
+ const active = "_active_1eoor_96";
3394
+ const navItemIcon = "_navItemIcon_1eoor_100";
3395
+ const navItemLabel = "_navItemLabel_1eoor_115";
3396
+ const styles$1 = {
3397
+ navContainer,
3398
+ logoSection,
3399
+ logoContainer,
3400
+ logoLink,
3401
+ logo,
3402
+ navContent,
3403
+ navSection,
3404
+ sectionHeader,
3405
+ sectionTitle,
3406
+ sectionItems,
3407
+ navItem,
3408
+ active,
3409
+ navItemIcon,
3410
+ navItemLabel
3411
+ };
3412
+ const userSection = "_userSection_r06sp_2";
3413
+ const userProfile = "_userProfile_r06sp_7";
3414
+ const userAvatar = "_userAvatar_r06sp_24";
3415
+ const avatarImage = "_avatarImage_r06sp_38";
3416
+ const userName = "_userName_r06sp_44";
3417
+ const popover = "_popover_r06sp_55";
3418
+ const popoverUserInfo = "_popoverUserInfo_r06sp_78";
3419
+ const popoverAvatar = "_popoverAvatar_r06sp_86";
3420
+ const popoverUserName = "_popoverUserName_r06sp_105";
3421
+ const popoverActions = "_popoverActions_r06sp_113";
3422
+ const logOutButton = "_logOutButton_r06sp_138";
3423
+ const changeClientButton = "_changeClientButton_r06sp_143";
3424
+ const styles = {
3425
+ userSection,
3426
+ userProfile,
3427
+ userAvatar,
3428
+ avatarImage,
3429
+ userName,
3430
+ popover,
3431
+ popoverUserInfo,
3432
+ popoverAvatar,
3433
+ popoverUserName,
3434
+ popoverActions,
3435
+ logOutButton,
3436
+ changeClientButton
3437
+ };
3438
+ const UserProfile = ({
3439
+ firstName,
3440
+ lastName,
3441
+ avatarUrl,
3442
+ onLogOut,
3443
+ onChangeClient
3444
+ }) => {
3445
+ const [isPopoverOpen, setIsPopoverOpen] = useState(false);
3446
+ const popoverRef = useRef(null);
3447
+ const buttonRef = useRef(null);
3448
+ const displayName = lastName ? `${firstName} ${lastName}` : firstName;
3449
+ const avatarDisplay = avatarUrl ? /* @__PURE__ */ jsx("img", { src: avatarUrl, alt: displayName, className: styles.avatarImage }) : firstName.charAt(0).toUpperCase();
3450
+ const togglePopover = () => {
3451
+ setIsPopoverOpen(!isPopoverOpen);
3452
+ };
3453
+ useEffect(() => {
3454
+ const handleClickOutside = (event) => {
3455
+ if (popoverRef.current && !popoverRef.current.contains(event.target) && buttonRef.current && !buttonRef.current.contains(event.target)) {
3456
+ setIsPopoverOpen(false);
3457
+ }
3458
+ };
3459
+ document.addEventListener("mousedown", handleClickOutside);
3460
+ return () => {
3461
+ document.removeEventListener("mousedown", handleClickOutside);
3462
+ };
3463
+ }, []);
3464
+ return /* @__PURE__ */ jsxs("div", { className: styles.userSection, children: [
3465
+ /* @__PURE__ */ jsxs(
3466
+ "button",
3467
+ {
3468
+ ref: buttonRef,
3469
+ className: styles.userProfile,
3470
+ onClick: togglePopover,
3471
+ children: [
3472
+ /* @__PURE__ */ jsx("div", { className: styles.userAvatar, children: avatarDisplay }),
3473
+ /* @__PURE__ */ jsx("span", { className: styles.userName, children: displayName })
3474
+ ]
3475
+ }
3476
+ ),
3477
+ isPopoverOpen && /* @__PURE__ */ jsxs("div", { ref: popoverRef, className: styles.popover, children: [
3478
+ /* @__PURE__ */ jsxs("div", { className: styles.popoverUserInfo, children: [
3479
+ /* @__PURE__ */ jsx("div", { className: styles.popoverAvatar, children: avatarDisplay }),
3480
+ /* @__PURE__ */ jsx("span", { className: styles.popoverUserName, children: displayName })
3481
+ ] }),
3482
+ /* @__PURE__ */ jsxs("div", { className: styles.popoverActions, children: [
3483
+ /* @__PURE__ */ jsx(
3484
+ "button",
3485
+ {
3486
+ className: styles.logOutButton,
3487
+ onClick: () => {
3488
+ onLogOut == null ? void 0 : onLogOut();
3489
+ setIsPopoverOpen(false);
3490
+ },
3491
+ children: "LOG OUT"
3492
+ }
3493
+ ),
3494
+ onChangeClient && /* @__PURE__ */ jsx(
3495
+ "button",
3496
+ {
3497
+ className: styles.changeClientButton,
3498
+ onClick: () => {
3499
+ onChangeClient == null ? void 0 : onChangeClient();
3500
+ setIsPopoverOpen(false);
3501
+ },
3502
+ children: "CHANGE CLIENT"
3503
+ }
3504
+ )
3505
+ ] })
3506
+ ] })
3507
+ ] });
3508
+ };
3509
+ const LegacyNavMenu = ({
3510
+ sections,
3511
+ user,
3512
+ onItemClick,
3513
+ logoUrl = "/",
3514
+ onLogOut,
3515
+ onChangeClient,
3516
+ headerSlot,
3517
+ footerSlot
3518
+ }) => {
3519
+ const handleItemClick = (itemId) => {
3520
+ onItemClick == null ? void 0 : onItemClick(itemId);
3521
+ };
3522
+ return /* @__PURE__ */ jsxs("div", { className: styles$1.navContainer, children: [
3523
+ /* @__PURE__ */ jsx("div", { className: styles$1.logoSection, children: /* @__PURE__ */ jsx("div", { className: styles$1.logoContainer, children: /* @__PURE__ */ jsx("a", { href: logoUrl, className: styles$1.logoLink, children: /* @__PURE__ */ jsx(SvgJ2LogoMenuCollapse, { className: styles$1.logo }) }) }) }),
3524
+ headerSlot && /* @__PURE__ */ jsx("div", { className: "px-4", children: headerSlot }),
3525
+ /* @__PURE__ */ jsx("div", { className: styles$1.navContent, children: sections.map((section) => /* @__PURE__ */ jsxs("div", { className: styles$1.navSection, children: [
3526
+ /* @__PURE__ */ jsx("div", { className: styles$1.sectionHeader, children: /* @__PURE__ */ jsx("span", { className: styles$1.sectionTitle, children: section.title }) }),
3527
+ /* @__PURE__ */ jsx("div", { className: styles$1.sectionItems, children: section.items.map((item) => /* @__PURE__ */ jsxs(
3528
+ "button",
3529
+ {
3530
+ className: `${styles$1.navItem} ${item.isActive ? styles$1.active : ""}`,
3531
+ onClick: () => handleItemClick(item.id),
3532
+ children: [
3533
+ item.icon && /* @__PURE__ */ jsx("div", { className: styles$1.navItemIcon, children: item.icon }),
3534
+ /* @__PURE__ */ jsx("span", { className: styles$1.navItemLabel, children: item.label })
3535
+ ]
3536
+ },
3537
+ item.id
3538
+ )) })
3539
+ ] }, section.title)) }),
3540
+ footerSlot && /* @__PURE__ */ jsx("div", { className: "px-4", children: footerSlot }),
3541
+ /* @__PURE__ */ jsx(
3542
+ UserProfile,
3543
+ {
3544
+ firstName: user.firstName,
3545
+ lastName: user.lastName,
3546
+ avatarUrl: user.avatarUrl,
3547
+ onLogOut,
3548
+ onChangeClient
3549
+ }
3550
+ )
3551
+ ] });
3552
+ };
3553
+ export {
3554
+ Alert,
3555
+ AntdInput,
3556
+ AntdSearchInput,
3557
+ AntdSelect,
3558
+ AppConfigProvider,
3559
+ BarChart,
3560
+ Breadcrumb,
3561
+ BulkActionBar,
3562
+ Button,
3563
+ Card,
3564
+ Checkbox,
3565
+ CheckboxTree,
3566
+ Collapse,
3567
+ Drawer,
3568
+ Dropdown,
3569
+ FiltersForm,
3570
+ Form,
3571
+ Chart2 as HighchartsReact,
3572
+ Input,
3573
+ InputNumber,
3574
+ LegacyNavMenu,
3575
+ ListPopover,
3576
+ Menu,
3577
+ Modal,
3578
+ NavMenu,
3579
+ NotificationModal,
3580
+ Pagination,
3581
+ Popover,
3582
+ Progress,
3583
+ Radio,
3584
+ RadioGroup,
3585
+ Rate,
3586
+ Select,
3587
+ Skeleton,
3588
+ Spinner,
3589
+ Steps,
3590
+ SummarizedSelect,
3591
+ Switch,
3592
+ Table,
3593
+ Tabs,
3594
+ Tag,
3595
+ Tooltip,
3596
+ UserProfile,
3597
+ VennDiagram,
3598
+ appTheme,
3599
+ index as icons,
3600
+ tailwindPreset,
3601
+ useMessage,
3602
+ useNotification,
3603
+ useSteps,
3604
+ withDesignSystemPaginationOverrides
3605
+ };
3606
+ //# sourceMappingURL=index.js.map