@godxjp/ui 5.0.2 → 6.0.1

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 (242) hide show
  1. package/README.md +101 -142
  2. package/dist/app/index.d.ts +140 -0
  3. package/dist/app/index.js +38 -0
  4. package/dist/app.prop-IobwLwaM.d.ts +90 -0
  5. package/dist/checkbox-NkFkqsQ8.d.ts +13 -0
  6. package/dist/chunk-2XW7J3EI.js +226 -0
  7. package/dist/chunk-3F2AKYRD.js +416 -0
  8. package/dist/chunk-3KPEZ5CF.js +37 -0
  9. package/dist/chunk-3UGU5TYP.js +89 -0
  10. package/dist/chunk-6RA3KSVK.js +588 -0
  11. package/dist/chunk-7NZFVD24.js +122 -0
  12. package/dist/chunk-7PWBC4BY.js +25 -0
  13. package/dist/chunk-7S7MYFXE.js +61 -0
  14. package/dist/chunk-7WRZG2IG.js +71 -0
  15. package/dist/chunk-B775Y6BE.js +1 -0
  16. package/dist/chunk-BHV2FUOA.js +111 -0
  17. package/dist/chunk-BI3HERR7.js +70 -0
  18. package/dist/chunk-BPSKQUL2.js +68 -0
  19. package/dist/chunk-CDWPQ5RP.js +187 -0
  20. package/dist/chunk-CP2LET6N.js +244 -0
  21. package/dist/chunk-CQBADMFG.js +20 -0
  22. package/dist/chunk-CRERCLIZ.js +33 -0
  23. package/dist/chunk-DU6ZYZRP.js +238 -0
  24. package/dist/chunk-DY5C44UP.js +55 -0
  25. package/dist/chunk-E4HJNQ62.js +117 -0
  26. package/dist/chunk-E76QIYSY.js +93 -0
  27. package/dist/chunk-F7PG4OEV.js +37 -0
  28. package/dist/chunk-GDSVW62T.js +171 -0
  29. package/dist/chunk-H2FHJOLU.js +178 -0
  30. package/dist/chunk-HJEBRCXL.js +55 -0
  31. package/dist/chunk-ICM6XBST.js +16 -0
  32. package/dist/chunk-IK7I3ABN.js +88 -0
  33. package/dist/chunk-L6J44O74.js +144 -0
  34. package/dist/chunk-LDSLS6HE.js +1 -0
  35. package/dist/chunk-LVNUHUEZ.js +191 -0
  36. package/dist/chunk-M64MVRLS.js +92 -0
  37. package/dist/chunk-NGQW3KEM.js +402 -0
  38. package/dist/chunk-NZ4FOC5N.js +559 -0
  39. package/dist/chunk-PIIRNAXA.js +26 -0
  40. package/dist/chunk-S66TJXJU.js +33 -0
  41. package/dist/chunk-SMLKNECP.js +133 -0
  42. package/dist/chunk-TAHBM3F2.js +66 -0
  43. package/dist/chunk-TO33OY4L.js +150 -0
  44. package/dist/chunk-TO7URV7U.js +51 -0
  45. package/dist/chunk-TOO5AEKL.js +81 -0
  46. package/dist/chunk-U3GHAOIJ.js +299 -0
  47. package/dist/chunk-U7N2A7A3.js +9 -0
  48. package/dist/chunk-UX634MYF.js +123 -0
  49. package/dist/chunk-V6UWJKZF.js +28 -0
  50. package/dist/chunk-VOHTRR5X.js +28 -0
  51. package/dist/chunk-WRFKVUPW.js +332 -0
  52. package/dist/chunk-WXW43RK5.js +24 -0
  53. package/dist/chunk-XG7XDYIM.js +60 -0
  54. package/dist/chunk-YFCQKO3B.js +842 -0
  55. package/dist/chunk-ZDWXGWLY.js +73 -0
  56. package/dist/chunk-ZLK5SPT6.js +11 -0
  57. package/dist/chunk-ZS6DTAM2.js +31 -0
  58. package/dist/chunk-ZT5UEUBO.js +1 -0
  59. package/dist/components/admin/index.d.ts +80 -0
  60. package/dist/components/admin/index.js +38 -0
  61. package/dist/components/data-display/badge.d.ts +12 -0
  62. package/dist/components/data-display/badge.js +3 -0
  63. package/dist/components/data-display/card.d.ts +87 -0
  64. package/dist/components/data-display/card.js +2 -0
  65. package/dist/components/data-display/index.d.ts +72 -0
  66. package/dist/components/data-display/index.js +89 -0
  67. package/dist/components/data-display/popover.d.ts +13 -0
  68. package/dist/components/data-display/popover.js +2 -0
  69. package/dist/components/data-display/scroll-area.d.ts +7 -0
  70. package/dist/components/data-display/scroll-area.js +2 -0
  71. package/dist/components/data-display/table.d.ts +10 -0
  72. package/dist/components/data-display/table.js +3 -0
  73. package/dist/components/data-entry/autocomplete.d.ts +16 -0
  74. package/dist/components/data-entry/autocomplete.js +8 -0
  75. package/dist/components/data-entry/calendar.d.ts +16 -0
  76. package/dist/components/data-entry/calendar.js +4 -0
  77. package/dist/components/data-entry/cascader.d.ts +32 -0
  78. package/dist/components/data-entry/cascader.js +13 -0
  79. package/dist/components/data-entry/checkbox.d.ts +13 -0
  80. package/dist/components/data-entry/checkbox.js +4 -0
  81. package/dist/components/data-entry/color-picker.d.ts +16 -0
  82. package/dist/components/data-entry/color-picker.js +6 -0
  83. package/dist/components/data-entry/command.d.ts +69 -0
  84. package/dist/components/data-entry/command.js +3 -0
  85. package/dist/components/data-entry/date-picker.d.ts +16 -0
  86. package/dist/components/data-entry/date-picker.js +8 -0
  87. package/dist/components/data-entry/date-range-picker.d.ts +16 -0
  88. package/dist/components/data-entry/date-range-picker.js +8 -0
  89. package/dist/components/data-entry/index.d.ts +53 -0
  90. package/dist/components/data-entry/index.js +152 -0
  91. package/dist/components/data-entry/input.d.ts +6 -0
  92. package/dist/components/data-entry/input.js +2 -0
  93. package/dist/components/data-entry/label.d.ts +8 -0
  94. package/dist/components/data-entry/label.js +2 -0
  95. package/dist/components/data-entry/radio.d.ts +24 -0
  96. package/dist/components/data-entry/radio.js +4 -0
  97. package/dist/components/data-entry/select.d.ts +18 -0
  98. package/dist/components/data-entry/select.js +3 -0
  99. package/dist/components/data-entry/slider.d.ts +16 -0
  100. package/dist/components/data-entry/slider.js +2 -0
  101. package/dist/components/data-entry/switch.d.ts +17 -0
  102. package/dist/components/data-entry/switch.js +2 -0
  103. package/dist/components/data-entry/textarea.d.ts +6 -0
  104. package/dist/components/data-entry/textarea.js +3 -0
  105. package/dist/components/data-entry/time-picker.d.ts +16 -0
  106. package/dist/components/data-entry/time-picker.js +7 -0
  107. package/dist/components/data-entry/transfer.d.ts +17 -0
  108. package/dist/components/data-entry/transfer.js +11 -0
  109. package/dist/components/data-entry/tree-select.d.ts +26 -0
  110. package/dist/components/data-entry/tree-select.js +13 -0
  111. package/dist/components/data-entry/upload.d.ts +42 -0
  112. package/dist/components/data-entry/upload.js +11 -0
  113. package/dist/components/feedback/alert.d.ts +60 -0
  114. package/dist/components/feedback/alert.js +7 -0
  115. package/dist/components/feedback/dialog.d.ts +64 -0
  116. package/dist/components/feedback/dialog.js +7 -0
  117. package/dist/components/feedback/index.d.ts +16 -0
  118. package/dist/components/feedback/index.js +14 -0
  119. package/dist/components/feedback/sheet.d.ts +24 -0
  120. package/dist/components/feedback/sheet.js +2 -0
  121. package/dist/components/feedback/sonner.d.ts +6 -0
  122. package/dist/components/feedback/sonner.js +1 -0
  123. package/dist/components/general/button.d.ts +20 -0
  124. package/dist/components/general/button.js +2 -0
  125. package/dist/components/general/index.d.ts +6 -0
  126. package/dist/components/general/index.js +2 -0
  127. package/dist/components/layout/index.d.ts +71 -0
  128. package/dist/components/layout/index.js +5 -0
  129. package/dist/components/navigation/dropdown-menu.d.ts +28 -0
  130. package/dist/components/navigation/dropdown-menu.js +2 -0
  131. package/dist/components/navigation/index.d.ts +32 -0
  132. package/dist/components/navigation/index.js +12 -0
  133. package/dist/components/navigation/pagination.d.ts +11 -0
  134. package/dist/components/navigation/pagination.js +7 -0
  135. package/dist/components/navigation/steps.d.ts +12 -0
  136. package/dist/components/navigation/steps.js +3 -0
  137. package/dist/components/navigation/tabs-items.d.ts +12 -0
  138. package/dist/components/navigation/tabs-items.js +3 -0
  139. package/dist/components/navigation/tabs.d.ts +12 -0
  140. package/dist/components/navigation/tabs.js +2 -0
  141. package/dist/components/query/index.d.ts +43 -0
  142. package/dist/components/query/index.js +8 -0
  143. package/dist/components/ui/index.d.ts +57 -0
  144. package/dist/components/ui/index.js +37 -0
  145. package/dist/content.prop-D1Dd3TAc.d.ts +31 -0
  146. package/dist/data-display.prop-DNTAzmDy.d.ts +58 -0
  147. package/dist/data-entry.prop-BEGA1lTq.d.ts +323 -0
  148. package/dist/data-table-D1u_rKLK.d.ts +83 -0
  149. package/dist/data.prop-BVvfKC_g.d.ts +41 -0
  150. package/dist/feedback.prop-BmxUlpAW.d.ts +64 -0
  151. package/dist/filter-bar-B7OGFO9S.d.ts +10 -0
  152. package/dist/form/index.d.ts +21 -0
  153. package/dist/form/index.js +4 -0
  154. package/dist/form.prop-BHgpuFFm.d.ts +41 -0
  155. package/dist/format-date-ByyZoqI5.d.ts +51 -0
  156. package/dist/general.prop-D7brMPNL.d.ts +16 -0
  157. package/dist/i18n/index.d.ts +217 -0
  158. package/dist/i18n/index.js +2 -0
  159. package/dist/index.d.ts +46 -26
  160. package/dist/index.js +39 -13062
  161. package/dist/inline-C5u6ptJV.d.ts +10 -0
  162. package/dist/interaction.prop-Cdn7wOtq.d.ts +25 -0
  163. package/dist/layout.prop-4TCNvyQZ.d.ts +20 -0
  164. package/dist/layout.prop-C795F0qg.d.ts +112 -0
  165. package/dist/lib/datetime/index.d.ts +31 -0
  166. package/dist/lib/datetime/index.js +1 -0
  167. package/dist/lib/utils.d.ts +5 -0
  168. package/dist/lib/utils.js +1 -0
  169. package/dist/navigation.prop-DpZqcXey.d.ts +78 -0
  170. package/dist/navigation.prop-DxBiClEH.d.ts +20 -0
  171. package/dist/props/components/index.d.ts +27 -0
  172. package/dist/props/components/index.js +1 -0
  173. package/dist/props/index.d.ts +28 -0
  174. package/dist/props/index.js +3 -0
  175. package/dist/props/registry.d.ts +649 -0
  176. package/dist/props/registry.js +1 -0
  177. package/dist/props/vocabulary/index.d.ts +7 -0
  178. package/dist/props/vocabulary/index.js +1 -0
  179. package/dist/query.prop-hIPrk2zI.d.ts +71 -0
  180. package/dist/search-input-uP01rY1L.d.ts +22 -0
  181. package/dist/shared.prop-BNRJc9K0.d.ts +45 -0
  182. package/dist/styles/alert-layout.css +191 -0
  183. package/dist/styles/badge-layout.css +22 -0
  184. package/dist/styles/card-layout.css +373 -0
  185. package/dist/styles/control.css +504 -0
  186. package/dist/styles/data-display-layout.css +246 -0
  187. package/dist/styles/density.css +43 -0
  188. package/dist/styles/dialog-layout.css +84 -0
  189. package/dist/styles/index.css +105 -0
  190. package/dist/styles/layout.css +479 -0
  191. package/dist/styles/shell-layout.css +604 -0
  192. package/dist/styles/table-layout.css +109 -0
  193. package/dist/theme/example.service.css +37 -0
  194. package/dist/tokens/base.css +13 -0
  195. package/dist/tokens/foundation.css +151 -0
  196. package/dist/tokens/primitives/badge.css +13 -0
  197. package/dist/tokens/primitives/card.css +29 -0
  198. package/dist/tokens/primitives/control.css +55 -0
  199. package/dist/tokens/primitives/feedback.css +17 -0
  200. package/dist/tokens/primitives/layout.css +20 -0
  201. package/dist/tokens/primitives/navigation.css +13 -0
  202. package/dist/tokens/primitives/table.css +10 -0
  203. package/dist/types-mvzYGrma.d.ts +37 -0
  204. package/dist/use-toast-Dol5bdY3.d.ts +34 -0
  205. package/package.json +279 -117
  206. package/scripts/ui-audit.mjs +179 -0
  207. package/BRAND.md +0 -296
  208. package/CHANGELOG.md +0 -668
  209. package/config/eslint.js +0 -54
  210. package/config/prettier.cjs +0 -20
  211. package/config/tsconfig.base.json +0 -22
  212. package/config/vitest.base.ts +0 -26
  213. package/dist/MiniMonth-YAmPGEpC.d.ts +0 -143
  214. package/dist/Table.types-BbsxoIYE.d.ts +0 -352
  215. package/dist/color-DO0qqUAb.d.ts +0 -38
  216. package/dist/components/composites.d.ts +0 -963
  217. package/dist/components/composites.js +0 -7343
  218. package/dist/components/composites.js.map +0 -1
  219. package/dist/components/primitives.d.ts +0 -2744
  220. package/dist/components/primitives.js +0 -7356
  221. package/dist/components/primitives.js.map +0 -1
  222. package/dist/components/shell.d.ts +0 -182
  223. package/dist/components/shell.js +0 -774
  224. package/dist/components/shell.js.map +0 -1
  225. package/dist/hooks.d.ts +0 -100
  226. package/dist/hooks.js +0 -558
  227. package/dist/hooks.js.map +0 -1
  228. package/dist/i18n.d.ts +0 -61
  229. package/dist/i18n.js +0 -860
  230. package/dist/i18n.js.map +0 -1
  231. package/dist/index.js.map +0 -1
  232. package/dist/padding-DY0JV5Ja.d.ts +0 -16
  233. package/dist/preferences.d.ts +0 -132
  234. package/dist/preferences.js +0 -262
  235. package/dist/preferences.js.map +0 -1
  236. package/dist/props.d.ts +0 -86
  237. package/dist/props.js +0 -16
  238. package/dist/props.js.map +0 -1
  239. package/dist/size-CQwNvOWd.d.ts +0 -19
  240. package/dist/types-LTj-2bl-.d.ts +0 -30
  241. package/dist/useTableViews-D5NIAJ7h.d.ts +0 -154
  242. package/src/tokens/tailwind.css +0 -158
@@ -0,0 +1,226 @@
1
+ import { normalizeTreeOptions, collectAllExpandableKeys, filterVisibleTree, flattenVisibleTree, findNodeByValue, reactNodeText, getDescendantValues } from './chunk-SMLKNECP.js';
2
+ import { Checkbox } from './chunk-E76QIYSY.js';
3
+ import { Command, CommandInput } from './chunk-V6UWJKZF.js';
4
+ import { Popover, PopoverTrigger, PopoverContent } from './chunk-DY5C44UP.js';
5
+ import { ScrollArea } from './chunk-3KPEZ5CF.js';
6
+ import { Button } from './chunk-HJEBRCXL.js';
7
+ import { useTranslation } from './chunk-3F2AKYRD.js';
8
+ import { cn } from './chunk-U7N2A7A3.js';
9
+ import * as React from 'react';
10
+ import { X, ChevronsUpDown, ChevronDown, ChevronRight } from 'lucide-react';
11
+ import { jsxs, jsx } from 'react/jsx-runtime';
12
+
13
+ // src/components/data-entry/tree-select-strategy.ts
14
+ var SHOW_CHILD = "SHOW_CHILD";
15
+ var SHOW_PARENT = "SHOW_PARENT";
16
+ var SHOW_ALL = "SHOW_ALL";
17
+ function toArray(value) {
18
+ if (value == null) return [];
19
+ return Array.isArray(value) ? value : [value];
20
+ }
21
+ function displayValues(values, options, showCheckedStrategy, treeCheckStrictly) {
22
+ if (treeCheckStrictly || showCheckedStrategy === SHOW_ALL) return values;
23
+ if (showCheckedStrategy === SHOW_PARENT) {
24
+ const filtered = values.filter((v) => {
25
+ const node = findNodeByValue(options, v);
26
+ if (!node?.children?.length) return true;
27
+ const desc = getDescendantValues(node).slice(1);
28
+ return !desc.every((d) => values.includes(d));
29
+ });
30
+ return filtered.length ? filtered : values;
31
+ }
32
+ return values.filter((v) => {
33
+ const node = findNodeByValue(options, v);
34
+ return !node?.children?.length;
35
+ });
36
+ }
37
+ function TreeSelectRoot({
38
+ treeData: treeDataProp,
39
+ value,
40
+ defaultValue,
41
+ onChange,
42
+ multiple,
43
+ treeCheckable,
44
+ treeCheckStrictly,
45
+ showSearch,
46
+ showCheckedStrategy = SHOW_CHILD,
47
+ treeDefaultExpandAll,
48
+ placeholder,
49
+ disabled,
50
+ allowClear = true,
51
+ className,
52
+ id,
53
+ fieldNames
54
+ }) {
55
+ const { t } = useTranslation();
56
+ const options = React.useMemo(
57
+ () => normalizeTreeOptions(treeDataProp, fieldNames),
58
+ [treeDataProp, fieldNames]
59
+ );
60
+ const checkable = treeCheckable ?? multiple;
61
+ const [open, setOpen] = React.useState(false);
62
+ const [search, setSearch] = React.useState("");
63
+ const [expandedKeys, setExpandedKeys] = React.useState(
64
+ () => new Set(treeDefaultExpandAll ? collectAllExpandableKeys(options) : [])
65
+ );
66
+ const isControlled = value !== void 0;
67
+ const [internal, setInternal] = React.useState(() => toArray(defaultValue));
68
+ const selected = isControlled ? toArray(value) : internal;
69
+ const resolvedPlaceholder = placeholder ?? t("dataEntry.treeSelect.placeholder");
70
+ const visible = React.useMemo(() => {
71
+ if (showSearch && search.trim()) return filterVisibleTree(options, search);
72
+ return flattenVisibleTree(options, expandedKeys);
73
+ }, [options, expandedKeys, search, showSearch]);
74
+ const commit = (next) => {
75
+ if (!isControlled) setInternal(next);
76
+ onChange?.(checkable || multiple ? next : next[0] ?? void 0);
77
+ };
78
+ const toggleExpand = (key) => {
79
+ setExpandedKeys((prev) => {
80
+ const next = new Set(prev);
81
+ if (next.has(key)) next.delete(key);
82
+ else next.add(key);
83
+ return next;
84
+ });
85
+ };
86
+ const toggleSelect = (node) => {
87
+ if (node.disabled) return;
88
+ const key = node.value;
89
+ if (!checkable && !multiple) {
90
+ commit([key]);
91
+ setOpen(false);
92
+ return;
93
+ }
94
+ const isOn = selected.includes(key);
95
+ let next;
96
+ if (treeCheckStrictly) {
97
+ next = isOn ? selected.filter((v) => v !== key) : [...selected, key];
98
+ } else {
99
+ const related = getDescendantValues(node);
100
+ next = isOn ? selected.filter((v) => !related.includes(v)) : [.../* @__PURE__ */ new Set([...selected, ...related])];
101
+ }
102
+ commit(next);
103
+ };
104
+ const displayKeys = displayValues(selected, options, showCheckedStrategy, treeCheckStrictly);
105
+ const displayLabel = displayKeys.map((v) => {
106
+ const label = findNodeByValue(options, v)?.label;
107
+ return label ? reactNodeText(label) : v;
108
+ }).join(", ");
109
+ const clearValue = (e) => {
110
+ e.stopPropagation();
111
+ commit([]);
112
+ };
113
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
114
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
115
+ Button,
116
+ {
117
+ id,
118
+ type: "button",
119
+ variant: "outline",
120
+ role: "combobox",
121
+ "aria-expanded": open,
122
+ disabled,
123
+ className: cn(
124
+ "w-full justify-between font-normal",
125
+ !displayKeys.length && "text-muted-foreground",
126
+ className
127
+ ),
128
+ children: [
129
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: displayKeys.length ? displayLabel : resolvedPlaceholder }),
130
+ /* @__PURE__ */ jsxs("span", { className: "ml-2 flex shrink-0 items-center gap-1", children: [
131
+ allowClear && displayKeys.length > 0 && !disabled && /* @__PURE__ */ jsx(
132
+ X,
133
+ {
134
+ className: "size-4 opacity-50 hover:opacity-100",
135
+ "aria-hidden": "true",
136
+ onClick: clearValue
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsx(ChevronsUpDown, { className: "size-4 opacity-50", "aria-hidden": "true" })
140
+ ] })
141
+ ]
142
+ }
143
+ ) }),
144
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: [
145
+ showSearch && /* @__PURE__ */ jsx("div", { className: "border-b p-2", children: /* @__PURE__ */ jsx(Command, { shouldFilter: false, children: /* @__PURE__ */ jsx(
146
+ CommandInput,
147
+ {
148
+ placeholder: t("dataEntry.treeSelect.searchPlaceholder"),
149
+ value: search,
150
+ onValueChange: setSearch
151
+ }
152
+ ) }) }),
153
+ /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-[min(300px,50vh)]", children: /* @__PURE__ */ jsx(
154
+ "div",
155
+ {
156
+ role: "tree",
157
+ "aria-multiselectable": Boolean(checkable) || Boolean(multiple),
158
+ className: "p-1",
159
+ children: visible.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground py-6 text-center text-sm", children: t("dataEntry.treeSelect.empty") }) : visible.map(({ node, depth, hasChildren }) => {
160
+ const expanded = expandedKeys.has(node.value);
161
+ const isSelected = selected.includes(node.value);
162
+ return /* @__PURE__ */ jsxs(
163
+ "div",
164
+ {
165
+ role: "treeitem",
166
+ "aria-expanded": hasChildren ? expanded : void 0,
167
+ "aria-selected": isSelected,
168
+ className: cn(
169
+ "flex items-center rounded-sm py-1.5 pr-2 text-sm outline-none",
170
+ "hover:bg-accent hover:text-accent-foreground",
171
+ isSelected && "bg-accent/60",
172
+ node.disabled && "pointer-events-none opacity-50"
173
+ ),
174
+ style: { paddingLeft: `${depth * 1.25 + 0.5}rem` },
175
+ children: [
176
+ /* @__PURE__ */ jsx(
177
+ "button",
178
+ {
179
+ type: "button",
180
+ tabIndex: -1,
181
+ "aria-label": expanded ? t("dataEntry.treeSelect.collapse") : t("dataEntry.treeSelect.expand"),
182
+ className: cn(
183
+ "mr-1 flex size-5 shrink-0 items-center justify-center rounded-sm",
184
+ !hasChildren && "invisible"
185
+ ),
186
+ onClick: () => toggleExpand(node.value),
187
+ children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "size-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "size-4", "aria-hidden": "true" })
188
+ }
189
+ ),
190
+ checkable ? /* @__PURE__ */ jsxs("label", { className: "flex flex-1 cursor-pointer items-center gap-2", children: [
191
+ /* @__PURE__ */ jsx(
192
+ Checkbox,
193
+ {
194
+ checked: isSelected,
195
+ disabled: Boolean(node.disabled) || Boolean(node.disableCheckbox),
196
+ onCheckedChange: () => toggleSelect(node)
197
+ }
198
+ ),
199
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: node.label })
200
+ ] }) : /* @__PURE__ */ jsx(
201
+ "button",
202
+ {
203
+ type: "button",
204
+ className: "flex-1 truncate text-left",
205
+ disabled: node.disabled,
206
+ onClick: () => toggleSelect(node),
207
+ children: node.label
208
+ }
209
+ )
210
+ ]
211
+ },
212
+ node.value
213
+ );
214
+ })
215
+ }
216
+ ) })
217
+ ] })
218
+ ] });
219
+ }
220
+ var TreeSelect = Object.assign(TreeSelectRoot, {
221
+ SHOW_CHILD,
222
+ SHOW_PARENT,
223
+ SHOW_ALL
224
+ });
225
+
226
+ export { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeSelect };
@@ -0,0 +1,416 @@
1
+ import { APP_TIME_FORMATS, isAppDateFormat, isAppTimeFormat, isAppLocale, translate, syncI18nLocale, syncDatetimeContext, getDateFnsLocale, getDayPickerLocale, APP_REQUEST_HEADER_DATE_FORMAT, APP_REQUEST_HEADER_TIME_FORMAT, resolveDefaultDateFormat } from './chunk-YFCQKO3B.js';
2
+ import * as React from 'react';
3
+ import { useMemo } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ // src/app/types.ts
7
+ var APP_LOCALES = ["vi", "en", "ja"];
8
+ var APP_REQUEST_HEADER_LOCALE = "x-locale";
9
+ var APP_REQUEST_HEADER_TIMEZONE = "x-timezone";
10
+
11
+ // src/app/request-headers.ts
12
+ var DEFAULT_HEADERS = {
13
+ [APP_REQUEST_HEADER_LOCALE]: "vi",
14
+ [APP_REQUEST_HEADER_TIMEZONE]: "Asia/Ho_Chi_Minh",
15
+ [APP_REQUEST_HEADER_TIME_FORMAT]: "24h",
16
+ [APP_REQUEST_HEADER_DATE_FORMAT]: "dmy"
17
+ };
18
+ var currentHeaders = { ...DEFAULT_HEADERS };
19
+ function syncAppRequestHeaders(headers) {
20
+ currentHeaders = { ...currentHeaders, ...headers };
21
+ }
22
+ function getAppRequestHeaders() {
23
+ return { ...currentHeaders };
24
+ }
25
+ function resetAppRequestHeaders() {
26
+ currentHeaders = { ...DEFAULT_HEADERS };
27
+ }
28
+
29
+ // src/app/storage.ts
30
+ var DEFAULT_STORAGE_KEY = "godxjp.app";
31
+ function readStoredPreferences(storageKey) {
32
+ if (typeof window === "undefined") return {};
33
+ try {
34
+ const raw = window.localStorage.getItem(storageKey);
35
+ if (!raw) return {};
36
+ const parsed = JSON.parse(raw);
37
+ return {
38
+ locale: isAppLocale(parsed.locale) ? parsed.locale : void 0,
39
+ timezone: typeof parsed.timezone === "string" ? parsed.timezone : void 0,
40
+ timeFormat: isAppTimeFormat(parsed.timeFormat) ? parsed.timeFormat : void 0,
41
+ dateFormat: isAppDateFormat(parsed.dateFormat) ? parsed.dateFormat : void 0
42
+ };
43
+ } catch {
44
+ return {};
45
+ }
46
+ }
47
+ function writeStoredPreferences(storageKey, preferences) {
48
+ if (typeof window === "undefined") return;
49
+ try {
50
+ window.localStorage.setItem(storageKey, JSON.stringify(preferences));
51
+ } catch {
52
+ }
53
+ }
54
+
55
+ // src/app/time-format-labels.ts
56
+ var APP_TIME_FORMAT_OPTIONS = APP_TIME_FORMATS.map((value) => ({ value }));
57
+ function getTimeFormatLabel(timeFormat, locale, fallbackLocale = "en") {
58
+ return translate(locale, fallbackLocale, `timeFormat.${timeFormat}`);
59
+ }
60
+ function resolveDefaultTimeFormat(locale) {
61
+ return locale === "en" ? "12h" : "24h";
62
+ }
63
+
64
+ // src/app/timezones.ts
65
+ var APP_TIMEZONE_PRESET = [
66
+ "UTC",
67
+ "Asia/Ho_Chi_Minh",
68
+ "Asia/Bangkok",
69
+ "Asia/Singapore",
70
+ "Asia/Jakarta",
71
+ "Asia/Manila",
72
+ "Asia/Kuala_Lumpur",
73
+ "Asia/Yangon",
74
+ "Asia/Phnom_Penh",
75
+ "Asia/Vientiane",
76
+ "Asia/Brunei",
77
+ "Asia/Tokyo",
78
+ "Asia/Seoul",
79
+ "Asia/Shanghai",
80
+ "Asia/Hong_Kong",
81
+ "Asia/Taipei",
82
+ "Asia/Ulaanbaatar",
83
+ "Asia/Kolkata",
84
+ "Asia/Karachi",
85
+ "Asia/Dhaka",
86
+ "Asia/Colombo",
87
+ "Asia/Dubai",
88
+ "Asia/Riyadh",
89
+ "Asia/Qatar",
90
+ "Asia/Tehran",
91
+ "Asia/Jerusalem",
92
+ "Europe/London",
93
+ "Europe/Paris",
94
+ "Europe/Berlin",
95
+ "Europe/Amsterdam",
96
+ "Europe/Rome",
97
+ "Europe/Madrid",
98
+ "Europe/Moscow",
99
+ "Europe/Istanbul",
100
+ "America/New_York",
101
+ "America/Chicago",
102
+ "America/Denver",
103
+ "America/Los_Angeles",
104
+ "America/Toronto",
105
+ "America/Vancouver",
106
+ "America/Mexico_City",
107
+ "America/Sao_Paulo",
108
+ "America/Buenos_Aires",
109
+ "Australia/Sydney",
110
+ "Australia/Melbourne",
111
+ "Australia/Perth",
112
+ "Pacific/Auckland"
113
+ ];
114
+ var APP_TIMEZONE_OPTIONS = APP_TIMEZONE_PRESET;
115
+ var TIMEZONE_ALIASES = {
116
+ "Asia/Ho_Chi_Minh": "Asia/Saigon"
117
+ };
118
+ var PREFERRED_TIMEZONE_IDS = Object.keys(TIMEZONE_ALIASES);
119
+ function resolveTimezoneForIntl(timezone) {
120
+ return TIMEZONE_ALIASES[timezone] ?? timezone;
121
+ }
122
+ var FALLBACK_IANA_TIMEZONES = [...APP_TIMEZONE_PRESET];
123
+ var cachedAllTimezones = null;
124
+ var cachedTimezoneSet = null;
125
+ function enrichTimezoneList(base) {
126
+ const set = new Set(base);
127
+ for (const preferred of PREFERRED_TIMEZONE_IDS) {
128
+ if (!set.has(preferred)) {
129
+ const canonical = TIMEZONE_ALIASES[preferred];
130
+ if (!canonical || set.has(canonical)) set.add(preferred);
131
+ }
132
+ }
133
+ return [...set].sort();
134
+ }
135
+ function getAllIanaTimezones() {
136
+ if (cachedAllTimezones) return cachedAllTimezones;
137
+ try {
138
+ const intl = Intl;
139
+ if (typeof intl.supportedValuesOf === "function") {
140
+ cachedAllTimezones = enrichTimezoneList(intl.supportedValuesOf("timeZone").slice().sort());
141
+ return cachedAllTimezones;
142
+ }
143
+ } catch {
144
+ }
145
+ cachedAllTimezones = FALLBACK_IANA_TIMEZONES;
146
+ return cachedAllTimezones;
147
+ }
148
+ function getIanaTimezoneSet() {
149
+ cachedTimezoneSet ??= new Set(getAllIanaTimezones());
150
+ return cachedTimezoneSet;
151
+ }
152
+ function isValidIanaTimezone(value) {
153
+ const set = getIanaTimezoneSet();
154
+ if (set.has(value)) return true;
155
+ const canonical = TIMEZONE_ALIASES[value];
156
+ return canonical ? set.has(canonical) : false;
157
+ }
158
+ function isKnownAppTimezone(value) {
159
+ return APP_TIMEZONE_PRESET.includes(value);
160
+ }
161
+ function resolveTimezonePickerOptions(configured, current) {
162
+ const base = configured && configured.length > 0 ? [...configured] : [...getAllIanaTimezones()];
163
+ if (current && !base.includes(current)) {
164
+ return [current, ...base];
165
+ }
166
+ return base;
167
+ }
168
+ function getBrowserTimezone() {
169
+ try {
170
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
171
+ } catch {
172
+ return "UTC";
173
+ }
174
+ }
175
+ function getTimezoneCityName(timezone) {
176
+ const segment = timezone.split("/").pop();
177
+ if (!segment) return timezone;
178
+ return segment.replace(/_/g, " ");
179
+ }
180
+ function getTimezoneOffsetLabel(timezone, locale = "en") {
181
+ if (timezone === "UTC") return "UTC";
182
+ try {
183
+ const parts = new Intl.DateTimeFormat(locale, {
184
+ timeZone: resolveTimezoneForIntl(timezone),
185
+ timeZoneName: "shortOffset"
186
+ }).formatToParts(/* @__PURE__ */ new Date());
187
+ return parts.find((part) => part.type === "timeZoneName")?.value ?? "";
188
+ } catch {
189
+ return "";
190
+ }
191
+ }
192
+ function formatTimezoneDisplayLabel(timezone, locale = "en") {
193
+ const city = getTimezoneCityName(timezone);
194
+ const offset = getTimezoneOffsetLabel(timezone, locale);
195
+ return offset ? `${city} (${offset})` : city;
196
+ }
197
+ function getTimezoneLabel(timezone, locale, fallbackLocale = "en") {
198
+ const key = `timezone.${timezone}`;
199
+ const translated = translate(locale, fallbackLocale, key);
200
+ if (translated !== key) return translated;
201
+ const offset = getTimezoneOffsetLabel(timezone, locale);
202
+ const city = getTimezoneCityName(timezone);
203
+ return offset ? `${city} (${offset})` : city;
204
+ }
205
+ function resolveDefaultTimezone(defaultTimezone, systemTimezone) {
206
+ if (defaultTimezone === "browser") return getBrowserTimezone();
207
+ if (defaultTimezone === "system") return systemTimezone ?? "UTC";
208
+ return defaultTimezone;
209
+ }
210
+ function resetIanaTimezoneCacheForTests() {
211
+ cachedAllTimezones = null;
212
+ cachedTimezoneSet = null;
213
+ }
214
+ var AppContext = React.createContext(null);
215
+ function resolveInitialTimeFormat(stored, defaultTimeFormat, locale) {
216
+ if (stored) return stored;
217
+ if (defaultTimeFormat === "locale") return resolveDefaultTimeFormat(locale);
218
+ return defaultTimeFormat;
219
+ }
220
+ function resolveInitialDateFormat(stored, defaultDateFormat, locale) {
221
+ if (stored) return stored;
222
+ if (defaultDateFormat === "locale") return resolveDefaultDateFormat(locale);
223
+ return defaultDateFormat;
224
+ }
225
+ function buildRequestHeaders(locale, timezone, timeFormat, dateFormat) {
226
+ return {
227
+ [APP_REQUEST_HEADER_LOCALE]: locale,
228
+ [APP_REQUEST_HEADER_TIMEZONE]: timezone,
229
+ [APP_REQUEST_HEADER_TIME_FORMAT]: timeFormat,
230
+ [APP_REQUEST_HEADER_DATE_FORMAT]: dateFormat
231
+ };
232
+ }
233
+ function AppProvider({
234
+ children,
235
+ defaultLocale = "vi",
236
+ fallbackLocale = "en",
237
+ defaultTimezone = "browser",
238
+ systemTimezone,
239
+ defaultTimeFormat = "locale",
240
+ defaultDateFormat = "locale",
241
+ timezoneOptions,
242
+ storageKey = DEFAULT_STORAGE_KEY,
243
+ persist = true,
244
+ onLocaleChange,
245
+ onTimezoneChange,
246
+ onTimeFormatChange,
247
+ onDateFormatChange
248
+ }) {
249
+ const stored = React.useMemo(
250
+ () => persist ? readStoredPreferences(storageKey) : {},
251
+ [persist, storageKey]
252
+ );
253
+ const initialLocale = stored.locale ?? defaultLocale;
254
+ const [locale, setLocaleState] = React.useState(initialLocale);
255
+ const [timezone, setTimezoneState] = React.useState(
256
+ stored.timezone ?? resolveDefaultTimezone(defaultTimezone, systemTimezone)
257
+ );
258
+ const [timeFormat, setTimeFormatState] = React.useState(
259
+ () => resolveInitialTimeFormat(stored.timeFormat, defaultTimeFormat, initialLocale)
260
+ );
261
+ const [dateFormat, setDateFormatState] = React.useState(
262
+ () => resolveInitialDateFormat(stored.dateFormat, defaultDateFormat, initialLocale)
263
+ );
264
+ const prefsRef = React.useRef({ locale, timezone, timeFormat, dateFormat });
265
+ React.useEffect(() => {
266
+ prefsRef.current = { locale, timezone, timeFormat, dateFormat };
267
+ }, [locale, timezone, timeFormat, dateFormat]);
268
+ const setLocale = React.useCallback(
269
+ (next) => {
270
+ prefsRef.current = { ...prefsRef.current, locale: next };
271
+ setLocaleState(next);
272
+ onLocaleChange?.(next);
273
+ if (persist) writeStoredPreferences(storageKey, prefsRef.current);
274
+ },
275
+ [onLocaleChange, persist, storageKey]
276
+ );
277
+ const setTimezone = React.useCallback(
278
+ (next) => {
279
+ prefsRef.current = { ...prefsRef.current, timezone: next };
280
+ setTimezoneState(next);
281
+ onTimezoneChange?.(next);
282
+ if (persist) writeStoredPreferences(storageKey, prefsRef.current);
283
+ },
284
+ [onTimezoneChange, persist, storageKey]
285
+ );
286
+ const setTimeFormat = React.useCallback(
287
+ (next) => {
288
+ prefsRef.current = { ...prefsRef.current, timeFormat: next };
289
+ setTimeFormatState(next);
290
+ onTimeFormatChange?.(next);
291
+ if (persist) writeStoredPreferences(storageKey, prefsRef.current);
292
+ },
293
+ [onTimeFormatChange, persist, storageKey]
294
+ );
295
+ const setDateFormat = React.useCallback(
296
+ (next) => {
297
+ prefsRef.current = { ...prefsRef.current, dateFormat: next };
298
+ setDateFormatState(next);
299
+ onDateFormatChange?.(next);
300
+ if (persist) writeStoredPreferences(storageKey, prefsRef.current);
301
+ },
302
+ [onDateFormatChange, persist, storageKey]
303
+ );
304
+ const requestHeaders = React.useMemo(
305
+ () => buildRequestHeaders(locale, timezone, timeFormat, dateFormat),
306
+ [locale, timezone, timeFormat, dateFormat]
307
+ );
308
+ React.useEffect(() => {
309
+ syncAppRequestHeaders(requestHeaders);
310
+ syncI18nLocale(locale, fallbackLocale);
311
+ syncDatetimeContext({
312
+ locale,
313
+ timezone,
314
+ timeFormat,
315
+ dateFormat,
316
+ dateFnsLocale: getDateFnsLocale(locale)
317
+ });
318
+ }, [requestHeaders, locale, fallbackLocale, timezone, timeFormat, dateFormat]);
319
+ const value = React.useMemo(
320
+ () => ({
321
+ locale,
322
+ fallbackLocale,
323
+ timezone,
324
+ timeFormat,
325
+ dateFormat,
326
+ dateFnsLocale: getDateFnsLocale(locale),
327
+ dayPickerLocale: getDayPickerLocale(locale),
328
+ requestHeaders,
329
+ timezoneOptions,
330
+ setLocale,
331
+ setTimezone,
332
+ setTimeFormat,
333
+ setDateFormat
334
+ }),
335
+ [
336
+ locale,
337
+ fallbackLocale,
338
+ timezone,
339
+ timeFormat,
340
+ dateFormat,
341
+ requestHeaders,
342
+ timezoneOptions,
343
+ setLocale,
344
+ setTimezone,
345
+ setTimeFormat,
346
+ setDateFormat
347
+ ]
348
+ );
349
+ return /* @__PURE__ */ jsx(AppContext.Provider, { value, children });
350
+ }
351
+ function useAppContext() {
352
+ const ctx = React.useContext(AppContext);
353
+ if (!ctx) {
354
+ throw new Error("useAppContext must be used within <AppProvider>");
355
+ }
356
+ return ctx;
357
+ }
358
+ function useOptionalAppContext() {
359
+ return React.useContext(AppContext);
360
+ }
361
+ function useAppLocale() {
362
+ const { locale, fallbackLocale, setLocale, dateFnsLocale, dayPickerLocale } = useAppContext();
363
+ return { locale, fallbackLocale, setLocale, dateFnsLocale, dayPickerLocale };
364
+ }
365
+ function useAppTimezone() {
366
+ const { timezone, setTimezone } = useAppContext();
367
+ return { timezone, setTimezone };
368
+ }
369
+ function useAppTimeFormat() {
370
+ const { timeFormat, setTimeFormat } = useAppContext();
371
+ return { timeFormat, setTimeFormat };
372
+ }
373
+ function useAppDateFormat() {
374
+ const { dateFormat, setDateFormat } = useAppContext();
375
+ return { dateFormat, setDateFormat };
376
+ }
377
+ var DEFAULT_LOCALE = "vi";
378
+ var DEFAULT_FALLBACK = "en";
379
+ function useTranslation() {
380
+ const ctx = useOptionalAppContext();
381
+ const locale = ctx?.locale ?? DEFAULT_LOCALE;
382
+ const fallbackLocale = ctx?.fallbackLocale ?? DEFAULT_FALLBACK;
383
+ return useMemo(
384
+ () => ({
385
+ locale,
386
+ fallbackLocale,
387
+ t: (key, params) => translate(locale, fallbackLocale, key, params)
388
+ }),
389
+ [locale, fallbackLocale]
390
+ );
391
+ }
392
+ function usePickerLocales(dayPickerOverride) {
393
+ const ctx = useOptionalAppContext();
394
+ const locale = ctx?.locale ?? DEFAULT_LOCALE;
395
+ return useMemo(
396
+ () => ({
397
+ locale,
398
+ timezone: ctx?.timezone ?? "Asia/Ho_Chi_Minh",
399
+ timeFormat: ctx?.timeFormat ?? "24h",
400
+ dateFormat: ctx?.dateFormat ?? "dmy",
401
+ dateFnsLocale: ctx?.dateFnsLocale ?? getDateFnsLocale(locale),
402
+ dayPickerLocale: dayPickerOverride ?? ctx?.dayPickerLocale ?? getDayPickerLocale(locale)
403
+ }),
404
+ [
405
+ ctx?.dateFnsLocale,
406
+ ctx?.dayPickerLocale,
407
+ ctx?.timeFormat,
408
+ ctx?.dateFormat,
409
+ ctx?.timezone,
410
+ dayPickerOverride,
411
+ locale
412
+ ]
413
+ );
414
+ }
415
+
416
+ export { APP_LOCALES, APP_REQUEST_HEADER_LOCALE, APP_REQUEST_HEADER_TIMEZONE, APP_TIMEZONE_OPTIONS, APP_TIMEZONE_PRESET, APP_TIME_FORMAT_OPTIONS, AppProvider, DEFAULT_STORAGE_KEY, TIMEZONE_ALIASES, formatTimezoneDisplayLabel, getAllIanaTimezones, getAppRequestHeaders, getBrowserTimezone, getTimeFormatLabel, getTimezoneCityName, getTimezoneLabel, getTimezoneOffsetLabel, isKnownAppTimezone, isValidIanaTimezone, readStoredPreferences, resetAppRequestHeaders, resetIanaTimezoneCacheForTests, resolveDefaultTimeFormat, resolveDefaultTimezone, resolveTimezoneForIntl, resolveTimezonePickerOptions, syncAppRequestHeaders, useAppContext, useAppDateFormat, useAppLocale, useAppTimeFormat, useAppTimezone, useOptionalAppContext, usePickerLocales, useTranslation, writeStoredPreferences };
@@ -0,0 +1,37 @@
1
+ import { cn } from './chunk-U7N2A7A3.js';
2
+ import * as React from 'react';
3
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ var ScrollArea = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
7
+ ScrollAreaPrimitive.Root,
8
+ {
9
+ ref,
10
+ className: cn("relative overflow-hidden", className),
11
+ ...props,
12
+ children: [
13
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, { className: "size-full rounded-[inherit]", children }),
14
+ /* @__PURE__ */ jsx(ScrollBar, {}),
15
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
16
+ ]
17
+ }
18
+ ));
19
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
20
+ var ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
21
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
22
+ {
23
+ ref,
24
+ orientation,
25
+ className: cn(
26
+ "flex touch-none transition-colors select-none",
27
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px",
28
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-px",
29
+ className
30
+ ),
31
+ ...props,
32
+ children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "bg-border relative flex-1 rounded-full" })
33
+ }
34
+ ));
35
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
36
+
37
+ export { ScrollArea, ScrollBar };