@dmsi/wedgekit-react 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/chunk-27KIIUAR.js +59 -0
- package/dist/chunk-2G2E2JMA.js +123 -0
- package/dist/chunk-4C66DLIJ.js +51 -0
- package/dist/chunk-4RD5ZF2V.js +55 -0
- package/dist/chunk-4RJKB7LC.js +14 -0
- package/dist/chunk-4T7F5BZZ.js +26 -0
- package/dist/chunk-5GOBP2JS.js +53 -0
- package/dist/chunk-6ZY524ID.js +42 -0
- package/dist/chunk-AWQSSKCK.js +32 -0
- package/dist/chunk-BNHSAFMP.js +93 -0
- package/dist/chunk-BWRHL2AG.js +439 -0
- package/dist/chunk-DKKYR6DS.js +132 -0
- package/dist/chunk-E5ALT5W7.js +182 -0
- package/dist/chunk-FY7PTP6E.js +322 -0
- package/dist/chunk-GTCSRHPF.js +119 -0
- package/dist/chunk-I2UVVKQI.js +12 -0
- package/dist/chunk-IGQVA7SC.js +41 -0
- package/dist/chunk-K3IKUSZW.js +59 -0
- package/dist/chunk-KENSVWOY.js +151 -0
- package/dist/chunk-KX3O6GJ6.js +138 -0
- package/dist/chunk-L4UM372R.js +253 -0
- package/dist/chunk-ORMEWXMH.js +37 -0
- package/dist/chunk-Q3FKEKIN.js +23 -0
- package/dist/chunk-SEKKGFM6.js +28 -0
- package/dist/chunk-SY3HT54E.js +91 -0
- package/dist/chunk-TAW5ZZ4Z.js +346 -0
- package/dist/chunk-TRUPPHBQ.js +109 -0
- package/dist/chunk-TU55CHXU.js +30 -0
- package/dist/chunk-TWZZB4WO.js +114 -0
- package/dist/chunk-TYI74BSP.js +62 -0
- package/dist/chunk-U42SKNR6.js +104 -0
- package/dist/chunk-UU3FA6LV.js +72 -0
- package/dist/chunk-WVUIIBRR.js +51 -0
- package/dist/chunk-XUIPGYP5.js +39 -0
- package/dist/chunk-Z4UCFUF7.js +299 -0
- package/dist/components/Breadcrumbs.cjs +376 -0
- package/dist/components/Breadcrumbs.js +90 -0
- package/dist/components/Button.cjs +319 -0
- package/dist/components/Button.js +8 -0
- package/dist/components/CalendarRange.cjs +520 -0
- package/dist/components/CalendarRange.js +13 -0
- package/dist/components/Caption.cjs +283 -0
- package/dist/components/Caption.js +80 -0
- package/dist/components/Checkbox.cjs +378 -0
- package/dist/components/Checkbox.js +11 -0
- package/dist/components/ContentTab.cjs +382 -0
- package/dist/components/ContentTab.js +10 -0
- package/dist/components/ContentTabs.cjs +472 -0
- package/dist/components/ContentTabs.js +98 -0
- package/dist/components/DMSiLogo.cjs +79 -0
- package/dist/components/DMSiLogo.js +56 -0
- package/dist/components/DataGrid.cjs +3113 -0
- package/dist/components/DataGrid.js +758 -0
- package/dist/components/DataGridCell.cjs +1907 -0
- package/dist/components/DataGridCell.js +24 -0
- package/dist/components/DataTable.cjs +791 -0
- package/dist/components/DataTable.js +720 -0
- package/dist/components/DateInput.cjs +1130 -0
- package/dist/components/DateInput.js +170 -0
- package/dist/components/DateRangeInput.cjs +1131 -0
- package/dist/components/DateRangeInput.js +171 -0
- package/dist/components/DebugJson.cjs +50 -0
- package/dist/components/DebugJson.js +27 -0
- package/dist/components/Display.cjs +234 -0
- package/dist/components/Display.js +12 -0
- package/dist/components/EditingContext.cjs +73 -0
- package/dist/components/EditingContext.js +35 -0
- package/dist/components/FilterGroup.cjs +1431 -0
- package/dist/components/FilterGroup.js +231 -0
- package/dist/components/FullViewportBox.cjs +35 -0
- package/dist/components/FullViewportBox.js +12 -0
- package/dist/components/Grid.cjs +69 -0
- package/dist/components/Grid.js +36 -0
- package/dist/components/GridContainer.cjs +125 -0
- package/dist/components/GridContainer.js +92 -0
- package/dist/components/Heading.cjs +238 -0
- package/dist/components/Heading.js +14 -0
- package/dist/components/HorizontalDivider.cjs +33 -0
- package/dist/components/HorizontalDivider.js +10 -0
- package/dist/components/Icon.cjs +98 -0
- package/dist/components/Icon.js +7 -0
- package/dist/components/Input.cjs +672 -0
- package/dist/components/Input.js +21 -0
- package/dist/components/InputGroup.cjs +270 -0
- package/dist/components/InputGroup.js +60 -0
- package/dist/components/Label.cjs +223 -0
- package/dist/components/Label.js +8 -0
- package/dist/components/Link.cjs +262 -0
- package/dist/components/Link.js +8 -0
- package/dist/components/List.cjs +37 -0
- package/dist/components/List.js +14 -0
- package/dist/components/LiveChatComponent.cjs +63 -0
- package/dist/components/LiveChatComponent.js +40 -0
- package/dist/components/LogoAgilityTopBar.cjs +115 -0
- package/dist/components/LogoAgilityTopBar.js +92 -0
- package/dist/components/LogoDMSiTopBar.cjs +79 -0
- package/dist/components/LogoDMSiTopBar.js +7 -0
- package/dist/components/LogoMillworkTopBar.cjs +221 -0
- package/dist/components/LogoMillworkTopBar.js +198 -0
- package/dist/components/MainBar.cjs +211 -0
- package/dist/components/MainBar.js +65 -0
- package/dist/components/Menu.cjs +437 -0
- package/dist/components/Menu.js +11 -0
- package/dist/components/MenuOption.cjs +483 -0
- package/dist/components/MenuOption.js +13 -0
- package/dist/components/MobileDataGrid.cjs +658 -0
- package/dist/components/MobileDataGrid.js +125 -0
- package/dist/components/Modal.cjs +783 -0
- package/dist/components/Modal.js +245 -0
- package/dist/components/ModalButtons.cjs +385 -0
- package/dist/components/ModalButtons.js +10 -0
- package/dist/components/ModalContent.cjs +57 -0
- package/dist/components/ModalContent.js +7 -0
- package/dist/components/ModalHeader.cjs +426 -0
- package/dist/components/ModalHeader.js +11 -0
- package/dist/components/ModalScrim.cjs +64 -0
- package/dist/components/ModalScrim.js +7 -0
- package/dist/components/NavigationTab.cjs +431 -0
- package/dist/components/NavigationTab.js +10 -0
- package/dist/components/NavigationTabs.cjs +477 -0
- package/dist/components/NavigationTabs.js +56 -0
- package/dist/components/Notification.cjs +640 -0
- package/dist/components/Notification.js +117 -0
- package/dist/components/OptionPill.cjs +478 -0
- package/dist/components/OptionPill.js +11 -0
- package/dist/components/Paragraph.cjs +231 -0
- package/dist/components/Paragraph.js +8 -0
- package/dist/components/Password.cjs +700 -0
- package/dist/components/Password.js +53 -0
- package/dist/components/ProjectBar.cjs +242 -0
- package/dist/components/ProjectBar.js +63 -0
- package/dist/components/Radio.cjs +349 -0
- package/dist/components/Radio.js +131 -0
- package/dist/components/Search.cjs +767 -0
- package/dist/components/Search.js +12 -0
- package/dist/components/Select.cjs +758 -0
- package/dist/components/Select.js +12 -0
- package/dist/components/SideMenu.cjs +54 -0
- package/dist/components/SideMenu.js +21 -0
- package/dist/components/SideMenuGroup.cjs +422 -0
- package/dist/components/SideMenuGroup.js +83 -0
- package/dist/components/SideMenuItem.cjs +388 -0
- package/dist/components/SideMenuItem.js +70 -0
- package/dist/components/Stack.cjs +138 -0
- package/dist/components/Stack.js +7 -0
- package/dist/components/StatusPill.cjs +265 -0
- package/dist/components/StatusPill.js +52 -0
- package/dist/components/Stepper.cjs +885 -0
- package/dist/components/Stepper.js +105 -0
- package/dist/components/Subheader.cjs +226 -0
- package/dist/components/Subheader.js +8 -0
- package/dist/components/Surface.cjs +98 -0
- package/dist/components/Surface.js +40 -0
- package/dist/components/Swatch.cjs +1728 -0
- package/dist/components/Swatch.js +1319 -0
- package/dist/components/Textarea.cjs +269 -0
- package/dist/components/Textarea.js +96 -0
- package/dist/components/Theme.cjs +36 -0
- package/dist/components/Theme.js +7 -0
- package/dist/components/Time.cjs +1118 -0
- package/dist/components/Time.js +353 -0
- package/dist/components/Toast.cjs +644 -0
- package/dist/components/Toast.js +218 -0
- package/dist/components/Tooltip.cjs +273 -0
- package/dist/components/Tooltip.js +9 -0
- package/dist/components/TopBar.cjs +352 -0
- package/dist/components/TopBar.js +132 -0
- package/dist/components/useInfiniteScroll.cjs +57 -0
- package/dist/components/useInfiniteScroll.js +8 -0
- package/dist/components/useMatchesMedia.cjs +53 -0
- package/dist/components/useMatchesMedia.js +9 -0
- package/dist/components/useMenuSystem.cjs +358 -0
- package/dist/components/useMenuSystem.js +11 -0
- package/dist/components/useMounted.cjs +39 -0
- package/dist/components/useMounted.js +8 -0
- package/dist/fonts.css +21 -0
- package/dist/icons-light[FILL]-PPZXOLWS.woff2 +0 -0
- package/dist/icons-normal[FILL]-PPZXOLWS.woff2 +0 -0
- package/dist/index.css +4401 -0
- package/dist/open-sans-55T6A4JE.woff2 +0 -0
- package/dist/types.cjs +18 -0
- package/dist/types.js +0 -0
- package/package.json +66 -0
- package/src/brand.css +125 -0
- package/src/classNames.ts +144 -0
- package/src/components/Breadcrumbs.tsx +116 -0
- package/src/components/Button.tsx +210 -0
- package/src/components/CalendarRange.tsx +429 -0
- package/src/components/Caption.tsx +101 -0
- package/src/components/Checkbox.tsx +196 -0
- package/src/components/ContentTab.tsx +66 -0
- package/src/components/ContentTabs.tsx +103 -0
- package/src/components/DMSiLogo.tsx +32 -0
- package/src/components/DataGrid.tsx +948 -0
- package/src/components/DataGridCell.tsx +384 -0
- package/src/components/DataTable.tsx +835 -0
- package/src/components/DateInput.tsx +188 -0
- package/src/components/DateRangeInput.tsx +179 -0
- package/src/components/DebugJson.tsx +24 -0
- package/src/components/Display.tsx +60 -0
- package/src/components/EditingContext.tsx +40 -0
- package/src/components/FilterGroup.tsx +234 -0
- package/src/components/FullViewportBox.tsx +11 -0
- package/src/components/Grid.tsx +75 -0
- package/src/components/GridContainer.tsx +124 -0
- package/src/components/Heading.tsx +66 -0
- package/src/components/HorizontalDivider.tsx +3 -0
- package/src/components/Icon.tsx +36 -0
- package/src/components/Input.tsx +511 -0
- package/src/components/InputGroup.tsx +51 -0
- package/src/components/Label.tsx +40 -0
- package/src/components/Link.tsx +106 -0
- package/src/components/List.tsx +10 -0
- package/src/components/LiveChatComponent.tsx +56 -0
- package/src/components/LogoAgilityTopBar.tsx +53 -0
- package/src/components/LogoDMSiTopBar.tsx +32 -0
- package/src/components/LogoMillworkTopBar.tsx +118 -0
- package/src/components/MainBar.tsx +83 -0
- package/src/components/Menu.tsx +286 -0
- package/src/components/MenuOption.tsx +275 -0
- package/src/components/MobileDataGrid.tsx +135 -0
- package/src/components/Modal.tsx +271 -0
- package/src/components/ModalButtons.tsx +44 -0
- package/src/components/ModalContent.tsx +23 -0
- package/src/components/ModalHeader.tsx +41 -0
- package/src/components/ModalScrim.tsx +35 -0
- package/src/components/NavigationTab.tsx +89 -0
- package/src/components/NavigationTabs.tsx +63 -0
- package/src/components/Notification.tsx +120 -0
- package/src/components/OptionPill.tsx +114 -0
- package/src/components/Paragraph.tsx +49 -0
- package/src/components/Password.tsx +46 -0
- package/src/components/ProjectBar.tsx +76 -0
- package/src/components/Radio.tsx +140 -0
- package/src/components/Search.tsx +129 -0
- package/src/components/Select.tsx +104 -0
- package/src/components/SideMenu.tsx +21 -0
- package/src/components/SideMenuGroup.tsx +81 -0
- package/src/components/SideMenuItem.tsx +90 -0
- package/src/components/Stack.tsx +179 -0
- package/src/components/StatusPill.tsx +51 -0
- package/src/components/Stepper.tsx +91 -0
- package/src/components/Subheader.tsx +44 -0
- package/src/components/Surface.tsx +34 -0
- package/src/components/Swatch.tsx +1066 -0
- package/src/components/Textarea.tsx +101 -0
- package/src/components/Theme.tsx +13 -0
- package/src/components/Time.tsx +438 -0
- package/src/components/Toast.tsx +244 -0
- package/src/components/Tooltip.tsx +137 -0
- package/src/components/TopBar.tsx +124 -0
- package/src/components/useInfiniteScroll.tsx +40 -0
- package/src/components/useMatchesMedia.tsx +28 -0
- package/src/components/useMenuSystem.tsx +367 -0
- package/src/components/useMounted.tsx +14 -0
- package/src/darkmode.css +140 -0
- package/src/fonts.css +23 -0
- package/src/index.css +509 -0
- package/src/index.tsx +2 -0
- package/src/types.ts +149 -0
- package/src/utils/formatting.tsx +81 -0
- package/src/utils.ts +23 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Label
|
|
3
|
+
} from "./chunk-4C66DLIJ.js";
|
|
4
|
+
import {
|
|
5
|
+
Icon
|
|
6
|
+
} from "./chunk-IGQVA7SC.js";
|
|
7
|
+
import {
|
|
8
|
+
baseTransition,
|
|
9
|
+
componentGap,
|
|
10
|
+
componentPaddingMinusBorder,
|
|
11
|
+
componentPaddingXUsingComponentGap,
|
|
12
|
+
typography
|
|
13
|
+
} from "./chunk-KX3O6GJ6.js";
|
|
14
|
+
import {
|
|
15
|
+
__objRest,
|
|
16
|
+
__spreadProps,
|
|
17
|
+
__spreadValues
|
|
18
|
+
} from "./chunk-ORMEWXMH.js";
|
|
19
|
+
|
|
20
|
+
// src/components/Input.tsx
|
|
21
|
+
import {
|
|
22
|
+
useEffect,
|
|
23
|
+
useRef,
|
|
24
|
+
useState
|
|
25
|
+
} from "react";
|
|
26
|
+
import clsx from "clsx";
|
|
27
|
+
|
|
28
|
+
// src/utils/formatting.tsx
|
|
29
|
+
function getDecimalPlaceholder(decimals) {
|
|
30
|
+
if (!decimals || decimals <= 0) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
placeholder: `0.${"0".repeat(decimals)}`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function formatDecimalValue(value, decimals) {
|
|
38
|
+
if (!value || value === "") {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
const numValue = typeof value === "string" ? parseFloat(value) : value;
|
|
42
|
+
if (isNaN(numValue)) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
if (!decimals || decimals <= 0) {
|
|
46
|
+
return String(Math.round(numValue));
|
|
47
|
+
}
|
|
48
|
+
return numValue.toFixed(decimals);
|
|
49
|
+
}
|
|
50
|
+
function formatCurrencyDisplay(value) {
|
|
51
|
+
if (!value || value === "") {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
const parts = value.split(".");
|
|
55
|
+
const integerPart = parts[0];
|
|
56
|
+
const decimalPart = parts[1];
|
|
57
|
+
const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
58
|
+
return decimalPart !== void 0 ? `${formattedInteger}.${decimalPart}` : formattedInteger;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/components/Input.tsx
|
|
62
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
63
|
+
var InputBase = (_a) => {
|
|
64
|
+
var _b = _a, {
|
|
65
|
+
before,
|
|
66
|
+
after,
|
|
67
|
+
type,
|
|
68
|
+
label,
|
|
69
|
+
error,
|
|
70
|
+
className,
|
|
71
|
+
align = "left",
|
|
72
|
+
caption,
|
|
73
|
+
required,
|
|
74
|
+
selectOnFocus,
|
|
75
|
+
removeRoundness,
|
|
76
|
+
inputContainerRef,
|
|
77
|
+
removeBorder,
|
|
78
|
+
wrapperClassName,
|
|
79
|
+
focus
|
|
80
|
+
} = _b, props = __objRest(_b, [
|
|
81
|
+
"before",
|
|
82
|
+
"after",
|
|
83
|
+
"type",
|
|
84
|
+
"label",
|
|
85
|
+
"error",
|
|
86
|
+
"className",
|
|
87
|
+
"align",
|
|
88
|
+
"caption",
|
|
89
|
+
"required",
|
|
90
|
+
"selectOnFocus",
|
|
91
|
+
"removeRoundness",
|
|
92
|
+
"inputContainerRef",
|
|
93
|
+
"removeBorder",
|
|
94
|
+
"wrapperClassName",
|
|
95
|
+
"focus"
|
|
96
|
+
]);
|
|
97
|
+
const attributes = {
|
|
98
|
+
"data-error": error && !focus || null,
|
|
99
|
+
"data-focus": focus || null
|
|
100
|
+
};
|
|
101
|
+
const inputRef = useRef(null);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
var _a2;
|
|
104
|
+
const input = inputRef.current;
|
|
105
|
+
const focusHandler = () => {
|
|
106
|
+
input == null ? void 0 : input.select();
|
|
107
|
+
};
|
|
108
|
+
if (selectOnFocus) {
|
|
109
|
+
(_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
|
|
110
|
+
return () => {
|
|
111
|
+
input == null ? void 0 : input.removeEventListener("focus", focusHandler);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}, [selectOnFocus]);
|
|
115
|
+
const inputBaseClass = clsx(
|
|
116
|
+
"w-full",
|
|
117
|
+
"flex flex-row items-center",
|
|
118
|
+
"bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
|
|
119
|
+
componentGap,
|
|
120
|
+
baseTransition,
|
|
121
|
+
"outline-transparent outline-2 -outline-offset-2",
|
|
122
|
+
componentPaddingMinusBorder,
|
|
123
|
+
!removeRoundness && "rounded-base",
|
|
124
|
+
!removeBorder && "border border-border-primary-normal",
|
|
125
|
+
"relative"
|
|
126
|
+
);
|
|
127
|
+
const inputFocusClass = clsx(
|
|
128
|
+
"has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
|
|
129
|
+
);
|
|
130
|
+
const inputDisabledClass = clsx(
|
|
131
|
+
"has-disabled:bg-background-action-secondary-disabled"
|
|
132
|
+
);
|
|
133
|
+
const inputReadOnlyClass = clsx(
|
|
134
|
+
"has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
|
|
135
|
+
);
|
|
136
|
+
const inputInvalidClass = clsx(
|
|
137
|
+
"has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
|
|
138
|
+
);
|
|
139
|
+
return /* @__PURE__ */ jsxs(
|
|
140
|
+
"label",
|
|
141
|
+
{
|
|
142
|
+
ref: inputContainerRef,
|
|
143
|
+
className: clsx(
|
|
144
|
+
"w-full flex flex-col",
|
|
145
|
+
"block",
|
|
146
|
+
"text-text-primary-normal has-disabled:text-text-primary-disabled",
|
|
147
|
+
componentGap
|
|
148
|
+
),
|
|
149
|
+
style: __spreadValues({}, props.style),
|
|
150
|
+
children: [
|
|
151
|
+
label && /* @__PURE__ */ jsxs("div", { className: clsx("flex items-center", componentGap), children: [
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
Label,
|
|
154
|
+
{
|
|
155
|
+
className: clsx(
|
|
156
|
+
props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
|
|
157
|
+
),
|
|
158
|
+
children: label
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
required && /* @__PURE__ */ jsx(
|
|
162
|
+
"span",
|
|
163
|
+
{
|
|
164
|
+
className: clsx(typography.label, "text-text-critical-normal"),
|
|
165
|
+
children: "*"
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsxs(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: clsx(
|
|
173
|
+
inputBaseClass,
|
|
174
|
+
!props.disabled && inputInvalidClass,
|
|
175
|
+
inputFocusClass,
|
|
176
|
+
inputDisabledClass,
|
|
177
|
+
inputReadOnlyClass,
|
|
178
|
+
wrapperClassName
|
|
179
|
+
),
|
|
180
|
+
children: [
|
|
181
|
+
before,
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
"input",
|
|
184
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
185
|
+
ref: (el) => {
|
|
186
|
+
inputRef.current = el;
|
|
187
|
+
},
|
|
188
|
+
type,
|
|
189
|
+
required
|
|
190
|
+
}, props), attributes), {
|
|
191
|
+
id: props.id,
|
|
192
|
+
className: clsx(
|
|
193
|
+
"flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
|
|
194
|
+
"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
|
|
195
|
+
"placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
|
|
196
|
+
align === "right" && "text-right",
|
|
197
|
+
align === "center" && "text-center",
|
|
198
|
+
componentPaddingXUsingComponentGap,
|
|
199
|
+
typography.paragraph,
|
|
200
|
+
className,
|
|
201
|
+
props.readOnly && !props.disabled && "!px-0"
|
|
202
|
+
)
|
|
203
|
+
})
|
|
204
|
+
),
|
|
205
|
+
after
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
caption
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
var Input = (_a) => {
|
|
215
|
+
var _b = _a, {
|
|
216
|
+
variant = "default",
|
|
217
|
+
decimals,
|
|
218
|
+
uom,
|
|
219
|
+
removeSearchIcon,
|
|
220
|
+
value: propValue,
|
|
221
|
+
onChange,
|
|
222
|
+
onBlur,
|
|
223
|
+
onClear
|
|
224
|
+
} = _b, props = __objRest(_b, [
|
|
225
|
+
"variant",
|
|
226
|
+
"decimals",
|
|
227
|
+
"uom",
|
|
228
|
+
"removeSearchIcon",
|
|
229
|
+
"value",
|
|
230
|
+
"onChange",
|
|
231
|
+
"onBlur",
|
|
232
|
+
"onClear"
|
|
233
|
+
]);
|
|
234
|
+
const [internalValue, setInternalValue] = useState("");
|
|
235
|
+
const [displayValue, setDisplayValue] = useState("");
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
var _a2;
|
|
238
|
+
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
239
|
+
if (variant === "currency") {
|
|
240
|
+
if (propValue === void 0 || propValue === "" || typeof propValue === "number" && isNaN(propValue)) {
|
|
241
|
+
setInternalValue("");
|
|
242
|
+
setDisplayValue("");
|
|
243
|
+
} else {
|
|
244
|
+
const numValue = typeof propValue === "string" ? parseFloat(propValue) : propValue;
|
|
245
|
+
if (!isNaN(numValue)) {
|
|
246
|
+
const formatted = numValue.toFixed(decimals != null ? decimals : 2);
|
|
247
|
+
setInternalValue(formatted);
|
|
248
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
setInternalValue(stringValue);
|
|
253
|
+
setDisplayValue(stringValue);
|
|
254
|
+
}
|
|
255
|
+
}, [propValue, decimals, variant]);
|
|
256
|
+
const getInputProps = () => {
|
|
257
|
+
var _a2;
|
|
258
|
+
const baseProps = __spreadProps(__spreadValues(__spreadValues({}, props), getDecimalPlaceholder(decimals)), {
|
|
259
|
+
value: propValue
|
|
260
|
+
});
|
|
261
|
+
switch (variant) {
|
|
262
|
+
case "search":
|
|
263
|
+
return __spreadProps(__spreadValues({}, baseProps), {
|
|
264
|
+
placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
|
|
265
|
+
className: "!mr-6",
|
|
266
|
+
value: displayValue
|
|
267
|
+
});
|
|
268
|
+
case "finder":
|
|
269
|
+
return baseProps;
|
|
270
|
+
case "currency":
|
|
271
|
+
return __spreadProps(__spreadValues({}, baseProps), {
|
|
272
|
+
align: "right",
|
|
273
|
+
type: "text",
|
|
274
|
+
value: displayValue
|
|
275
|
+
});
|
|
276
|
+
case "percentage":
|
|
277
|
+
case "uom":
|
|
278
|
+
return __spreadProps(__spreadValues({}, baseProps), {
|
|
279
|
+
type: "number",
|
|
280
|
+
align: "right"
|
|
281
|
+
});
|
|
282
|
+
default:
|
|
283
|
+
return baseProps;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const getBeforeElement = () => {
|
|
287
|
+
if (props.before) return props.before;
|
|
288
|
+
switch (variant) {
|
|
289
|
+
case "search":
|
|
290
|
+
return !removeSearchIcon ? /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "search" }) }) : null;
|
|
291
|
+
case "currency":
|
|
292
|
+
return /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "attach_money" }) });
|
|
293
|
+
default:
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const getAfterElement = () => {
|
|
298
|
+
if (props.after) return props.after;
|
|
299
|
+
switch (variant) {
|
|
300
|
+
case "search": {
|
|
301
|
+
const hasValue = displayValue.length > 0;
|
|
302
|
+
return hasValue && !props.readOnly ? /* @__PURE__ */ jsx(
|
|
303
|
+
Icon,
|
|
304
|
+
{
|
|
305
|
+
name: "close",
|
|
306
|
+
onClick: handleSearchReset,
|
|
307
|
+
className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
|
|
308
|
+
}
|
|
309
|
+
) : null;
|
|
310
|
+
}
|
|
311
|
+
case "finder":
|
|
312
|
+
return /* @__PURE__ */ jsx(Icon, { name: "search" });
|
|
313
|
+
case "uom":
|
|
314
|
+
return uom ? /* @__PURE__ */ jsx("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
|
|
315
|
+
case "percentage":
|
|
316
|
+
return /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "percent" }) });
|
|
317
|
+
default:
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const handleSearchReset = () => {
|
|
322
|
+
setInternalValue("");
|
|
323
|
+
setDisplayValue("");
|
|
324
|
+
if (onChange) {
|
|
325
|
+
const syntheticEvent = {
|
|
326
|
+
target: { value: "" }
|
|
327
|
+
};
|
|
328
|
+
if (typeof onChange === "function") {
|
|
329
|
+
onChange(syntheticEvent);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
onClear == null ? void 0 : onClear();
|
|
333
|
+
};
|
|
334
|
+
const handleChange = (e) => {
|
|
335
|
+
const rawValue = e.target.value;
|
|
336
|
+
if (variant === "search") {
|
|
337
|
+
setInternalValue(rawValue);
|
|
338
|
+
setDisplayValue(rawValue);
|
|
339
|
+
if (typeof onChange === "function") {
|
|
340
|
+
onChange(e);
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (variant === "currency") {
|
|
345
|
+
const raw = rawValue.replace(/,/g, "");
|
|
346
|
+
if (raw === "") {
|
|
347
|
+
setInternalValue("");
|
|
348
|
+
setDisplayValue("");
|
|
349
|
+
if (onChange) {
|
|
350
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
351
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
352
|
+
});
|
|
353
|
+
onChange(syntheticEvent);
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const regex = /^\d*\.?\d*$/;
|
|
358
|
+
if (!regex.test(raw)) return;
|
|
359
|
+
const parts = raw.split(".");
|
|
360
|
+
const currentDecimals = decimals != null ? decimals : 2;
|
|
361
|
+
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
362
|
+
setInternalValue(raw);
|
|
363
|
+
setDisplayValue(formatCurrencyDisplay(raw));
|
|
364
|
+
const asNumber = Number(raw);
|
|
365
|
+
if (!isNaN(asNumber) && onChange) {
|
|
366
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
367
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
368
|
+
});
|
|
369
|
+
onChange(syntheticEvent);
|
|
370
|
+
}
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
setInternalValue(rawValue);
|
|
374
|
+
setDisplayValue(rawValue);
|
|
375
|
+
if (typeof onChange === "function") {
|
|
376
|
+
onChange(e);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
const handleBlur = (e) => {
|
|
380
|
+
if (variant === "currency") {
|
|
381
|
+
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
382
|
+
setInternalValue(formatted);
|
|
383
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
384
|
+
const asNumber = Number(formatted);
|
|
385
|
+
if (!isNaN(asNumber) && onChange) {
|
|
386
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
387
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
388
|
+
});
|
|
389
|
+
onChange(syntheticEvent);
|
|
390
|
+
}
|
|
391
|
+
} else if (variant === "uom" || variant === "percentage") {
|
|
392
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
393
|
+
e.target.value = formattedValue;
|
|
394
|
+
}
|
|
395
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
396
|
+
};
|
|
397
|
+
const inputProps = getInputProps();
|
|
398
|
+
return /* @__PURE__ */ jsx(
|
|
399
|
+
InputBase,
|
|
400
|
+
__spreadProps(__spreadValues({}, inputProps), {
|
|
401
|
+
before: getBeforeElement(),
|
|
402
|
+
after: getAfterElement(),
|
|
403
|
+
onChange: handleChange,
|
|
404
|
+
onBlur: handleBlur
|
|
405
|
+
})
|
|
406
|
+
);
|
|
407
|
+
};
|
|
408
|
+
Input.displayName = "Input";
|
|
409
|
+
var Finder = (props) => /* @__PURE__ */ jsx(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
|
|
410
|
+
var UOM = (props) => /* @__PURE__ */ jsx(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
|
|
411
|
+
var Currency = (props) => {
|
|
412
|
+
var _a;
|
|
413
|
+
const handleCurrencyChange = (e) => {
|
|
414
|
+
var _a2;
|
|
415
|
+
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
|
|
416
|
+
};
|
|
417
|
+
return /* @__PURE__ */ jsx(
|
|
418
|
+
Input,
|
|
419
|
+
__spreadProps(__spreadValues({}, props), {
|
|
420
|
+
variant: "currency",
|
|
421
|
+
decimals: (_a = props.decimals) != null ? _a : 2,
|
|
422
|
+
onChange: handleCurrencyChange
|
|
423
|
+
})
|
|
424
|
+
);
|
|
425
|
+
};
|
|
426
|
+
var Percentage = (props) => /* @__PURE__ */ jsx(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
|
|
427
|
+
Finder.displayName = "Finder";
|
|
428
|
+
UOM.displayName = "UOM";
|
|
429
|
+
Currency.displayName = "Currency";
|
|
430
|
+
Percentage.displayName = "Percentage";
|
|
431
|
+
|
|
432
|
+
export {
|
|
433
|
+
InputBase,
|
|
434
|
+
Input,
|
|
435
|
+
Finder,
|
|
436
|
+
UOM,
|
|
437
|
+
Currency,
|
|
438
|
+
Percentage
|
|
439
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Paragraph
|
|
3
|
+
} from "./chunk-K3IKUSZW.js";
|
|
4
|
+
import {
|
|
5
|
+
Icon
|
|
6
|
+
} from "./chunk-IGQVA7SC.js";
|
|
7
|
+
import {
|
|
8
|
+
baseTransition,
|
|
9
|
+
componentGap
|
|
10
|
+
} from "./chunk-KX3O6GJ6.js";
|
|
11
|
+
import {
|
|
12
|
+
__objRest,
|
|
13
|
+
__spreadValues
|
|
14
|
+
} from "./chunk-ORMEWXMH.js";
|
|
15
|
+
|
|
16
|
+
// src/components/Checkbox.tsx
|
|
17
|
+
import clsx from "clsx";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
var Checkbox = (_a) => {
|
|
20
|
+
var _b = _a, {
|
|
21
|
+
label,
|
|
22
|
+
error,
|
|
23
|
+
disabled,
|
|
24
|
+
readOnly,
|
|
25
|
+
checked,
|
|
26
|
+
onChange,
|
|
27
|
+
indeterminate,
|
|
28
|
+
paragraphClassName
|
|
29
|
+
} = _b, props = __objRest(_b, [
|
|
30
|
+
"label",
|
|
31
|
+
"error",
|
|
32
|
+
"disabled",
|
|
33
|
+
"readOnly",
|
|
34
|
+
"checked",
|
|
35
|
+
"onChange",
|
|
36
|
+
"indeterminate",
|
|
37
|
+
"paragraphClassName"
|
|
38
|
+
]);
|
|
39
|
+
const selected = indeterminate || checked;
|
|
40
|
+
const normalClassName = clsx(
|
|
41
|
+
!selected && !error && !disabled && !readOnly && "border-border-primary-normal bg-background-action-secondary-normal peer-hover:border-border-action-hover peer-hover:bg-background-action-secondary-hover peer-active:border-border-action-active peer-active:bg-background-action-secondary-active"
|
|
42
|
+
);
|
|
43
|
+
const normalSelectedClassName = clsx(
|
|
44
|
+
selected && !error && !disabled && !readOnly && "bg-background-action-primary-normal border-background-action-primary-normal peer-hover:bg-background-action-primary-hover peer-hover:border-background-action-primary-hover peer-active:bg-background-action-primary-active peer-active:border-background-action-primary-active"
|
|
45
|
+
);
|
|
46
|
+
const errorClassName = clsx(
|
|
47
|
+
error && !selected && "bg-background-action-critical-secondary-normal border-border-action-critical-normal peer-hover:border-border-action-critical-hover peer-hover:bg-background-action-critical-secondary-hover peer-active:border-border-action-critical-active peer-active:bg-background-action-secondary-active"
|
|
48
|
+
);
|
|
49
|
+
const errorSelectedClassName = clsx(
|
|
50
|
+
error && selected && "bg-background-action-critical-primary-normal border-background-action-critical-primary-normal peer-hover:bg-background-action-critical-primary-hover peer-hover:border-background-action-critical-primary-hover peer-active:bg-background-action-critical-primary-active peer-active:border-background-action-critical-primary-active"
|
|
51
|
+
);
|
|
52
|
+
const disabledClassName = clsx(
|
|
53
|
+
disabled && !readOnly && "border-border-primary-normal bg-background-action-secondary-disabled peer-checked:bg-icon-on-action-primary-disabled peer-checked:border-icon-on-action-primary-disabled"
|
|
54
|
+
);
|
|
55
|
+
const readOnlyClassName = clsx(
|
|
56
|
+
readOnly && "border-transparent bg-transparent peer-checked:bg-transparent peer-checked:border-transparent"
|
|
57
|
+
);
|
|
58
|
+
const checkColor = clsx(
|
|
59
|
+
selected && !disabled && !readOnly && "color-icon-on-action-primary-normal peer-hover:color-icon-on-action-primary-hover peer-active:color-icon-on-action-primary-active",
|
|
60
|
+
selected && disabled && "color-background-action-primary-disabled"
|
|
61
|
+
);
|
|
62
|
+
return /* @__PURE__ */ jsxs(
|
|
63
|
+
"label",
|
|
64
|
+
{
|
|
65
|
+
className: clsx(
|
|
66
|
+
"flex items-center",
|
|
67
|
+
componentGap,
|
|
68
|
+
(disabled || readOnly && error || readOnly) && "cursor-default",
|
|
69
|
+
!(readOnly && error) && !disabled && !readOnly && "cursor-pointer"
|
|
70
|
+
),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
"input",
|
|
75
|
+
__spreadValues({
|
|
76
|
+
type: "checkbox",
|
|
77
|
+
className: "sr-only peer",
|
|
78
|
+
disabled,
|
|
79
|
+
checked: selected,
|
|
80
|
+
onChange: handleOnChange,
|
|
81
|
+
id: props.id,
|
|
82
|
+
"data-indeterminate": indeterminate
|
|
83
|
+
}, props)
|
|
84
|
+
),
|
|
85
|
+
error && (readOnly || disabled) ? /* @__PURE__ */ jsx("div", { className: clsx("size-6", "flex items-center justify-center"), children: selected ? indeterminate ? /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "question_mark" }) }) : readOnly ? /* @__PURE__ */ jsx("span", { className: "text-success-400 contents", children: /* @__PURE__ */ jsx(Icon, { name: "check" }) }) : /* @__PURE__ */ jsx("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "check", className: "pointer-events-none" }) }) : readOnly && /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "close" }) }) }) : /* @__PURE__ */ jsx(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
className: clsx(
|
|
89
|
+
"size-6 border rounded-base",
|
|
90
|
+
"flex items-center justify-center",
|
|
91
|
+
baseTransition,
|
|
92
|
+
normalClassName,
|
|
93
|
+
normalSelectedClassName,
|
|
94
|
+
errorClassName,
|
|
95
|
+
errorSelectedClassName,
|
|
96
|
+
disabledClassName,
|
|
97
|
+
readOnlyClassName,
|
|
98
|
+
checkColor
|
|
99
|
+
),
|
|
100
|
+
children: selected ? indeterminate ? readOnly ? /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "question_mark" }) }) : /* @__PURE__ */ jsx("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "remove", className: "pointer-events-none" }) }) : readOnly ? /* @__PURE__ */ jsx("span", { className: "text-success-400 contents", children: /* @__PURE__ */ jsx(Icon, { name: "check" }) }) : /* @__PURE__ */ jsx("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "check", className: "pointer-events-none" }) }) : readOnly && /* @__PURE__ */ jsx("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ jsx(Icon, { name: "close" }) })
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] }),
|
|
104
|
+
label && /* @__PURE__ */ jsx(
|
|
105
|
+
Paragraph,
|
|
106
|
+
{
|
|
107
|
+
as: "span",
|
|
108
|
+
padded: true,
|
|
109
|
+
className: clsx(
|
|
110
|
+
"text-nowrap",
|
|
111
|
+
disabled && !error && "!text-text-primary-disabled",
|
|
112
|
+
error && !disabled && !readOnly && "!text-text-primary-error",
|
|
113
|
+
paragraphClassName
|
|
114
|
+
),
|
|
115
|
+
children: label
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
function handleOnChange(e) {
|
|
122
|
+
if (disabled || readOnly || readOnly && error || !onChange) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
onChange(e);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
Checkbox.displayName = "Checkbox";
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
Checkbox
|
|
132
|
+
};
|