smartsell-ui-kit 0.0.6 → 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.
- package/README.md +36 -24
- package/dist/{chunk-UIFTQDYM.js → chunk-YWH2VIAD.js} +177 -64
- package/dist/chunk-YWH2VIAD.js.map +1 -0
- package/dist/index.cjs +1258 -303
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -17
- package/dist/index.d.ts +59 -17
- package/dist/index.js +1052 -206
- package/dist/index.js.map +1 -1
- package/dist/{modal-CS9SuYSC.d.cts → modal-B2lmASXk.d.cts} +3 -4
- package/dist/{modal-CS9SuYSC.d.ts → modal-B2lmASXk.d.ts} +3 -4
- package/dist/modal.cjs +175 -63
- package/dist/modal.cjs.map +1 -1
- package/dist/modal.d.cts +2 -2
- package/dist/modal.d.ts +2 -2
- package/dist/modal.js +1 -1
- package/package.json +5 -10
- package/dist/chunk-UIFTQDYM.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
Button: () => Button,
|
|
24
24
|
Card: () => Card,
|
|
25
|
+
Checkbox: () => Checkbox,
|
|
25
26
|
ComposableModal: () => ComposableModal,
|
|
27
|
+
DatePicker: () => DatePicker,
|
|
26
28
|
Input: () => Input,
|
|
27
29
|
Modal: () => Modal,
|
|
28
30
|
Select: () => Select,
|
|
@@ -34,7 +36,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
34
36
|
|
|
35
37
|
// src/components/Button.tsx
|
|
36
38
|
var import_react2 = require("react");
|
|
37
|
-
var import_smartsell_sales_sdk2 = require("smartsell-sales-sdk");
|
|
38
39
|
|
|
39
40
|
// src/components/controlSize.ts
|
|
40
41
|
var CONTROL_METRICS_BY_SIZE = {
|
|
@@ -93,29 +94,88 @@ var getButtonSizeStyles = (size) => {
|
|
|
93
94
|
};
|
|
94
95
|
};
|
|
95
96
|
|
|
97
|
+
// src/color.ts
|
|
98
|
+
function withAlpha(hex, alpha) {
|
|
99
|
+
const normalized = hex.replace("#", "").trim();
|
|
100
|
+
const value = normalized.length === 3 ? normalized.split("").map((char) => char + char).join("") : normalized;
|
|
101
|
+
const red = Number.parseInt(value.slice(0, 2), 16);
|
|
102
|
+
const green = Number.parseInt(value.slice(2, 4), 16);
|
|
103
|
+
const blue = Number.parseInt(value.slice(4, 6), 16);
|
|
104
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
// src/theme.ts
|
|
97
108
|
var import_react = require("react");
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
var import_smartsell_theme = require("smartsell-theme");
|
|
110
|
+
var DEFAULT_THEME_COLORS = {
|
|
111
|
+
primary: "#111827",
|
|
112
|
+
secondary: "#6b7280",
|
|
113
|
+
background: "#f8fafc",
|
|
114
|
+
surface: "#ffffff",
|
|
115
|
+
text: "#111827",
|
|
116
|
+
textLight: "#6b7280",
|
|
117
|
+
positive: "#16a34a",
|
|
118
|
+
negative: "#dc2626",
|
|
119
|
+
warning: "#d97706",
|
|
120
|
+
info: "#2563eb",
|
|
121
|
+
onPrimary: "#ffffff"
|
|
122
|
+
};
|
|
123
|
+
function normalizeUiKitTheme(theme) {
|
|
124
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
125
|
+
const colors = theme.colors;
|
|
126
|
+
const primary = (_a = colors.primary) != null ? _a : DEFAULT_THEME_COLORS.primary;
|
|
127
|
+
const background = (_b = colors.background) != null ? _b : DEFAULT_THEME_COLORS.background;
|
|
128
|
+
const surface = (_c = colors.surface) != null ? _c : background;
|
|
129
|
+
const text = (_f = (_e = (_d = colors.text) != null ? _d : colors.onSurface) != null ? _e : colors.onBackground) != null ? _f : DEFAULT_THEME_COLORS.text;
|
|
130
|
+
const textLight = (_h = (_g = colors.textLight) != null ? _g : colors.onSurfaceLight) != null ? _h : text;
|
|
131
|
+
const normalizedColors = {
|
|
132
|
+
...theme.colors,
|
|
133
|
+
primary,
|
|
134
|
+
primaryLight: (_i = colors.primaryLight) != null ? _i : primary,
|
|
135
|
+
primaryDark: (_j = colors.primaryDark) != null ? _j : primary,
|
|
136
|
+
secondary: (_k = colors.secondary) != null ? _k : DEFAULT_THEME_COLORS.secondary,
|
|
137
|
+
background,
|
|
138
|
+
backgroundLight: (_l = colors.backgroundLight) != null ? _l : background,
|
|
139
|
+
surface,
|
|
140
|
+
text,
|
|
141
|
+
textLight,
|
|
142
|
+
positive: (_m = colors.positive) != null ? _m : DEFAULT_THEME_COLORS.positive,
|
|
143
|
+
negative: (_n = colors.negative) != null ? _n : DEFAULT_THEME_COLORS.negative,
|
|
144
|
+
warning: (_o = colors.warning) != null ? _o : DEFAULT_THEME_COLORS.warning,
|
|
145
|
+
info: (_p = colors.info) != null ? _p : DEFAULT_THEME_COLORS.info,
|
|
146
|
+
onPrimary: (_q = colors.onPrimary) != null ? _q : DEFAULT_THEME_COLORS.onPrimary,
|
|
147
|
+
onSecondary: (_r = colors.onSecondary) != null ? _r : text,
|
|
148
|
+
onBackground: (_s = colors.onBackground) != null ? _s : text,
|
|
149
|
+
onSurface: (_t = colors.onSurface) != null ? _t : text,
|
|
150
|
+
onSurfaceLight: (_u = colors.onSurfaceLight) != null ? _u : textLight,
|
|
151
|
+
onWarning: (_v = colors.onWarning) != null ? _v : text
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
...theme,
|
|
155
|
+
colors: normalizedColors,
|
|
156
|
+
color: normalizedColors
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function useUiKitTheme() {
|
|
160
|
+
const activeTheme = (0, import_smartsell_theme.useThemeValue)();
|
|
101
161
|
return (0, import_react.useMemo)(() => {
|
|
162
|
+
const theme = normalizeUiKitTheme(activeTheme);
|
|
102
163
|
return {
|
|
103
164
|
theme,
|
|
104
|
-
borderSoft:
|
|
105
|
-
borderStrong:
|
|
106
|
-
surfaceMuted:
|
|
107
|
-
surfaceRaised:
|
|
108
|
-
overlay:
|
|
109
|
-
focusRing:
|
|
110
|
-
mutedText:
|
|
165
|
+
borderSoft: withAlpha(theme.colors.onSurface, 0.1),
|
|
166
|
+
borderStrong: withAlpha(theme.colors.onSurface, 0.16),
|
|
167
|
+
surfaceMuted: withAlpha(theme.colors.onSurface, 0.04),
|
|
168
|
+
surfaceRaised: withAlpha(theme.colors.surface, 0.94),
|
|
169
|
+
overlay: withAlpha("#030712", 0.62),
|
|
170
|
+
focusRing: withAlpha(theme.colors.primary, 0.22),
|
|
171
|
+
mutedText: withAlpha(theme.colors.onSurface, 0.72)
|
|
111
172
|
};
|
|
112
|
-
}, [
|
|
173
|
+
}, [activeTheme]);
|
|
113
174
|
}
|
|
114
175
|
|
|
115
176
|
// src/components/Button.tsx
|
|
116
177
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
117
178
|
function Button({
|
|
118
|
-
sdk,
|
|
119
179
|
variant = "solid",
|
|
120
180
|
size = "md",
|
|
121
181
|
fullWidth = false,
|
|
@@ -137,18 +197,18 @@ function Button({
|
|
|
137
197
|
onTouchCancel,
|
|
138
198
|
...rest
|
|
139
199
|
}) {
|
|
140
|
-
const { theme } = useUiKitTheme(
|
|
200
|
+
const { theme } = useUiKitTheme();
|
|
141
201
|
const [isHovered, setIsHovered] = (0, import_react2.useState)(false);
|
|
142
202
|
const [isPressed, setIsPressed] = (0, import_react2.useState)(false);
|
|
143
203
|
const variantStyles = {
|
|
144
204
|
solid: {
|
|
145
205
|
backgroundColor: theme.colors.primary,
|
|
146
|
-
borderColor:
|
|
206
|
+
borderColor: withAlpha(theme.colors.primary, 0.5),
|
|
147
207
|
color: theme.colors.onPrimary
|
|
148
208
|
},
|
|
149
209
|
outline: {
|
|
150
210
|
backgroundColor: "transparent",
|
|
151
|
-
borderColor:
|
|
211
|
+
borderColor: withAlpha(theme.colors.text, 0.5),
|
|
152
212
|
color: theme.colors.onSurface
|
|
153
213
|
},
|
|
154
214
|
ghost: {
|
|
@@ -167,12 +227,12 @@ function Button({
|
|
|
167
227
|
},
|
|
168
228
|
outline: {
|
|
169
229
|
transform: isPressed ? "translateY(1px) scale(0.985)" : isHovered ? "translateY(-1px)" : "translateY(0)",
|
|
170
|
-
backgroundColor: isPressed ?
|
|
230
|
+
backgroundColor: isPressed ? withAlpha(interactiveColor, 0.14) : isHovered ? withAlpha(interactiveColor, 0.08) : "transparent",
|
|
171
231
|
boxShadow: "none"
|
|
172
232
|
},
|
|
173
233
|
ghost: {
|
|
174
234
|
transform: isPressed ? "translateY(1px) scale(0.985)" : isHovered ? "translateY(-1px)" : "translateY(0)",
|
|
175
|
-
backgroundColor: isPressed ?
|
|
235
|
+
backgroundColor: isPressed ? withAlpha(interactiveColor, 0.12) : isHovered ? withAlpha(interactiveColor, 0.06) : "transparent",
|
|
176
236
|
boxShadow: "none"
|
|
177
237
|
}
|
|
178
238
|
};
|
|
@@ -261,10 +321,8 @@ function Button({
|
|
|
261
321
|
}
|
|
262
322
|
|
|
263
323
|
// src/components/Card.tsx
|
|
264
|
-
var import_smartsell_sales_sdk3 = require("smartsell-sales-sdk");
|
|
265
324
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
266
325
|
function Card({
|
|
267
|
-
sdk,
|
|
268
326
|
children,
|
|
269
327
|
eyebrow,
|
|
270
328
|
title,
|
|
@@ -273,15 +331,15 @@ function Card({
|
|
|
273
331
|
style,
|
|
274
332
|
...rest
|
|
275
333
|
}) {
|
|
276
|
-
const { theme } = useUiKitTheme(
|
|
334
|
+
const { theme } = useUiKitTheme();
|
|
277
335
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
278
336
|
"div",
|
|
279
337
|
{
|
|
280
338
|
...rest,
|
|
281
339
|
style: {
|
|
282
340
|
borderRadius: 28,
|
|
283
|
-
border: `1px solid ${
|
|
284
|
-
background: `${
|
|
341
|
+
border: `1px solid ${withAlpha(theme.colors.text, 0.5)}`,
|
|
342
|
+
background: `${withAlpha(theme.colors.background, 0.7)}`,
|
|
285
343
|
color: theme.colors.text,
|
|
286
344
|
padding: padded ? 24 : void 0,
|
|
287
345
|
...style
|
|
@@ -335,13 +393,257 @@ function Card({
|
|
|
335
393
|
);
|
|
336
394
|
}
|
|
337
395
|
|
|
396
|
+
// src/components/Checkbox.tsx
|
|
397
|
+
var import_react3 = require("react");
|
|
398
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
399
|
+
var CHECKBOX_SIZE_BY_CONTROL_SIZE = {
|
|
400
|
+
sm: 18,
|
|
401
|
+
md: 20,
|
|
402
|
+
lg: 22
|
|
403
|
+
};
|
|
404
|
+
var getCheckboxSize = (controlSize) => CHECKBOX_SIZE_BY_CONTROL_SIZE[controlSize];
|
|
405
|
+
function CheckIcon({ size, color }) {
|
|
406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
407
|
+
"path",
|
|
408
|
+
{
|
|
409
|
+
d: "M5.75 10.25L8.5 13l5.75-6",
|
|
410
|
+
stroke: color,
|
|
411
|
+
strokeWidth: "1.8",
|
|
412
|
+
strokeLinecap: "round",
|
|
413
|
+
strokeLinejoin: "round"
|
|
414
|
+
}
|
|
415
|
+
) });
|
|
416
|
+
}
|
|
417
|
+
function MixedIcon({ size, color }) {
|
|
418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M5.5 10H14.5", stroke: color, strokeWidth: "1.8", strokeLinecap: "round" }) });
|
|
419
|
+
}
|
|
420
|
+
function CheckboxIndicator({
|
|
421
|
+
checked,
|
|
422
|
+
indeterminate = false,
|
|
423
|
+
disabled = false,
|
|
424
|
+
size = 20,
|
|
425
|
+
checkedColor,
|
|
426
|
+
iconColor,
|
|
427
|
+
uncheckedBorderColor,
|
|
428
|
+
uncheckedBackgroundColor = "transparent",
|
|
429
|
+
style
|
|
430
|
+
}) {
|
|
431
|
+
const isActive = checked || indeterminate;
|
|
432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
433
|
+
"span",
|
|
434
|
+
{
|
|
435
|
+
"aria-hidden": "true",
|
|
436
|
+
style: {
|
|
437
|
+
width: size,
|
|
438
|
+
height: size,
|
|
439
|
+
borderRadius: 999,
|
|
440
|
+
boxSizing: "border-box",
|
|
441
|
+
flexShrink: 0,
|
|
442
|
+
display: "inline-flex",
|
|
443
|
+
alignItems: "center",
|
|
444
|
+
justifyContent: "center",
|
|
445
|
+
border: `1.5px solid ${isActive ? checkedColor : uncheckedBorderColor}`,
|
|
446
|
+
backgroundColor: isActive ? checkedColor : uncheckedBackgroundColor,
|
|
447
|
+
opacity: disabled ? 0.45 : 1,
|
|
448
|
+
transition: "background-color 140ms ease, border-color 140ms ease, opacity 140ms ease",
|
|
449
|
+
...style
|
|
450
|
+
},
|
|
451
|
+
children: [
|
|
452
|
+
indeterminate ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MixedIcon, { size: Math.max(10, size - 6), color: iconColor }) : null,
|
|
453
|
+
!indeterminate && checked ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, { size: Math.max(10, size - 6), color: iconColor }) : null
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
function Checkbox({
|
|
459
|
+
label,
|
|
460
|
+
hint,
|
|
461
|
+
error,
|
|
462
|
+
controlSize = "md",
|
|
463
|
+
id,
|
|
464
|
+
checked,
|
|
465
|
+
defaultChecked,
|
|
466
|
+
disabled,
|
|
467
|
+
indeterminate = false,
|
|
468
|
+
required,
|
|
469
|
+
className,
|
|
470
|
+
style,
|
|
471
|
+
onChange,
|
|
472
|
+
onFocus,
|
|
473
|
+
onBlur,
|
|
474
|
+
...rest
|
|
475
|
+
}) {
|
|
476
|
+
const { theme, mutedText } = useUiKitTheme();
|
|
477
|
+
const controlMetrics = getControlMetrics(controlSize);
|
|
478
|
+
const indicatorSize = getCheckboxSize(controlSize);
|
|
479
|
+
const resolvedId = id != null ? id : `ss-checkbox-${(0, import_react3.useId)().replace(/:/g, "")}`;
|
|
480
|
+
const inputRef = (0, import_react3.useRef)(null);
|
|
481
|
+
const [isFocused, setIsFocused] = (0, import_react3.useState)(false);
|
|
482
|
+
const [internalChecked, setInternalChecked] = (0, import_react3.useState)(Boolean(defaultChecked));
|
|
483
|
+
const isControlled = checked !== void 0;
|
|
484
|
+
const resolvedChecked = isControlled ? Boolean(checked) : internalChecked;
|
|
485
|
+
(0, import_react3.useEffect)(() => {
|
|
486
|
+
if (!inputRef.current) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
inputRef.current.indeterminate = indeterminate;
|
|
490
|
+
}, [indeterminate, resolvedChecked]);
|
|
491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
492
|
+
"div",
|
|
493
|
+
{
|
|
494
|
+
className,
|
|
495
|
+
style: {
|
|
496
|
+
width: "100%",
|
|
497
|
+
display: "flex",
|
|
498
|
+
flexDirection: "column",
|
|
499
|
+
gap: 6,
|
|
500
|
+
...style
|
|
501
|
+
},
|
|
502
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
503
|
+
"label",
|
|
504
|
+
{
|
|
505
|
+
htmlFor: resolvedId,
|
|
506
|
+
style: {
|
|
507
|
+
display: "inline-flex",
|
|
508
|
+
alignItems: label || hint ? "flex-start" : "center",
|
|
509
|
+
gap: 10,
|
|
510
|
+
width: label || hint || error ? "100%" : "auto",
|
|
511
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
512
|
+
opacity: disabled ? 0.7 : 1,
|
|
513
|
+
userSelect: "none"
|
|
514
|
+
},
|
|
515
|
+
children: [
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
517
|
+
"span",
|
|
518
|
+
{
|
|
519
|
+
style: {
|
|
520
|
+
position: "relative",
|
|
521
|
+
display: "inline-flex",
|
|
522
|
+
alignItems: "center",
|
|
523
|
+
justifyContent: "center",
|
|
524
|
+
flexShrink: 0,
|
|
525
|
+
padding: 2,
|
|
526
|
+
marginTop: label || hint ? 1 : 0,
|
|
527
|
+
borderRadius: 999,
|
|
528
|
+
boxShadow: isFocused ? `0 0 0 3px ${withAlpha(theme.colors.primary, 0.16)}` : "none",
|
|
529
|
+
transition: "box-shadow 140ms ease"
|
|
530
|
+
},
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
533
|
+
"input",
|
|
534
|
+
{
|
|
535
|
+
...rest,
|
|
536
|
+
ref: inputRef,
|
|
537
|
+
id: resolvedId,
|
|
538
|
+
type: "checkbox",
|
|
539
|
+
checked: resolvedChecked,
|
|
540
|
+
disabled,
|
|
541
|
+
required,
|
|
542
|
+
onChange: (event) => {
|
|
543
|
+
if (!isControlled) {
|
|
544
|
+
setInternalChecked(event.currentTarget.checked);
|
|
545
|
+
}
|
|
546
|
+
onChange == null ? void 0 : onChange(event);
|
|
547
|
+
},
|
|
548
|
+
onFocus: (event) => {
|
|
549
|
+
setIsFocused(true);
|
|
550
|
+
onFocus == null ? void 0 : onFocus(event);
|
|
551
|
+
},
|
|
552
|
+
onBlur: (event) => {
|
|
553
|
+
setIsFocused(false);
|
|
554
|
+
onBlur == null ? void 0 : onBlur(event);
|
|
555
|
+
},
|
|
556
|
+
style: {
|
|
557
|
+
position: "absolute",
|
|
558
|
+
inset: 0,
|
|
559
|
+
width: "100%",
|
|
560
|
+
height: "100%",
|
|
561
|
+
margin: 0,
|
|
562
|
+
opacity: 0,
|
|
563
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
),
|
|
567
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
568
|
+
CheckboxIndicator,
|
|
569
|
+
{
|
|
570
|
+
checked: resolvedChecked,
|
|
571
|
+
indeterminate,
|
|
572
|
+
disabled,
|
|
573
|
+
size: indicatorSize,
|
|
574
|
+
checkedColor: theme.colors.primary,
|
|
575
|
+
iconColor: theme.colors.onPrimary,
|
|
576
|
+
uncheckedBorderColor: withAlpha(theme.colors.onSurface, 0.24),
|
|
577
|
+
uncheckedBackgroundColor: theme.colors.surface
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
),
|
|
583
|
+
label || hint || error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
584
|
+
"span",
|
|
585
|
+
{
|
|
586
|
+
style: {
|
|
587
|
+
display: "flex",
|
|
588
|
+
flexDirection: "column",
|
|
589
|
+
gap: 4,
|
|
590
|
+
minWidth: 0
|
|
591
|
+
},
|
|
592
|
+
children: [
|
|
593
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
594
|
+
"span",
|
|
595
|
+
{
|
|
596
|
+
style: {
|
|
597
|
+
color: theme.colors.onSurface,
|
|
598
|
+
fontSize: controlMetrics.fontSize,
|
|
599
|
+
lineHeight: controlMetrics.lineHeight,
|
|
600
|
+
fontWeight: 600
|
|
601
|
+
},
|
|
602
|
+
children: [
|
|
603
|
+
label,
|
|
604
|
+
required ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: theme.colors.negative, marginLeft: 4 }, children: "*" }) : null
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
) : null,
|
|
608
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
609
|
+
"span",
|
|
610
|
+
{
|
|
611
|
+
style: {
|
|
612
|
+
color: mutedText,
|
|
613
|
+
fontSize: 13,
|
|
614
|
+
lineHeight: 1.45
|
|
615
|
+
},
|
|
616
|
+
children: hint
|
|
617
|
+
}
|
|
618
|
+
) : null,
|
|
619
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
620
|
+
"span",
|
|
621
|
+
{
|
|
622
|
+
style: {
|
|
623
|
+
color: theme.colors.negative,
|
|
624
|
+
fontSize: 13,
|
|
625
|
+
lineHeight: 1.45,
|
|
626
|
+
fontWeight: 600
|
|
627
|
+
},
|
|
628
|
+
children: error
|
|
629
|
+
}
|
|
630
|
+
) : null
|
|
631
|
+
]
|
|
632
|
+
}
|
|
633
|
+
) : null
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
)
|
|
637
|
+
}
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
|
|
338
641
|
// src/components/ComposableModal.tsx
|
|
339
|
-
var
|
|
340
|
-
var import_smartsell_sales_sdk4 = require("smartsell-sales-sdk");
|
|
642
|
+
var import_react5 = require("react");
|
|
341
643
|
|
|
342
644
|
// src/components/Modal.tsx
|
|
343
|
-
var
|
|
344
|
-
var
|
|
645
|
+
var import_react4 = require("react");
|
|
646
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
345
647
|
var defaultThemeColors = {
|
|
346
648
|
background: "#f8fafc",
|
|
347
649
|
surface: "#ffffff",
|
|
@@ -354,13 +656,16 @@ var defaultThemeColors = {
|
|
|
354
656
|
negative: "#dc2626",
|
|
355
657
|
warning: "#d97706"
|
|
356
658
|
};
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
659
|
+
var srOnlyStyle = {
|
|
660
|
+
position: "absolute",
|
|
661
|
+
width: 1,
|
|
662
|
+
height: 1,
|
|
663
|
+
padding: 0,
|
|
664
|
+
margin: -1,
|
|
665
|
+
overflow: "hidden",
|
|
666
|
+
clip: "rect(0, 0, 0, 0)",
|
|
667
|
+
whiteSpace: "nowrap",
|
|
668
|
+
border: 0
|
|
364
669
|
};
|
|
365
670
|
var isUiKitThemeTokens = (theme) => {
|
|
366
671
|
return Boolean(theme && typeof theme === "object" && "theme" in theme);
|
|
@@ -374,12 +679,12 @@ var resolveTheme = (theme) => {
|
|
|
374
679
|
};
|
|
375
680
|
return {
|
|
376
681
|
colors,
|
|
377
|
-
borderSoft: isUiKitThemeTokens(theme) ? theme.borderSoft :
|
|
378
|
-
borderStrong: isUiKitThemeTokens(theme) ? theme.borderStrong :
|
|
379
|
-
surfaceMuted: isUiKitThemeTokens(theme) ? theme.surfaceMuted :
|
|
380
|
-
surfaceRaised: isUiKitThemeTokens(theme) ? theme.surfaceRaised :
|
|
381
|
-
overlay: isUiKitThemeTokens(theme) ? theme.overlay :
|
|
382
|
-
mutedText: isUiKitThemeTokens(theme) ? theme.mutedText :
|
|
682
|
+
borderSoft: isUiKitThemeTokens(theme) ? theme.borderSoft : withAlpha(colors.onSurface, 0.1),
|
|
683
|
+
borderStrong: isUiKitThemeTokens(theme) ? theme.borderStrong : withAlpha(colors.onSurface, 0.16),
|
|
684
|
+
surfaceMuted: isUiKitThemeTokens(theme) ? theme.surfaceMuted : withAlpha(colors.onSurface, 0.04),
|
|
685
|
+
surfaceRaised: isUiKitThemeTokens(theme) ? theme.surfaceRaised : withAlpha(colors.surface, 0.94),
|
|
686
|
+
overlay: isUiKitThemeTokens(theme) ? theme.overlay : withAlpha("#030712", 0.62),
|
|
687
|
+
mutedText: isUiKitThemeTokens(theme) ? theme.mutedText : withAlpha(colors.onSurface, 0.72)
|
|
383
688
|
};
|
|
384
689
|
};
|
|
385
690
|
var normalizeWidth = (maxWidth) => {
|
|
@@ -478,11 +783,12 @@ function ModalActionButton({
|
|
|
478
783
|
alignItems: "center",
|
|
479
784
|
justifyContent: "center",
|
|
480
785
|
borderRadius: "0.4rem",
|
|
481
|
-
padding: appearance === "link" ? 0 : "1.
|
|
786
|
+
padding: appearance === "link" ? 0 : "0.9rem 1.15rem",
|
|
482
787
|
boxSizing: "border-box",
|
|
483
788
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
484
789
|
fontWeight: 700,
|
|
485
|
-
fontSize: "1.
|
|
790
|
+
fontSize: "1.05rem",
|
|
791
|
+
lineHeight: 1.2,
|
|
486
792
|
margin: 0,
|
|
487
793
|
textAlign: "center",
|
|
488
794
|
transition: "0.5s",
|
|
@@ -503,14 +809,14 @@ function ModalActionButton({
|
|
|
503
809
|
buttonStyle.background = "none";
|
|
504
810
|
buttonStyle.border = `2px solid ${colors.primary}`;
|
|
505
811
|
buttonStyle.color = colors.primary;
|
|
506
|
-
buttonStyle.boxShadow = `0 14px 28px ${
|
|
812
|
+
buttonStyle.boxShadow = `0 14px 28px ${withAlpha(colors.onSurface, 0.08)}`;
|
|
507
813
|
} else {
|
|
508
814
|
buttonStyle.background = colors.primary;
|
|
509
815
|
buttonStyle.border = "1px solid transparent";
|
|
510
816
|
buttonStyle.color = colors.onPrimary;
|
|
511
|
-
buttonStyle.boxShadow = `0 14px 28px ${
|
|
817
|
+
buttonStyle.boxShadow = `0 14px 28px ${withAlpha(colors.primary, 0.22)}`;
|
|
512
818
|
}
|
|
513
|
-
return /* @__PURE__ */ (0,
|
|
819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
514
820
|
"div",
|
|
515
821
|
{
|
|
516
822
|
style: {
|
|
@@ -518,11 +824,11 @@ function ModalActionButton({
|
|
|
518
824
|
display: "flex",
|
|
519
825
|
alignItems: "center",
|
|
520
826
|
justifyContent: "center",
|
|
521
|
-
margin:
|
|
827
|
+
margin: 0,
|
|
522
828
|
marginBottom: (_b = style == null ? void 0 : style.marginBottom) != null ? _b : 0,
|
|
523
829
|
...style
|
|
524
830
|
},
|
|
525
|
-
children: /* @__PURE__ */ (0,
|
|
831
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
526
832
|
"button",
|
|
527
833
|
{
|
|
528
834
|
type: "button",
|
|
@@ -535,12 +841,68 @@ function ModalActionButton({
|
|
|
535
841
|
}
|
|
536
842
|
);
|
|
537
843
|
}
|
|
844
|
+
function ModalBusyIndicator({
|
|
845
|
+
theme
|
|
846
|
+
}) {
|
|
847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
848
|
+
"div",
|
|
849
|
+
{
|
|
850
|
+
"aria-live": "polite",
|
|
851
|
+
role: "status",
|
|
852
|
+
style: {
|
|
853
|
+
position: "relative",
|
|
854
|
+
display: "inline-flex",
|
|
855
|
+
alignItems: "center",
|
|
856
|
+
justifyContent: "center",
|
|
857
|
+
width: 56,
|
|
858
|
+
height: 56,
|
|
859
|
+
borderRadius: 999,
|
|
860
|
+
backgroundColor: withAlpha(theme.colors.surface, 0.88),
|
|
861
|
+
boxShadow: `0 18px 36px ${withAlpha(theme.colors.onSurface, 0.08)}`
|
|
862
|
+
},
|
|
863
|
+
children: [
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: srOnlyStyle, children: "Loading" }),
|
|
865
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { "aria-hidden": "true", width: "32", height: "32", viewBox: "0 0 40 40", fill: "none", children: [
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
867
|
+
"circle",
|
|
868
|
+
{
|
|
869
|
+
cx: "20",
|
|
870
|
+
cy: "20",
|
|
871
|
+
r: "16",
|
|
872
|
+
stroke: withAlpha(theme.colors.onSurface, 0.12),
|
|
873
|
+
strokeWidth: "4"
|
|
874
|
+
}
|
|
875
|
+
),
|
|
876
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
877
|
+
"path",
|
|
878
|
+
{
|
|
879
|
+
d: "M20 4C28.837 4 36 11.163 36 20",
|
|
880
|
+
stroke: theme.colors.primary,
|
|
881
|
+
strokeWidth: "4",
|
|
882
|
+
strokeLinecap: "round",
|
|
883
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
884
|
+
"animateTransform",
|
|
885
|
+
{
|
|
886
|
+
attributeName: "transform",
|
|
887
|
+
type: "rotate",
|
|
888
|
+
from: "0 20 20",
|
|
889
|
+
to: "360 20 20",
|
|
890
|
+
dur: "0.75s",
|
|
891
|
+
repeatCount: "indefinite"
|
|
892
|
+
}
|
|
893
|
+
)
|
|
894
|
+
}
|
|
895
|
+
)
|
|
896
|
+
] })
|
|
897
|
+
]
|
|
898
|
+
}
|
|
899
|
+
);
|
|
900
|
+
}
|
|
538
901
|
function UnifiedModal({
|
|
539
902
|
isOpen,
|
|
540
903
|
onClose,
|
|
541
904
|
children,
|
|
542
905
|
title,
|
|
543
|
-
description,
|
|
544
906
|
headerContent,
|
|
545
907
|
footer,
|
|
546
908
|
confirmAction,
|
|
@@ -560,10 +922,11 @@ function UnifiedModal({
|
|
|
560
922
|
theme
|
|
561
923
|
}) {
|
|
562
924
|
var _a, _b;
|
|
563
|
-
const modalTheme = (0,
|
|
564
|
-
const [isMaximized, setIsMaximized] = (0,
|
|
565
|
-
const titleId = (0,
|
|
566
|
-
|
|
925
|
+
const modalTheme = (0, import_react4.useMemo)(() => resolveTheme(theme), [theme]);
|
|
926
|
+
const [isMaximized, setIsMaximized] = (0, import_react4.useState)(maximized != null ? maximized : false);
|
|
927
|
+
const titleId = (0, import_react4.useMemo)(() => createTitleId(title), [title]);
|
|
928
|
+
const shouldDisableDismiss = disableDismiss || isBusy;
|
|
929
|
+
(0, import_react4.useEffect)(() => {
|
|
567
930
|
if (typeof maximized === "boolean") {
|
|
568
931
|
setIsMaximized(maximized);
|
|
569
932
|
return;
|
|
@@ -572,14 +935,14 @@ function UnifiedModal({
|
|
|
572
935
|
setIsMaximized(true);
|
|
573
936
|
}
|
|
574
937
|
}, [maximized]);
|
|
575
|
-
(0,
|
|
938
|
+
(0, import_react4.useEffect)(() => {
|
|
576
939
|
if (!isOpen || typeof window === "undefined" || typeof document === "undefined") {
|
|
577
940
|
return;
|
|
578
941
|
}
|
|
579
942
|
const previousOverflow = document.body.style.overflow;
|
|
580
943
|
document.body.style.overflow = "hidden";
|
|
581
944
|
const handleKeyDown = (event) => {
|
|
582
|
-
if (!
|
|
945
|
+
if (!shouldDisableDismiss && closeOnEscape && event.key === "Escape") {
|
|
583
946
|
onClose();
|
|
584
947
|
}
|
|
585
948
|
};
|
|
@@ -588,53 +951,54 @@ function UnifiedModal({
|
|
|
588
951
|
document.body.style.overflow = previousOverflow;
|
|
589
952
|
window.removeEventListener("keydown", handleKeyDown);
|
|
590
953
|
};
|
|
591
|
-
}, [closeOnEscape,
|
|
954
|
+
}, [closeOnEscape, isOpen, onClose, shouldDisableDismiss]);
|
|
592
955
|
if (!isOpen) {
|
|
593
956
|
return null;
|
|
594
957
|
}
|
|
595
|
-
const resolvedHeader = headerContent != null ? headerContent : /* @__PURE__ */ (0,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
) : null,
|
|
610
|
-
description ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
611
|
-
"p",
|
|
612
|
-
{
|
|
613
|
-
style: {
|
|
614
|
-
margin: 0,
|
|
615
|
-
color: modalTheme.mutedText,
|
|
616
|
-
fontSize: 15,
|
|
617
|
-
lineHeight: 1.6
|
|
618
|
-
},
|
|
619
|
-
children: description
|
|
620
|
-
}
|
|
621
|
-
) : null
|
|
622
|
-
] });
|
|
958
|
+
const resolvedHeader = headerContent != null ? headerContent : title ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
959
|
+
"h2",
|
|
960
|
+
{
|
|
961
|
+
id: titleId,
|
|
962
|
+
style: {
|
|
963
|
+
margin: 0,
|
|
964
|
+
color: modalTheme.colors.onSurface,
|
|
965
|
+
fontSize: 30,
|
|
966
|
+
fontWeight: 800,
|
|
967
|
+
lineHeight: 1.1
|
|
968
|
+
},
|
|
969
|
+
children: title
|
|
970
|
+
}
|
|
971
|
+
) : null;
|
|
623
972
|
let footerContent = footer;
|
|
624
973
|
if (footerContent === void 0) {
|
|
625
974
|
if (closeAction && !closeAction.hidden) {
|
|
626
|
-
footerContent = /* @__PURE__ */ (0,
|
|
975
|
+
footerContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
976
|
+
ModalActionButton,
|
|
977
|
+
{
|
|
978
|
+
action: { ...closeAction, disabled: closeAction.disabled || isBusy },
|
|
979
|
+
theme: modalTheme
|
|
980
|
+
}
|
|
981
|
+
);
|
|
627
982
|
} else {
|
|
628
983
|
const resolvedActions = [
|
|
629
|
-
cancelAction ? {
|
|
984
|
+
cancelAction ? {
|
|
985
|
+
...cancelAction,
|
|
986
|
+
appearance: (_a = cancelAction.appearance) != null ? _a : "text",
|
|
987
|
+
disabled: cancelAction.disabled || isBusy
|
|
988
|
+
} : void 0,
|
|
630
989
|
...(extraActions != null ? extraActions : []).map((action) => {
|
|
631
990
|
var _a2;
|
|
632
991
|
return {
|
|
633
992
|
...action,
|
|
634
|
-
appearance: (_a2 = action.appearance) != null ? _a2 : "contained"
|
|
993
|
+
appearance: (_a2 = action.appearance) != null ? _a2 : "contained",
|
|
994
|
+
disabled: action.disabled || isBusy
|
|
635
995
|
};
|
|
636
996
|
}),
|
|
637
|
-
confirmAction ? {
|
|
997
|
+
confirmAction ? {
|
|
998
|
+
...confirmAction,
|
|
999
|
+
appearance: (_b = confirmAction.appearance) != null ? _b : "contained",
|
|
1000
|
+
disabled: confirmAction.disabled || isBusy
|
|
1001
|
+
} : void 0
|
|
638
1002
|
].reduce((items, action) => {
|
|
639
1003
|
if (!action || action.hidden) {
|
|
640
1004
|
return items;
|
|
@@ -642,7 +1006,7 @@ function UnifiedModal({
|
|
|
642
1006
|
items.push(action);
|
|
643
1007
|
return items;
|
|
644
1008
|
}, []);
|
|
645
|
-
footerContent = resolvedActions.length > 0 ? resolvedActions.map((action, index) => /* @__PURE__ */ (0,
|
|
1009
|
+
footerContent = resolvedActions.length > 0 ? resolvedActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
646
1010
|
ModalActionButton,
|
|
647
1011
|
{
|
|
648
1012
|
action,
|
|
@@ -653,15 +1017,16 @@ function UnifiedModal({
|
|
|
653
1017
|
}
|
|
654
1018
|
}
|
|
655
1019
|
const shouldRenderFooter = footerContent !== void 0 && footerContent !== null && footerContent !== false;
|
|
656
|
-
return /* @__PURE__ */ (0,
|
|
1020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
657
1021
|
"div",
|
|
658
1022
|
{
|
|
659
1023
|
"aria-label": headerContent ? typeof title === "string" ? title : "Dialog" : void 0,
|
|
660
1024
|
"aria-labelledby": headerContent ? void 0 : title ? titleId : void 0,
|
|
1025
|
+
"aria-busy": isBusy,
|
|
661
1026
|
"aria-modal": "true",
|
|
662
1027
|
role: "dialog",
|
|
663
1028
|
onMouseDown: (event) => {
|
|
664
|
-
if (!
|
|
1029
|
+
if (!shouldDisableDismiss && closeOnBackdrop && event.target === event.currentTarget) {
|
|
665
1030
|
onClose();
|
|
666
1031
|
}
|
|
667
1032
|
},
|
|
@@ -676,10 +1041,9 @@ function UnifiedModal({
|
|
|
676
1041
|
backgroundColor: modalTheme.overlay,
|
|
677
1042
|
backdropFilter: "blur(8px)"
|
|
678
1043
|
},
|
|
679
|
-
children: /* @__PURE__ */ (0,
|
|
1044
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
680
1045
|
"div",
|
|
681
1046
|
{
|
|
682
|
-
id: isBusy ? "ldg1" : void 0,
|
|
683
1047
|
style: {
|
|
684
1048
|
position: "relative",
|
|
685
1049
|
display: "flex",
|
|
@@ -692,28 +1056,37 @@ function UnifiedModal({
|
|
|
692
1056
|
borderRadius: isMaximized ? 0 : 30,
|
|
693
1057
|
border: `1px solid ${modalTheme.borderSoft}`,
|
|
694
1058
|
background: `linear-gradient(180deg, ${modalTheme.surfaceRaised}, ${modalTheme.colors.surface})`,
|
|
695
|
-
boxShadow: `0 34px 80px ${
|
|
1059
|
+
boxShadow: `0 34px 80px ${withAlpha("#020617", 0.28)}`,
|
|
696
1060
|
color: modalTheme.colors.onSurface,
|
|
697
1061
|
overflow: "hidden",
|
|
698
|
-
opacity: isBusy ? 0.5 : 1,
|
|
699
1062
|
...contentStyle
|
|
700
1063
|
},
|
|
701
1064
|
children: [
|
|
702
|
-
/* @__PURE__ */ (0,
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
703
1066
|
"div",
|
|
704
1067
|
{
|
|
705
1068
|
style: {
|
|
706
1069
|
display: "flex",
|
|
707
1070
|
alignItems: "flex-start",
|
|
708
1071
|
justifyContent: "space-between",
|
|
709
|
-
gap:
|
|
710
|
-
padding: "
|
|
711
|
-
borderBottom: `1px solid ${
|
|
1072
|
+
gap: 12,
|
|
1073
|
+
padding: "18px 20px 12px",
|
|
1074
|
+
borderBottom: `1px solid ${withAlpha(modalTheme.colors.onSurface, 0.06)}`
|
|
712
1075
|
},
|
|
713
1076
|
children: [
|
|
714
|
-
/* @__PURE__ */ (0,
|
|
715
|
-
|
|
716
|
-
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1078
|
+
"div",
|
|
1079
|
+
{
|
|
1080
|
+
style: {
|
|
1081
|
+
flex: 1,
|
|
1082
|
+
opacity: isBusy ? 0.38 : 1,
|
|
1083
|
+
transition: "opacity 180ms ease"
|
|
1084
|
+
},
|
|
1085
|
+
children: resolvedHeader
|
|
1086
|
+
}
|
|
1087
|
+
),
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
1089
|
+
!hideExpandButton ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
717
1090
|
"button",
|
|
718
1091
|
{
|
|
719
1092
|
"aria-label": isMaximized ? "Minimize modal" : "Maximize modal",
|
|
@@ -721,8 +1094,8 @@ function UnifiedModal({
|
|
|
721
1094
|
type: "button",
|
|
722
1095
|
onClick: () => setIsMaximized((current) => !current),
|
|
723
1096
|
style: {
|
|
724
|
-
height:
|
|
725
|
-
width:
|
|
1097
|
+
height: 40,
|
|
1098
|
+
width: 40,
|
|
726
1099
|
borderRadius: 999,
|
|
727
1100
|
border: `1px solid ${modalTheme.borderSoft}`,
|
|
728
1101
|
backgroundColor: "transparent",
|
|
@@ -734,23 +1107,23 @@ function UnifiedModal({
|
|
|
734
1107
|
children: isMaximized ? "\u25A2" : "\u25A1"
|
|
735
1108
|
}
|
|
736
1109
|
) : null,
|
|
737
|
-
!hideCloseButton ? /* @__PURE__ */ (0,
|
|
1110
|
+
!hideCloseButton ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
738
1111
|
"button",
|
|
739
1112
|
{
|
|
740
1113
|
"aria-label": "Close modal",
|
|
741
1114
|
type: "button",
|
|
742
|
-
onClick:
|
|
1115
|
+
onClick: shouldDisableDismiss ? void 0 : onClose,
|
|
743
1116
|
style: {
|
|
744
|
-
height:
|
|
745
|
-
width:
|
|
1117
|
+
height: 40,
|
|
1118
|
+
width: 40,
|
|
746
1119
|
borderRadius: 999,
|
|
747
1120
|
border: `1px solid ${modalTheme.borderSoft}`,
|
|
748
1121
|
backgroundColor: "transparent",
|
|
749
1122
|
color: modalTheme.colors.onSurface,
|
|
750
|
-
cursor:
|
|
1123
|
+
cursor: shouldDisableDismiss ? "not-allowed" : "pointer",
|
|
751
1124
|
fontSize: 20,
|
|
752
1125
|
fontWeight: 700,
|
|
753
|
-
opacity:
|
|
1126
|
+
opacity: shouldDisableDismiss ? 0.5 : 1
|
|
754
1127
|
},
|
|
755
1128
|
children: "\xD7"
|
|
756
1129
|
}
|
|
@@ -759,28 +1132,57 @@ function UnifiedModal({
|
|
|
759
1132
|
]
|
|
760
1133
|
}
|
|
761
1134
|
),
|
|
762
|
-
/* @__PURE__ */ (0,
|
|
1135
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
763
1136
|
"div",
|
|
764
1137
|
{
|
|
765
1138
|
style: {
|
|
766
1139
|
flex: 1,
|
|
767
1140
|
minHeight: 0,
|
|
1141
|
+
position: "relative",
|
|
768
1142
|
overflow: "auto",
|
|
769
1143
|
padding: 24,
|
|
770
1144
|
...bodyStyle
|
|
771
1145
|
},
|
|
772
|
-
children
|
|
1146
|
+
children: [
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1148
|
+
"div",
|
|
1149
|
+
{
|
|
1150
|
+
style: {
|
|
1151
|
+
opacity: isBusy ? 0.38 : 1,
|
|
1152
|
+
filter: isBusy ? "saturate(0.8)" : "none",
|
|
1153
|
+
pointerEvents: isBusy ? "none" : "auto",
|
|
1154
|
+
transition: "opacity 180ms ease, filter 180ms ease"
|
|
1155
|
+
},
|
|
1156
|
+
children
|
|
1157
|
+
}
|
|
1158
|
+
),
|
|
1159
|
+
isBusy ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1160
|
+
"div",
|
|
1161
|
+
{
|
|
1162
|
+
style: {
|
|
1163
|
+
position: "absolute",
|
|
1164
|
+
inset: 0,
|
|
1165
|
+
display: "flex",
|
|
1166
|
+
alignItems: "center",
|
|
1167
|
+
justifyContent: "center",
|
|
1168
|
+
backgroundColor: withAlpha(modalTheme.colors.surface, 0.58),
|
|
1169
|
+
backdropFilter: "blur(2px)"
|
|
1170
|
+
},
|
|
1171
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ModalBusyIndicator, { theme: modalTheme })
|
|
1172
|
+
}
|
|
1173
|
+
) : null
|
|
1174
|
+
]
|
|
773
1175
|
}
|
|
774
1176
|
),
|
|
775
|
-
shouldRenderFooter ? /* @__PURE__ */ (0,
|
|
1177
|
+
shouldRenderFooter ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
776
1178
|
"div",
|
|
777
1179
|
{
|
|
778
1180
|
style: {
|
|
779
1181
|
display: "flex",
|
|
780
1182
|
justifyContent: "flex-end",
|
|
781
|
-
gap:
|
|
782
|
-
padding: "
|
|
783
|
-
borderTop: `1px solid ${
|
|
1183
|
+
gap: 10,
|
|
1184
|
+
padding: "12px 20px 16px",
|
|
1185
|
+
borderTop: `1px solid ${withAlpha(modalTheme.colors.onSurface, 0.06)}`
|
|
784
1186
|
},
|
|
785
1187
|
children: footerContent
|
|
786
1188
|
}
|
|
@@ -792,23 +1194,22 @@ function UnifiedModal({
|
|
|
792
1194
|
);
|
|
793
1195
|
}
|
|
794
1196
|
function Modal(props) {
|
|
795
|
-
return /* @__PURE__ */ (0,
|
|
1197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UnifiedModal, { ...normalizeModalProps(props) });
|
|
796
1198
|
}
|
|
797
1199
|
|
|
798
1200
|
// src/components/ComposableModal.tsx
|
|
799
|
-
var
|
|
1201
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
800
1202
|
var createModalSlotIds = (slotBaseId) => ({
|
|
801
1203
|
header: `${slotBaseId}:modal-header`,
|
|
802
1204
|
body: `${slotBaseId}:modal-body`,
|
|
803
1205
|
footer: `${slotBaseId}:modal-footer`
|
|
804
1206
|
});
|
|
805
1207
|
function ComposableModal({
|
|
806
|
-
sdk,
|
|
807
1208
|
isOpen,
|
|
808
1209
|
onClose,
|
|
809
1210
|
title,
|
|
810
|
-
description,
|
|
811
1211
|
slotBaseId,
|
|
1212
|
+
renderSlot,
|
|
812
1213
|
payload,
|
|
813
1214
|
onConfirm,
|
|
814
1215
|
confirmLabel = "Confirm",
|
|
@@ -824,12 +1225,11 @@ function ComposableModal({
|
|
|
824
1225
|
footerFallback,
|
|
825
1226
|
children
|
|
826
1227
|
}) {
|
|
827
|
-
const theme = useUiKitTheme(
|
|
1228
|
+
const theme = useUiKitTheme();
|
|
828
1229
|
const slotIds = createModalSlotIds(slotBaseId);
|
|
829
|
-
const context = (0,
|
|
1230
|
+
const context = (0, import_react5.useMemo)(
|
|
830
1231
|
() => ({
|
|
831
1232
|
title,
|
|
832
|
-
description,
|
|
833
1233
|
payload,
|
|
834
1234
|
close: onClose,
|
|
835
1235
|
confirm: onConfirm,
|
|
@@ -838,48 +1238,44 @@ function ComposableModal({
|
|
|
838
1238
|
isOpen,
|
|
839
1239
|
isBusy
|
|
840
1240
|
}),
|
|
841
|
-
[cancelLabel, confirmLabel,
|
|
1241
|
+
[cancelLabel, confirmLabel, isBusy, isOpen, onClose, onConfirm, payload, title]
|
|
842
1242
|
);
|
|
843
|
-
const defaultFooter = hideDefaultFooter ? void 0 : footerFallback != null ? footerFallback : /* @__PURE__ */ (0,
|
|
844
|
-
/* @__PURE__ */ (0,
|
|
845
|
-
onConfirm ? /* @__PURE__ */ (0,
|
|
1243
|
+
const defaultFooter = hideDefaultFooter ? void 0 : footerFallback != null ? footerFallback : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { variant: "outline", onClick: onClose, disabled: isBusy, children: cancelLabel }),
|
|
1245
|
+
onConfirm ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { onClick: onConfirm, disabled: isBusy, children: confirmLabel }) : null
|
|
846
1246
|
] });
|
|
847
|
-
const defaultHeader = headerFallback != null ? headerFallback : /* @__PURE__ */ (0,
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
{
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
const headerContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_smartsell_sales_sdk4.SlotRenderer, { id: slotIds.header, sdk, context, children: defaultHeader });
|
|
874
|
-
const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_smartsell_sales_sdk4.SlotRenderer, { id: slotIds.body, sdk, context, children });
|
|
875
|
-
const footerContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_smartsell_sales_sdk4.SlotRenderer, { id: slotIds.footer, sdk, context, children: defaultFooter });
|
|
876
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1247
|
+
const defaultHeader = headerFallback != null ? headerFallback : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1248
|
+
"h2",
|
|
1249
|
+
{
|
|
1250
|
+
style: {
|
|
1251
|
+
margin: 0,
|
|
1252
|
+
fontSize: 30,
|
|
1253
|
+
fontWeight: 800,
|
|
1254
|
+
lineHeight: 1.1
|
|
1255
|
+
},
|
|
1256
|
+
children: title
|
|
1257
|
+
}
|
|
1258
|
+
);
|
|
1259
|
+
const renderSlotContent = (id, slotChildren) => {
|
|
1260
|
+
if (!renderSlot) {
|
|
1261
|
+
return slotChildren;
|
|
1262
|
+
}
|
|
1263
|
+
return renderSlot({
|
|
1264
|
+
id,
|
|
1265
|
+
context,
|
|
1266
|
+
children: slotChildren
|
|
1267
|
+
});
|
|
1268
|
+
};
|
|
1269
|
+
const headerContent = renderSlotContent(slotIds.header, defaultHeader);
|
|
1270
|
+
const bodyContent = renderSlotContent(slotIds.body, children);
|
|
1271
|
+
const footerContent = renderSlotContent(slotIds.footer, defaultFooter);
|
|
1272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
877
1273
|
Modal,
|
|
878
1274
|
{
|
|
879
1275
|
isOpen,
|
|
880
1276
|
onClose,
|
|
881
1277
|
title,
|
|
882
|
-
|
|
1278
|
+
isBusy,
|
|
883
1279
|
headerContent,
|
|
884
1280
|
footer: footerContent,
|
|
885
1281
|
theme,
|
|
@@ -893,10 +1289,12 @@ function ComposableModal({
|
|
|
893
1289
|
);
|
|
894
1290
|
}
|
|
895
1291
|
|
|
1292
|
+
// src/components/DatePicker.tsx
|
|
1293
|
+
var import_react7 = require("react");
|
|
1294
|
+
|
|
896
1295
|
// src/components/Input.tsx
|
|
897
|
-
var
|
|
898
|
-
var
|
|
899
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1296
|
+
var import_react6 = require("react");
|
|
1297
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
900
1298
|
var PASSWORD_TOGGLE_METRICS_BY_SIZE = {
|
|
901
1299
|
sm: {
|
|
902
1300
|
buttonSize: 18,
|
|
@@ -919,7 +1317,6 @@ var PASSWORD_TOGGLE_METRICS_BY_SIZE = {
|
|
|
919
1317
|
};
|
|
920
1318
|
var getPasswordToggleMetrics = (size) => PASSWORD_TOGGLE_METRICS_BY_SIZE[size];
|
|
921
1319
|
function ControlFrame({
|
|
922
|
-
sdk,
|
|
923
1320
|
label,
|
|
924
1321
|
hint,
|
|
925
1322
|
error,
|
|
@@ -929,10 +1326,10 @@ function ControlFrame({
|
|
|
929
1326
|
children,
|
|
930
1327
|
style
|
|
931
1328
|
}) {
|
|
1329
|
+
const { theme, mutedText } = useUiKitTheme();
|
|
932
1330
|
if (!label && !hint && !error) {
|
|
933
|
-
return /* @__PURE__ */ (0,
|
|
1331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children });
|
|
934
1332
|
}
|
|
935
|
-
const { theme, mutedText } = useUiKitTheme(sdk);
|
|
936
1333
|
const labelStyle = {
|
|
937
1334
|
color: theme.colors.onSurface,
|
|
938
1335
|
fontSize: 14,
|
|
@@ -947,13 +1344,13 @@ function ControlFrame({
|
|
|
947
1344
|
...style
|
|
948
1345
|
};
|
|
949
1346
|
if (!useLabelWrapper) {
|
|
950
|
-
return /* @__PURE__ */ (0,
|
|
951
|
-
label || hint ? /* @__PURE__ */ (0,
|
|
952
|
-
label ? /* @__PURE__ */ (0,
|
|
1347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: wrapperStyle, children: [
|
|
1348
|
+
label || hint ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
|
|
1349
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { htmlFor, style: labelStyle, children: [
|
|
953
1350
|
label,
|
|
954
|
-
required ? /* @__PURE__ */ (0,
|
|
1351
|
+
required ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { color: theme.colors.negative, marginLeft: 4 }, children: "*" }) : null
|
|
955
1352
|
] }) : null,
|
|
956
|
-
hint ? /* @__PURE__ */ (0,
|
|
1353
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
957
1354
|
"span",
|
|
958
1355
|
{
|
|
959
1356
|
style: {
|
|
@@ -966,7 +1363,7 @@ function ControlFrame({
|
|
|
966
1363
|
) : null
|
|
967
1364
|
] }) : null,
|
|
968
1365
|
children,
|
|
969
|
-
error ? /* @__PURE__ */ (0,
|
|
1366
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
970
1367
|
"span",
|
|
971
1368
|
{
|
|
972
1369
|
style: {
|
|
@@ -980,13 +1377,13 @@ function ControlFrame({
|
|
|
980
1377
|
) : null
|
|
981
1378
|
] });
|
|
982
1379
|
}
|
|
983
|
-
return /* @__PURE__ */ (0,
|
|
984
|
-
label || hint ? /* @__PURE__ */ (0,
|
|
985
|
-
label ? /* @__PURE__ */ (0,
|
|
1380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { htmlFor, style: wrapperStyle, children: [
|
|
1381
|
+
label || hint ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
|
|
1382
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { style: labelStyle, children: [
|
|
986
1383
|
label,
|
|
987
|
-
required ? /* @__PURE__ */ (0,
|
|
1384
|
+
required ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { color: theme.colors.negative, marginLeft: 4 }, children: "*" }) : null
|
|
988
1385
|
] }) : null,
|
|
989
|
-
hint ? /* @__PURE__ */ (0,
|
|
1386
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
990
1387
|
"span",
|
|
991
1388
|
{
|
|
992
1389
|
style: {
|
|
@@ -999,7 +1396,7 @@ function ControlFrame({
|
|
|
999
1396
|
) : null
|
|
1000
1397
|
] }) : null,
|
|
1001
1398
|
children,
|
|
1002
|
-
error ? /* @__PURE__ */ (0,
|
|
1399
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1003
1400
|
"span",
|
|
1004
1401
|
{
|
|
1005
1402
|
style: {
|
|
@@ -1014,7 +1411,6 @@ function ControlFrame({
|
|
|
1014
1411
|
] });
|
|
1015
1412
|
}
|
|
1016
1413
|
function Input({
|
|
1017
|
-
sdk,
|
|
1018
1414
|
label,
|
|
1019
1415
|
hint,
|
|
1020
1416
|
error,
|
|
@@ -1026,10 +1422,10 @@ function Input({
|
|
|
1026
1422
|
type = "text",
|
|
1027
1423
|
...rest
|
|
1028
1424
|
}) {
|
|
1029
|
-
const { theme,
|
|
1425
|
+
const { theme, focusRing } = useUiKitTheme();
|
|
1030
1426
|
const controlMetrics = getControlMetrics(controlSize);
|
|
1031
1427
|
const passwordToggleMetrics = getPasswordToggleMetrics(controlSize);
|
|
1032
|
-
const [isPasswordVisible, setIsPasswordVisible] = (0,
|
|
1428
|
+
const [isPasswordVisible, setIsPasswordVisible] = (0, import_react6.useState)(false);
|
|
1033
1429
|
const isPasswordField = type === "password";
|
|
1034
1430
|
const canTogglePasswordVisibility = isPasswordField && showPasswordToggle;
|
|
1035
1431
|
const passwordToggleInset = Math.max(
|
|
@@ -1043,7 +1439,7 @@ function Input({
|
|
|
1043
1439
|
boxSizing: "border-box",
|
|
1044
1440
|
height: controlMetrics.height,
|
|
1045
1441
|
borderRadius: 16,
|
|
1046
|
-
border: `1px solid ${error ? theme.colors.negative :
|
|
1442
|
+
border: `1px solid ${error ? theme.colors.negative : withAlpha(theme.colors.textLight, 0.5)}`,
|
|
1047
1443
|
backgroundColor: theme.colors.surface,
|
|
1048
1444
|
color: theme.colors.text,
|
|
1049
1445
|
cursor: disabled ? "not-allowed" : "text",
|
|
@@ -1052,12 +1448,12 @@ function Input({
|
|
|
1052
1448
|
outline: "none",
|
|
1053
1449
|
fontSize: controlMetrics.fontSize,
|
|
1054
1450
|
lineHeight: controlMetrics.lineHeight,
|
|
1055
|
-
boxShadow: error ? `0 0 0 3px ${
|
|
1451
|
+
boxShadow: error ? `0 0 0 3px ${withAlpha(theme.colors.negative, 0.12)}` : `0 0 0 0 ${focusRing}`,
|
|
1056
1452
|
transition: "border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease",
|
|
1057
1453
|
...style
|
|
1058
1454
|
};
|
|
1059
|
-
const input = canTogglePasswordVisibility ? /* @__PURE__ */ (0,
|
|
1060
|
-
/* @__PURE__ */ (0,
|
|
1455
|
+
const input = canTogglePasswordVisibility ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
1456
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1061
1457
|
"button",
|
|
1062
1458
|
{
|
|
1063
1459
|
type: "button",
|
|
@@ -1090,7 +1486,7 @@ function Input({
|
|
|
1090
1486
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
1091
1487
|
opacity: disabled ? 0.5 : 1
|
|
1092
1488
|
},
|
|
1093
|
-
children: isPasswordVisible ? /* @__PURE__ */ (0,
|
|
1489
|
+
children: isPasswordVisible ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1094
1490
|
"svg",
|
|
1095
1491
|
{
|
|
1096
1492
|
width: passwordToggleMetrics.iconSize,
|
|
@@ -1099,7 +1495,7 @@ function Input({
|
|
|
1099
1495
|
fill: "none",
|
|
1100
1496
|
"aria-hidden": "true",
|
|
1101
1497
|
children: [
|
|
1102
|
-
/* @__PURE__ */ (0,
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1103
1499
|
"path",
|
|
1104
1500
|
{
|
|
1105
1501
|
d: "M2.5 3.5L17.5 16.5",
|
|
@@ -1108,7 +1504,7 @@ function Input({
|
|
|
1108
1504
|
strokeLinecap: "round"
|
|
1109
1505
|
}
|
|
1110
1506
|
),
|
|
1111
|
-
/* @__PURE__ */ (0,
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1112
1508
|
"path",
|
|
1113
1509
|
{
|
|
1114
1510
|
d: "M8.825 8.786a2 2 0 0 0 2.389 2.389",
|
|
@@ -1118,7 +1514,7 @@ function Input({
|
|
|
1118
1514
|
strokeLinejoin: "round"
|
|
1119
1515
|
}
|
|
1120
1516
|
),
|
|
1121
|
-
/* @__PURE__ */ (0,
|
|
1517
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1122
1518
|
"path",
|
|
1123
1519
|
{
|
|
1124
1520
|
d: "M4.42 6.774C3.422 7.73 2.777 8.815 2.5 9.375c1.182 2.39 3.934 5.625 7.5 5.625 1.155 0 2.224-.34 3.166-.847",
|
|
@@ -1128,7 +1524,7 @@ function Input({
|
|
|
1128
1524
|
strokeLinejoin: "round"
|
|
1129
1525
|
}
|
|
1130
1526
|
),
|
|
1131
|
-
/* @__PURE__ */ (0,
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1132
1528
|
"path",
|
|
1133
1529
|
{
|
|
1134
1530
|
d: "M7.043 4.455A7.7 7.7 0 0 1 10 3.75c3.566 0 6.318 3.235 7.5 5.625-.39.787-1.504 2.588-3.259 3.986",
|
|
@@ -1140,7 +1536,7 @@ function Input({
|
|
|
1140
1536
|
)
|
|
1141
1537
|
]
|
|
1142
1538
|
}
|
|
1143
|
-
) : /* @__PURE__ */ (0,
|
|
1539
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1144
1540
|
"svg",
|
|
1145
1541
|
{
|
|
1146
1542
|
width: passwordToggleMetrics.iconSize,
|
|
@@ -1149,7 +1545,7 @@ function Input({
|
|
|
1149
1545
|
fill: "none",
|
|
1150
1546
|
"aria-hidden": "true",
|
|
1151
1547
|
children: [
|
|
1152
|
-
/* @__PURE__ */ (0,
|
|
1548
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1153
1549
|
"path",
|
|
1154
1550
|
{
|
|
1155
1551
|
d: "M2.5 10c1.182-2.39 3.934-5.625 7.5-5.625S16.318 7.61 17.5 10c-1.182 2.39-3.934 5.625-7.5 5.625S3.682 12.39 2.5 10Z",
|
|
@@ -1159,21 +1555,598 @@ function Input({
|
|
|
1159
1555
|
strokeLinejoin: "round"
|
|
1160
1556
|
}
|
|
1161
1557
|
),
|
|
1162
|
-
/* @__PURE__ */ (0,
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "10", cy: "10", r: "2.25", stroke: "currentColor", strokeWidth: "1.8" })
|
|
1163
1559
|
]
|
|
1164
1560
|
}
|
|
1165
1561
|
)
|
|
1166
1562
|
}
|
|
1167
1563
|
),
|
|
1168
|
-
/* @__PURE__ */ (0,
|
|
1169
|
-
] }) : /* @__PURE__ */ (0,
|
|
1170
|
-
return /* @__PURE__ */ (0,
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ...rest, id, type: resolvedType, disabled, style: inputStyle })
|
|
1565
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ...rest, id, type: resolvedType, disabled, style: inputStyle });
|
|
1566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ControlFrame, { label, hint, error, htmlFor: id, required: rest.required, children: input });
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// src/components/DatePicker.tsx
|
|
1570
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1571
|
+
var DEFAULT_FORMAT_BY_MODE = {
|
|
1572
|
+
date: "DD/MM/YYYY",
|
|
1573
|
+
datetime: "DD/MM/YYYY HH:mm"
|
|
1574
|
+
};
|
|
1575
|
+
var HTML_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
1576
|
+
var HTML_DATETIME_PATTERN = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::\d{2})?$/;
|
|
1577
|
+
var FORMAT_TOKENS = [
|
|
1578
|
+
{
|
|
1579
|
+
token: "YYYY",
|
|
1580
|
+
key: "year",
|
|
1581
|
+
pattern: "(\\d{4})",
|
|
1582
|
+
formatter: (date) => String(date.getFullYear())
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
token: "MM",
|
|
1586
|
+
key: "month",
|
|
1587
|
+
pattern: "(\\d{1,2})",
|
|
1588
|
+
formatter: (date) => padNumber(date.getMonth() + 1)
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
token: "DD",
|
|
1592
|
+
key: "day",
|
|
1593
|
+
pattern: "(\\d{1,2})",
|
|
1594
|
+
formatter: (date) => padNumber(date.getDate())
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
token: "HH",
|
|
1598
|
+
key: "hour",
|
|
1599
|
+
pattern: "(\\d{1,2})",
|
|
1600
|
+
formatter: (date) => padNumber(date.getHours())
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
token: "mm",
|
|
1604
|
+
key: "minute",
|
|
1605
|
+
pattern: "(\\d{1,2})",
|
|
1606
|
+
formatter: (date) => padNumber(date.getMinutes())
|
|
1607
|
+
}
|
|
1608
|
+
];
|
|
1609
|
+
var ACCESSORY_METRICS_BY_SIZE = {
|
|
1610
|
+
sm: {
|
|
1611
|
+
buttonSize: 18,
|
|
1612
|
+
iconSize: 14,
|
|
1613
|
+
rightOffset: 8,
|
|
1614
|
+
clusterGap: 6,
|
|
1615
|
+
contentGap: 8
|
|
1616
|
+
},
|
|
1617
|
+
md: {
|
|
1618
|
+
buttonSize: 20,
|
|
1619
|
+
iconSize: 16,
|
|
1620
|
+
rightOffset: 10,
|
|
1621
|
+
clusterGap: 8,
|
|
1622
|
+
contentGap: 10
|
|
1623
|
+
},
|
|
1624
|
+
lg: {
|
|
1625
|
+
buttonSize: 22,
|
|
1626
|
+
iconSize: 18,
|
|
1627
|
+
rightOffset: 12,
|
|
1628
|
+
clusterGap: 8,
|
|
1629
|
+
contentGap: 12
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
function padNumber(value, length = 2) {
|
|
1633
|
+
return String(value).padStart(length, "0");
|
|
1634
|
+
}
|
|
1635
|
+
function escapeRegExp(value) {
|
|
1636
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1637
|
+
}
|
|
1638
|
+
function isValidDateInstance(value) {
|
|
1639
|
+
return !Number.isNaN(value.getTime());
|
|
1640
|
+
}
|
|
1641
|
+
function createValidatedDate(year, month, day, hour = 0, minute = 0) {
|
|
1642
|
+
const nextDate = new Date(year, month - 1, day, hour, minute, 0, 0);
|
|
1643
|
+
if (!isValidDateInstance(nextDate)) {
|
|
1644
|
+
return null;
|
|
1645
|
+
}
|
|
1646
|
+
if (nextDate.getFullYear() !== year || nextDate.getMonth() !== month - 1 || nextDate.getDate() !== day || nextDate.getHours() !== hour || nextDate.getMinutes() !== minute) {
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
return nextDate;
|
|
1650
|
+
}
|
|
1651
|
+
function normalizeDatePrecision(date, mode) {
|
|
1652
|
+
if (mode === "date") {
|
|
1653
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
|
|
1654
|
+
}
|
|
1655
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), 0, 0);
|
|
1656
|
+
}
|
|
1657
|
+
function toLocalInputValue(date, mode) {
|
|
1658
|
+
const normalizedDate = normalizeDatePrecision(date, mode);
|
|
1659
|
+
const datePart = `${normalizedDate.getFullYear()}-${padNumber(normalizedDate.getMonth() + 1)}-${padNumber(normalizedDate.getDate())}`;
|
|
1660
|
+
if (mode === "date") {
|
|
1661
|
+
return datePart;
|
|
1662
|
+
}
|
|
1663
|
+
return `${datePart}T${padNumber(normalizedDate.getHours())}:${padNumber(normalizedDate.getMinutes())}`;
|
|
1664
|
+
}
|
|
1665
|
+
function parseHtmlDateLikeValue(value) {
|
|
1666
|
+
const trimmedValue = value.trim();
|
|
1667
|
+
const dateMatch = HTML_DATE_PATTERN.exec(trimmedValue);
|
|
1668
|
+
if (dateMatch) {
|
|
1669
|
+
return createValidatedDate(
|
|
1670
|
+
Number(dateMatch[1]),
|
|
1671
|
+
Number(dateMatch[2]),
|
|
1672
|
+
Number(dateMatch[3])
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
1675
|
+
const datetimeMatch = HTML_DATETIME_PATTERN.exec(trimmedValue);
|
|
1676
|
+
if (datetimeMatch) {
|
|
1677
|
+
return createValidatedDate(
|
|
1678
|
+
Number(datetimeMatch[1]),
|
|
1679
|
+
Number(datetimeMatch[2]),
|
|
1680
|
+
Number(datetimeMatch[3]),
|
|
1681
|
+
Number(datetimeMatch[4]),
|
|
1682
|
+
Number(datetimeMatch[5])
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1687
|
+
function parseFormattedDateValue(value, format, mode) {
|
|
1688
|
+
const orderedParts = [];
|
|
1689
|
+
let expression = "^";
|
|
1690
|
+
for (let index = 0; index < format.length; ) {
|
|
1691
|
+
const token = FORMAT_TOKENS.find(({ token: currentToken }) => format.startsWith(currentToken, index));
|
|
1692
|
+
if (token) {
|
|
1693
|
+
expression += token.pattern;
|
|
1694
|
+
orderedParts.push(token.key);
|
|
1695
|
+
index += token.token.length;
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
expression += escapeRegExp(format[index]);
|
|
1699
|
+
index += 1;
|
|
1700
|
+
}
|
|
1701
|
+
expression += "$";
|
|
1702
|
+
const match = new RegExp(expression).exec(value.trim());
|
|
1703
|
+
if (!match) {
|
|
1704
|
+
return null;
|
|
1705
|
+
}
|
|
1706
|
+
const resolvedParts = {
|
|
1707
|
+
year: 0,
|
|
1708
|
+
month: 1,
|
|
1709
|
+
day: 1,
|
|
1710
|
+
hour: 0,
|
|
1711
|
+
minute: 0
|
|
1712
|
+
};
|
|
1713
|
+
orderedParts.forEach((key, index) => {
|
|
1714
|
+
resolvedParts[key] = Number(match[index + 1]);
|
|
1715
|
+
});
|
|
1716
|
+
if (!resolvedParts.year || !resolvedParts.month || !resolvedParts.day) {
|
|
1717
|
+
return null;
|
|
1718
|
+
}
|
|
1719
|
+
return createValidatedDate(
|
|
1720
|
+
resolvedParts.year,
|
|
1721
|
+
resolvedParts.month,
|
|
1722
|
+
resolvedParts.day,
|
|
1723
|
+
mode === "datetime" ? resolvedParts.hour : 0,
|
|
1724
|
+
mode === "datetime" ? resolvedParts.minute : 0
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
function parseDateValue(value, mode, format) {
|
|
1728
|
+
if (value == null || value === "") {
|
|
1729
|
+
return null;
|
|
1730
|
+
}
|
|
1731
|
+
if (value instanceof Date) {
|
|
1732
|
+
return isValidDateInstance(value) ? normalizeDatePrecision(value, mode) : null;
|
|
1733
|
+
}
|
|
1734
|
+
if (typeof value !== "string") {
|
|
1735
|
+
return null;
|
|
1736
|
+
}
|
|
1737
|
+
const parsedFormattedDate = parseFormattedDateValue(value, format, mode);
|
|
1738
|
+
if (parsedFormattedDate) {
|
|
1739
|
+
return normalizeDatePrecision(parsedFormattedDate, mode);
|
|
1740
|
+
}
|
|
1741
|
+
const parsedHtmlDate = parseHtmlDateLikeValue(value);
|
|
1742
|
+
if (parsedHtmlDate) {
|
|
1743
|
+
return normalizeDatePrecision(parsedHtmlDate, mode);
|
|
1744
|
+
}
|
|
1745
|
+
const parsedNativeDate = new Date(value);
|
|
1746
|
+
return isValidDateInstance(parsedNativeDate) ? normalizeDatePrecision(parsedNativeDate, mode) : null;
|
|
1747
|
+
}
|
|
1748
|
+
function formatDateValue(date, format) {
|
|
1749
|
+
return FORMAT_TOKENS.reduce((currentFormat, token) => {
|
|
1750
|
+
return currentFormat.split(token.token).join(token.formatter(date));
|
|
1751
|
+
}, format);
|
|
1752
|
+
}
|
|
1753
|
+
function getLaterDate(leftDate, rightDate) {
|
|
1754
|
+
if (!leftDate) return rightDate;
|
|
1755
|
+
if (!rightDate) return leftDate;
|
|
1756
|
+
return leftDate.getTime() >= rightDate.getTime() ? leftDate : rightDate;
|
|
1757
|
+
}
|
|
1758
|
+
function getEarlierDate(leftDate, rightDate) {
|
|
1759
|
+
if (!leftDate) return rightDate;
|
|
1760
|
+
if (!rightDate) return leftDate;
|
|
1761
|
+
return leftDate.getTime() <= rightDate.getTime() ? leftDate : rightDate;
|
|
1762
|
+
}
|
|
1763
|
+
function CalendarIcon({ size }) {
|
|
1764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
1765
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", { x: "3", y: "4.5", width: "14", height: "12.5", rx: "3", stroke: "currentColor", strokeWidth: "1.6" }),
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M6.25 2.75V6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }),
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M13.75 2.75V6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }),
|
|
1768
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M3 7.5H17", stroke: "currentColor", strokeWidth: "1.6" }),
|
|
1769
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "10", cy: "11.5", r: "1.2", fill: "currentColor" })
|
|
1770
|
+
] });
|
|
1771
|
+
}
|
|
1772
|
+
function ClearIcon({ size }) {
|
|
1773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M5 5L15 15", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" }),
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M15 5L5 15", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
|
|
1776
|
+
] });
|
|
1777
|
+
}
|
|
1778
|
+
function DatePicker({
|
|
1779
|
+
label,
|
|
1780
|
+
hint,
|
|
1781
|
+
error,
|
|
1782
|
+
controlSize = "md",
|
|
1783
|
+
value,
|
|
1784
|
+
defaultValue,
|
|
1785
|
+
onChange,
|
|
1786
|
+
mode = "date",
|
|
1787
|
+
format,
|
|
1788
|
+
allowPastDates = true,
|
|
1789
|
+
allowFutureDates = true,
|
|
1790
|
+
minDate,
|
|
1791
|
+
maxDate,
|
|
1792
|
+
minuteStep = 5,
|
|
1793
|
+
clearable = true,
|
|
1794
|
+
showPickerButton = true,
|
|
1795
|
+
isDateUnavailable,
|
|
1796
|
+
invalidDateMessage,
|
|
1797
|
+
unavailableDateMessage,
|
|
1798
|
+
pickerButtonLabel,
|
|
1799
|
+
clearButtonLabel,
|
|
1800
|
+
id,
|
|
1801
|
+
name,
|
|
1802
|
+
disabled,
|
|
1803
|
+
readOnly,
|
|
1804
|
+
required,
|
|
1805
|
+
style,
|
|
1806
|
+
className,
|
|
1807
|
+
placeholder,
|
|
1808
|
+
onBlur,
|
|
1809
|
+
onFocus,
|
|
1810
|
+
onKeyDown,
|
|
1811
|
+
...rest
|
|
1812
|
+
}) {
|
|
1813
|
+
var _a;
|
|
1814
|
+
const { theme, focusRing } = useUiKitTheme();
|
|
1815
|
+
const controlMetrics = getControlMetrics(controlSize);
|
|
1816
|
+
const accessoryMetrics = ACCESSORY_METRICS_BY_SIZE[controlSize];
|
|
1817
|
+
const generatedIdRef = (0, import_react7.useRef)();
|
|
1818
|
+
const visibleInputRef = (0, import_react7.useRef)(null);
|
|
1819
|
+
const nativeInputRef = (0, import_react7.useRef)(null);
|
|
1820
|
+
const [internalError, setInternalError] = (0, import_react7.useState)();
|
|
1821
|
+
const resolvedFormat = (format == null ? void 0 : format.trim()) ? format : DEFAULT_FORMAT_BY_MODE[mode];
|
|
1822
|
+
const isControlled = value !== void 0;
|
|
1823
|
+
const nativePickerType = mode === "datetime" ? "datetime-local" : "date";
|
|
1824
|
+
if (!generatedIdRef.current) {
|
|
1825
|
+
generatedIdRef.current = `ss-date-picker-${Math.random().toString(36).slice(2, 10)}`;
|
|
1826
|
+
}
|
|
1827
|
+
const resolvedId = id != null ? id : generatedIdRef.current;
|
|
1828
|
+
const normalizedDefaultValue = (0, import_react7.useMemo)(() => {
|
|
1829
|
+
const parsedDefaultValue = parseDateValue(defaultValue, mode, resolvedFormat);
|
|
1830
|
+
return parsedDefaultValue ? toLocalInputValue(parsedDefaultValue, mode) : null;
|
|
1831
|
+
}, [defaultValue, mode, resolvedFormat]);
|
|
1832
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react7.useState)(normalizedDefaultValue);
|
|
1833
|
+
const committedDate = (0, import_react7.useMemo)(() => {
|
|
1834
|
+
const sourceValue = isControlled ? value : uncontrolledValue;
|
|
1835
|
+
return parseDateValue(sourceValue, mode, resolvedFormat);
|
|
1836
|
+
}, [isControlled, mode, resolvedFormat, uncontrolledValue, value]);
|
|
1837
|
+
const committedValue = committedDate ? toLocalInputValue(committedDate, mode) : null;
|
|
1838
|
+
const committedDisplayValue = committedDate ? formatDateValue(committedDate, resolvedFormat) : "";
|
|
1839
|
+
const [draftValue, setDraftValue] = (0, import_react7.useState)(committedDisplayValue);
|
|
1840
|
+
(0, import_react7.useEffect)(() => {
|
|
1841
|
+
setDraftValue(committedDisplayValue);
|
|
1842
|
+
setInternalError(void 0);
|
|
1843
|
+
}, [committedDisplayValue]);
|
|
1844
|
+
(0, import_react7.useEffect)(() => {
|
|
1845
|
+
if (!isControlled) {
|
|
1846
|
+
setUncontrolledValue((currentValue) => {
|
|
1847
|
+
if (currentValue == null) {
|
|
1848
|
+
return currentValue;
|
|
1849
|
+
}
|
|
1850
|
+
const parsedCurrentValue = parseDateValue(currentValue, mode, resolvedFormat);
|
|
1851
|
+
return parsedCurrentValue ? toLocalInputValue(parsedCurrentValue, mode) : null;
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
}, [isControlled, mode, resolvedFormat]);
|
|
1855
|
+
const parsedMinDate = (0, import_react7.useMemo)(() => {
|
|
1856
|
+
const explicitMinDate = parseDateValue(minDate, mode, resolvedFormat);
|
|
1857
|
+
const guardedMinDate = allowPastDates ? null : normalizeDatePrecision(/* @__PURE__ */ new Date(), mode);
|
|
1858
|
+
return getLaterDate(explicitMinDate, guardedMinDate);
|
|
1859
|
+
}, [allowPastDates, minDate, mode, resolvedFormat]);
|
|
1860
|
+
const parsedMaxDate = (0, import_react7.useMemo)(() => {
|
|
1861
|
+
const explicitMaxDate = parseDateValue(maxDate, mode, resolvedFormat);
|
|
1862
|
+
const guardedMaxDate = allowFutureDates ? null : normalizeDatePrecision(/* @__PURE__ */ new Date(), mode);
|
|
1863
|
+
return getEarlierDate(explicitMaxDate, guardedMaxDate);
|
|
1864
|
+
}, [allowFutureDates, maxDate, mode, resolvedFormat]);
|
|
1865
|
+
const hasExternalError = error !== void 0 && error !== null && error !== "";
|
|
1866
|
+
const hasConfigurationConflict = Boolean(parsedMinDate && parsedMaxDate && parsedMinDate.getTime() > parsedMaxDate.getTime());
|
|
1867
|
+
const derivedError = hasConfigurationConflict ? "Current date rules do not allow any selection." : internalError;
|
|
1868
|
+
const resolvedError = hasExternalError ? error : derivedError;
|
|
1869
|
+
const hasAnyValue = draftValue.trim().length > 0 || Boolean(committedValue);
|
|
1870
|
+
const canOpenPicker = showPickerButton && !disabled && !readOnly && !hasConfigurationConflict;
|
|
1871
|
+
const canClear = clearable && !disabled && !readOnly && !required && hasAnyValue;
|
|
1872
|
+
const visibleButtonCount = Number(canOpenPicker) + Number(canClear);
|
|
1873
|
+
const trailingInset = visibleButtonCount > 0 ? Math.max(
|
|
1874
|
+
0,
|
|
1875
|
+
accessoryMetrics.rightOffset + visibleButtonCount * accessoryMetrics.buttonSize + (visibleButtonCount - 1) * accessoryMetrics.clusterGap + accessoryMetrics.contentGap - controlMetrics.paddingX
|
|
1876
|
+
) : 0;
|
|
1877
|
+
const getValidationMessage = (parsedDate) => {
|
|
1878
|
+
if (parsedMinDate && parsedDate.getTime() < parsedMinDate.getTime()) {
|
|
1879
|
+
return `Choose a value on or after ${formatDateValue(parsedMinDate, resolvedFormat)}.`;
|
|
1880
|
+
}
|
|
1881
|
+
if (parsedMaxDate && parsedDate.getTime() > parsedMaxDate.getTime()) {
|
|
1882
|
+
return `Choose a value on or before ${formatDateValue(parsedMaxDate, resolvedFormat)}.`;
|
|
1883
|
+
}
|
|
1884
|
+
if (mode === "datetime" && minuteStep > 1 && parsedDate.getMinutes() % minuteStep !== 0) {
|
|
1885
|
+
return `Minutes must use ${minuteStep}-minute intervals.`;
|
|
1886
|
+
}
|
|
1887
|
+
if (isDateUnavailable == null ? void 0 : isDateUnavailable(parsedDate)) {
|
|
1888
|
+
return unavailableDateMessage != null ? unavailableDateMessage : "This date is not available.";
|
|
1889
|
+
}
|
|
1890
|
+
return void 0;
|
|
1891
|
+
};
|
|
1892
|
+
const emitChange = (nextValue, context) => {
|
|
1893
|
+
onChange == null ? void 0 : onChange(nextValue, context);
|
|
1894
|
+
};
|
|
1895
|
+
const commitValue = (nextValue, reason) => {
|
|
1896
|
+
if (hasConfigurationConflict) {
|
|
1897
|
+
setInternalError("Current date rules do not allow any selection.");
|
|
1898
|
+
return false;
|
|
1899
|
+
}
|
|
1900
|
+
if (!nextValue) {
|
|
1901
|
+
if (!isControlled) {
|
|
1902
|
+
setUncontrolledValue(null);
|
|
1903
|
+
}
|
|
1904
|
+
setDraftValue("");
|
|
1905
|
+
setInternalError(void 0);
|
|
1906
|
+
emitChange(null, {
|
|
1907
|
+
reason,
|
|
1908
|
+
date: null,
|
|
1909
|
+
nativeValue: "",
|
|
1910
|
+
displayValue: ""
|
|
1911
|
+
});
|
|
1912
|
+
return true;
|
|
1913
|
+
}
|
|
1914
|
+
const parsedDate = parseHtmlDateLikeValue(nextValue);
|
|
1915
|
+
if (!parsedDate) {
|
|
1916
|
+
setInternalError(invalidDateMessage != null ? invalidDateMessage : `Enter a valid value using ${resolvedFormat}.`);
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
const normalizedDate = normalizeDatePrecision(parsedDate, mode);
|
|
1920
|
+
const validationMessage = getValidationMessage(normalizedDate);
|
|
1921
|
+
if (validationMessage) {
|
|
1922
|
+
setInternalError(validationMessage);
|
|
1923
|
+
return false;
|
|
1924
|
+
}
|
|
1925
|
+
const normalizedValue = toLocalInputValue(normalizedDate, mode);
|
|
1926
|
+
const displayValue = formatDateValue(normalizedDate, resolvedFormat);
|
|
1927
|
+
if (!isControlled) {
|
|
1928
|
+
setUncontrolledValue(normalizedValue);
|
|
1929
|
+
}
|
|
1930
|
+
setDraftValue(displayValue);
|
|
1931
|
+
setInternalError(void 0);
|
|
1932
|
+
emitChange(normalizedValue, {
|
|
1933
|
+
reason,
|
|
1934
|
+
date: normalizedDate,
|
|
1935
|
+
nativeValue: normalizedValue,
|
|
1936
|
+
displayValue
|
|
1937
|
+
});
|
|
1938
|
+
return true;
|
|
1939
|
+
};
|
|
1940
|
+
const commitDraftValue = () => {
|
|
1941
|
+
var _a2, _b;
|
|
1942
|
+
const trimmedDraftValue = draftValue.trim();
|
|
1943
|
+
if (!trimmedDraftValue) {
|
|
1944
|
+
return commitValue(null, "clear");
|
|
1945
|
+
}
|
|
1946
|
+
const parsedDraftDate = (_b = (_a2 = parseFormattedDateValue(trimmedDraftValue, resolvedFormat, mode)) != null ? _a2 : parseHtmlDateLikeValue(trimmedDraftValue)) != null ? _b : parseDateValue(trimmedDraftValue, mode, resolvedFormat);
|
|
1947
|
+
if (!parsedDraftDate) {
|
|
1948
|
+
setInternalError(invalidDateMessage != null ? invalidDateMessage : `Enter a valid value using ${resolvedFormat}.`);
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
return commitValue(toLocalInputValue(parsedDraftDate, mode), "input");
|
|
1952
|
+
};
|
|
1953
|
+
const openNativePicker = () => {
|
|
1954
|
+
var _a2, _b;
|
|
1955
|
+
if (!canOpenPicker || !nativeInputRef.current) {
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
const parsedDraftDate = draftValue.trim() ? (_a2 = parseFormattedDateValue(draftValue, resolvedFormat, mode)) != null ? _a2 : parseHtmlDateLikeValue(draftValue) : null;
|
|
1959
|
+
if (parsedDraftDate) {
|
|
1960
|
+
nativeInputRef.current.value = toLocalInputValue(parsedDraftDate, mode);
|
|
1961
|
+
}
|
|
1962
|
+
const pickerInput = nativeInputRef.current;
|
|
1963
|
+
try {
|
|
1964
|
+
if (pickerInput.showPicker) {
|
|
1965
|
+
pickerInput.showPicker();
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1968
|
+
pickerInput.focus();
|
|
1969
|
+
} catch {
|
|
1970
|
+
(_b = visibleInputRef.current) == null ? void 0 : _b.focus();
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
const inputStyle = {
|
|
1974
|
+
width: "100%",
|
|
1975
|
+
boxSizing: "border-box",
|
|
1976
|
+
height: controlMetrics.height,
|
|
1977
|
+
borderRadius: 16,
|
|
1978
|
+
border: `1px solid ${resolvedError ? theme.colors.negative : withAlpha(theme.colors.textLight, 0.5)}`,
|
|
1979
|
+
backgroundColor: theme.colors.surface,
|
|
1980
|
+
color: theme.colors.text,
|
|
1981
|
+
cursor: disabled ? "not-allowed" : readOnly ? "default" : "text",
|
|
1982
|
+
opacity: disabled ? 0.7 : 1,
|
|
1983
|
+
padding: getTextInputPadding(controlSize, { trailingInset }),
|
|
1984
|
+
outline: "none",
|
|
1985
|
+
fontSize: controlMetrics.fontSize,
|
|
1986
|
+
lineHeight: controlMetrics.lineHeight,
|
|
1987
|
+
boxShadow: resolvedError ? `0 0 0 3px ${withAlpha(theme.colors.negative, 0.12)}` : `0 0 0 0 ${focusRing}`,
|
|
1988
|
+
transition: "border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease",
|
|
1989
|
+
...style
|
|
1990
|
+
};
|
|
1991
|
+
const accessoryButtonStyle = {
|
|
1992
|
+
width: accessoryMetrics.buttonSize,
|
|
1993
|
+
height: accessoryMetrics.buttonSize,
|
|
1994
|
+
border: "none",
|
|
1995
|
+
padding: 0,
|
|
1996
|
+
margin: 0,
|
|
1997
|
+
display: "inline-flex",
|
|
1998
|
+
alignItems: "center",
|
|
1999
|
+
justifyContent: "center",
|
|
2000
|
+
borderRadius: 999,
|
|
2001
|
+
backgroundColor: "transparent",
|
|
2002
|
+
color: theme.colors.textLight,
|
|
2003
|
+
cursor: disabled || readOnly ? "not-allowed" : "pointer",
|
|
2004
|
+
opacity: disabled ? 0.5 : 1
|
|
2005
|
+
};
|
|
2006
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2008
|
+
"input",
|
|
2009
|
+
{
|
|
2010
|
+
...rest,
|
|
2011
|
+
ref: visibleInputRef,
|
|
2012
|
+
id: resolvedId,
|
|
2013
|
+
className,
|
|
2014
|
+
type: "text",
|
|
2015
|
+
value: draftValue,
|
|
2016
|
+
disabled,
|
|
2017
|
+
readOnly,
|
|
2018
|
+
required,
|
|
2019
|
+
placeholder: placeholder != null ? placeholder : resolvedFormat,
|
|
2020
|
+
autoComplete: (_a = rest.autoComplete) != null ? _a : "off",
|
|
2021
|
+
spellCheck: false,
|
|
2022
|
+
"aria-invalid": Boolean(resolvedError),
|
|
2023
|
+
onChange: (event) => {
|
|
2024
|
+
setDraftValue(event.target.value);
|
|
2025
|
+
setInternalError(void 0);
|
|
2026
|
+
},
|
|
2027
|
+
onFocus: (event) => {
|
|
2028
|
+
setInternalError(void 0);
|
|
2029
|
+
onFocus == null ? void 0 : onFocus(event);
|
|
2030
|
+
},
|
|
2031
|
+
onBlur: (event) => {
|
|
2032
|
+
commitDraftValue();
|
|
2033
|
+
onBlur == null ? void 0 : onBlur(event);
|
|
2034
|
+
},
|
|
2035
|
+
onKeyDown: (event) => {
|
|
2036
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
2037
|
+
if (event.defaultPrevented) {
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
if (event.key === "Enter") {
|
|
2041
|
+
event.preventDefault();
|
|
2042
|
+
commitDraftValue();
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
if (event.key === "Escape") {
|
|
2046
|
+
event.preventDefault();
|
|
2047
|
+
setDraftValue(committedDisplayValue);
|
|
2048
|
+
setInternalError(void 0);
|
|
2049
|
+
}
|
|
2050
|
+
},
|
|
2051
|
+
style: inputStyle
|
|
2052
|
+
}
|
|
2053
|
+
),
|
|
2054
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2055
|
+
"input",
|
|
2056
|
+
{
|
|
2057
|
+
ref: nativeInputRef,
|
|
2058
|
+
tabIndex: -1,
|
|
2059
|
+
"aria-hidden": "true",
|
|
2060
|
+
name,
|
|
2061
|
+
type: nativePickerType,
|
|
2062
|
+
value: committedValue != null ? committedValue : "",
|
|
2063
|
+
min: parsedMinDate ? toLocalInputValue(parsedMinDate, mode) : void 0,
|
|
2064
|
+
max: parsedMaxDate ? toLocalInputValue(parsedMaxDate, mode) : void 0,
|
|
2065
|
+
step: mode === "datetime" ? Math.max(1, minuteStep) * 60 : void 0,
|
|
2066
|
+
disabled: disabled || readOnly || hasConfigurationConflict,
|
|
2067
|
+
onChange: (event) => {
|
|
2068
|
+
commitValue(event.target.value || null, "picker");
|
|
2069
|
+
},
|
|
2070
|
+
style: {
|
|
2071
|
+
position: "absolute",
|
|
2072
|
+
width: 1,
|
|
2073
|
+
height: 1,
|
|
2074
|
+
padding: 0,
|
|
2075
|
+
margin: -1,
|
|
2076
|
+
overflow: "hidden",
|
|
2077
|
+
clip: "rect(0, 0, 0, 0)",
|
|
2078
|
+
whiteSpace: "nowrap",
|
|
2079
|
+
border: 0,
|
|
2080
|
+
opacity: 0,
|
|
2081
|
+
pointerEvents: "none"
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
),
|
|
2085
|
+
visibleButtonCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2086
|
+
"div",
|
|
2087
|
+
{
|
|
2088
|
+
style: {
|
|
2089
|
+
position: "absolute",
|
|
2090
|
+
top: "50%",
|
|
2091
|
+
right: accessoryMetrics.rightOffset,
|
|
2092
|
+
transform: "translateY(-50%)",
|
|
2093
|
+
display: "inline-flex",
|
|
2094
|
+
alignItems: "center",
|
|
2095
|
+
gap: accessoryMetrics.clusterGap
|
|
2096
|
+
},
|
|
2097
|
+
children: [
|
|
2098
|
+
canClear ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2099
|
+
"button",
|
|
2100
|
+
{
|
|
2101
|
+
type: "button",
|
|
2102
|
+
"aria-label": clearButtonLabel != null ? clearButtonLabel : "Clear date",
|
|
2103
|
+
disabled: disabled || readOnly,
|
|
2104
|
+
onMouseDown: (event) => {
|
|
2105
|
+
event.preventDefault();
|
|
2106
|
+
},
|
|
2107
|
+
onClick: () => {
|
|
2108
|
+
var _a2;
|
|
2109
|
+
commitValue(null, "clear");
|
|
2110
|
+
(_a2 = visibleInputRef.current) == null ? void 0 : _a2.focus();
|
|
2111
|
+
},
|
|
2112
|
+
style: accessoryButtonStyle,
|
|
2113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ClearIcon, { size: accessoryMetrics.iconSize })
|
|
2114
|
+
}
|
|
2115
|
+
) : null,
|
|
2116
|
+
canOpenPicker ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2117
|
+
"button",
|
|
2118
|
+
{
|
|
2119
|
+
type: "button",
|
|
2120
|
+
"aria-label": pickerButtonLabel != null ? pickerButtonLabel : mode === "datetime" ? "Open date and time picker" : "Open date picker",
|
|
2121
|
+
disabled: disabled || readOnly || hasConfigurationConflict,
|
|
2122
|
+
onMouseDown: (event) => {
|
|
2123
|
+
event.preventDefault();
|
|
2124
|
+
},
|
|
2125
|
+
onClick: openNativePicker,
|
|
2126
|
+
style: accessoryButtonStyle,
|
|
2127
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CalendarIcon, { size: accessoryMetrics.iconSize })
|
|
2128
|
+
}
|
|
2129
|
+
) : null
|
|
2130
|
+
]
|
|
2131
|
+
}
|
|
2132
|
+
) : null
|
|
2133
|
+
] });
|
|
2134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2135
|
+
ControlFrame,
|
|
2136
|
+
{
|
|
2137
|
+
label,
|
|
2138
|
+
hint,
|
|
2139
|
+
error: resolvedError,
|
|
2140
|
+
htmlFor: resolvedId,
|
|
2141
|
+
required,
|
|
2142
|
+
children: input
|
|
2143
|
+
}
|
|
2144
|
+
);
|
|
1171
2145
|
}
|
|
1172
2146
|
|
|
1173
2147
|
// src/components/Select.tsx
|
|
1174
|
-
var
|
|
1175
|
-
var
|
|
1176
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2148
|
+
var import_react8 = require("react");
|
|
2149
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1177
2150
|
var MENU_OFFSET = 8;
|
|
1178
2151
|
var MENU_MAX_HEIGHT = 280;
|
|
1179
2152
|
var getOptionPadding = (size) => {
|
|
@@ -1191,7 +2164,7 @@ function getTextContent(node) {
|
|
|
1191
2164
|
if (Array.isArray(node)) {
|
|
1192
2165
|
return node.map(getTextContent).join("");
|
|
1193
2166
|
}
|
|
1194
|
-
if ((0,
|
|
2167
|
+
if ((0, import_react8.isValidElement)(node)) {
|
|
1195
2168
|
return getTextContent(node.props.children);
|
|
1196
2169
|
}
|
|
1197
2170
|
return "";
|
|
@@ -1237,8 +2210,8 @@ function parseSelectChildren(children) {
|
|
|
1237
2210
|
});
|
|
1238
2211
|
standaloneOptions.length = 0;
|
|
1239
2212
|
};
|
|
1240
|
-
|
|
1241
|
-
if (!(0,
|
|
2213
|
+
import_react8.Children.forEach(children, (child) => {
|
|
2214
|
+
if (!(0, import_react8.isValidElement)(child)) {
|
|
1242
2215
|
return;
|
|
1243
2216
|
}
|
|
1244
2217
|
if (child.type === "option") {
|
|
@@ -1252,8 +2225,8 @@ function parseSelectChildren(children) {
|
|
|
1252
2225
|
flushStandaloneOptions();
|
|
1253
2226
|
const groupOptions = [];
|
|
1254
2227
|
let groupOptionIndex = 0;
|
|
1255
|
-
|
|
1256
|
-
if (!(0,
|
|
2228
|
+
import_react8.Children.forEach(child.props.children, (optionChild) => {
|
|
2229
|
+
if (!(0, import_react8.isValidElement)(optionChild) || optionChild.type !== "option") {
|
|
1257
2230
|
return;
|
|
1258
2231
|
}
|
|
1259
2232
|
groupOptions.push(
|
|
@@ -1293,7 +2266,6 @@ function filterSelectGroups(groups, query) {
|
|
|
1293
2266
|
})).filter((group) => group.options.length > 0);
|
|
1294
2267
|
}
|
|
1295
2268
|
function Select({
|
|
1296
|
-
sdk,
|
|
1297
2269
|
label,
|
|
1298
2270
|
hint,
|
|
1299
2271
|
error,
|
|
@@ -1317,8 +2289,8 @@ function Select({
|
|
|
1317
2289
|
...rest
|
|
1318
2290
|
}) {
|
|
1319
2291
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1320
|
-
const { theme,
|
|
1321
|
-
const generatedId = (0,
|
|
2292
|
+
const { theme, mutedText, surfaceRaised } = useUiKitTheme();
|
|
2293
|
+
const generatedId = (0, import_react8.useId)().replace(/:/g, "");
|
|
1322
2294
|
const resolvedId = id != null ? id : `ss-select-${generatedId}`;
|
|
1323
2295
|
const isMultiSelect = Boolean(isMulti || multiple);
|
|
1324
2296
|
const hasFilter = Boolean(isFilterable);
|
|
@@ -1327,17 +2299,17 @@ function Select({
|
|
|
1327
2299
|
const enabledOptions = flatOptions.filter((option) => !option.disabled);
|
|
1328
2300
|
const isControlled = value !== void 0;
|
|
1329
2301
|
const fallbackValues = defaultValue !== void 0 ? normalizeSelectValues(defaultValue) : isMultiSelect ? [] : ((_a = enabledOptions[0]) == null ? void 0 : _a.value) ? [enabledOptions[0].value] : [];
|
|
1330
|
-
const [uncontrolledValues, setUncontrolledValues] = (0,
|
|
1331
|
-
const [isOpen, setIsOpen] = (0,
|
|
1332
|
-
const [filterQuery, setFilterQuery] = (0,
|
|
1333
|
-
const [menuPlacement, setMenuPlacement] = (0,
|
|
1334
|
-
const [isPlacementResolved, setIsPlacementResolved] = (0,
|
|
1335
|
-
const [highlightedValue, setHighlightedValue] = (0,
|
|
1336
|
-
const shellRef = (0,
|
|
1337
|
-
const buttonRef = (0,
|
|
1338
|
-
const menuRef = (0,
|
|
1339
|
-
const searchInputRef = (0,
|
|
1340
|
-
const hiddenSelectRef = (0,
|
|
2302
|
+
const [uncontrolledValues, setUncontrolledValues] = (0, import_react8.useState)(fallbackValues);
|
|
2303
|
+
const [isOpen, setIsOpen] = (0, import_react8.useState)(false);
|
|
2304
|
+
const [filterQuery, setFilterQuery] = (0, import_react8.useState)("");
|
|
2305
|
+
const [menuPlacement, setMenuPlacement] = (0, import_react8.useState)("bottom");
|
|
2306
|
+
const [isPlacementResolved, setIsPlacementResolved] = (0, import_react8.useState)(false);
|
|
2307
|
+
const [highlightedValue, setHighlightedValue] = (0, import_react8.useState)((_d = (_c = fallbackValues[0]) != null ? _c : (_b = enabledOptions[0]) == null ? void 0 : _b.value) != null ? _d : "");
|
|
2308
|
+
const shellRef = (0, import_react8.useRef)(null);
|
|
2309
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
2310
|
+
const menuRef = (0, import_react8.useRef)(null);
|
|
2311
|
+
const searchInputRef = (0, import_react8.useRef)(null);
|
|
2312
|
+
const hiddenSelectRef = (0, import_react8.useRef)(null);
|
|
1341
2313
|
const selectedValues = isControlled ? normalizeSelectValues(value) : uncontrolledValues;
|
|
1342
2314
|
const selectedValue = (_e = selectedValues[0]) != null ? _e : "";
|
|
1343
2315
|
const selectedOptions = flatOptions.filter((option) => selectedValues.includes(option.value));
|
|
@@ -1353,16 +2325,16 @@ function Select({
|
|
|
1353
2325
|
const indicatorOffset = getSelectIndicatorOffset(controlSize);
|
|
1354
2326
|
const controlMetrics = getControlMetrics(controlSize);
|
|
1355
2327
|
const listboxId = `${resolvedId}-listbox`;
|
|
1356
|
-
const scrollbarThumbColor =
|
|
1357
|
-
const scrollbarThumbHoverColor =
|
|
2328
|
+
const scrollbarThumbColor = withAlpha(theme.colors.onSurface, 0.22);
|
|
2329
|
+
const scrollbarThumbHoverColor = withAlpha(theme.colors.onSurface, 0.32);
|
|
1358
2330
|
const highlightedOption = (_h = visibleOptions.find((option) => option.value === highlightedValue)) != null ? _h : null;
|
|
1359
|
-
const optionHoverBackground =
|
|
1360
|
-
const optionSelectedBackground =
|
|
1361
|
-
const triggerShadow = error ? `0 0 0 3px ${
|
|
2331
|
+
const optionHoverBackground = withAlpha(theme.colors.primary, 1);
|
|
2332
|
+
const optionSelectedBackground = withAlpha(theme.colors.primary, 1);
|
|
2333
|
+
const triggerShadow = error ? `0 0 0 3px ${withAlpha(theme.colors.negative, 0.12)}` : "none";
|
|
1362
2334
|
const buttonPassthroughProps = Object.fromEntries(
|
|
1363
2335
|
Object.entries(rest).filter(([key]) => key.startsWith("aria-") || key.startsWith("data-"))
|
|
1364
2336
|
);
|
|
1365
|
-
(0,
|
|
2337
|
+
(0, import_react8.useEffect)(() => {
|
|
1366
2338
|
var _a2, _b2, _c2, _d2;
|
|
1367
2339
|
if (isControlled) {
|
|
1368
2340
|
return;
|
|
@@ -1379,7 +2351,7 @@ function Select({
|
|
|
1379
2351
|
setUncontrolledValues(nextValues);
|
|
1380
2352
|
setHighlightedValue((_d2 = (_c2 = nextValues[0]) != null ? _c2 : (_b2 = enabledOptions[0]) == null ? void 0 : _b2.value) != null ? _d2 : "");
|
|
1381
2353
|
}, [children, defaultValue, enabledOptions, flatOptions, isControlled, isMultiSelect, uncontrolledValues]);
|
|
1382
|
-
(0,
|
|
2354
|
+
(0, import_react8.useEffect)(() => {
|
|
1383
2355
|
var _a2, _b2, _c2;
|
|
1384
2356
|
if (!isOpen) {
|
|
1385
2357
|
setMenuPlacement("bottom");
|
|
@@ -1389,14 +2361,14 @@ function Select({
|
|
|
1389
2361
|
const nextHighlightedValue = (_c2 = (_b2 = [...selectedValues].reverse().find((currentValue) => visibleEnabledValues.includes(currentValue))) != null ? _b2 : (_a2 = visibleEnabledOptions[0]) == null ? void 0 : _a2.value) != null ? _c2 : "";
|
|
1390
2362
|
setHighlightedValue(nextHighlightedValue);
|
|
1391
2363
|
}, [isOpen, selectedValuesKey, visibleEnabledValuesKey]);
|
|
1392
|
-
(0,
|
|
2364
|
+
(0, import_react8.useEffect)(() => {
|
|
1393
2365
|
var _a2;
|
|
1394
2366
|
if (!isOpen || !hasFilter) {
|
|
1395
2367
|
return;
|
|
1396
2368
|
}
|
|
1397
2369
|
(_a2 = searchInputRef.current) == null ? void 0 : _a2.focus();
|
|
1398
2370
|
}, [hasFilter, isOpen]);
|
|
1399
|
-
(0,
|
|
2371
|
+
(0, import_react8.useEffect)(() => {
|
|
1400
2372
|
if (!isOpen) {
|
|
1401
2373
|
return;
|
|
1402
2374
|
}
|
|
@@ -1421,13 +2393,13 @@ function Select({
|
|
|
1421
2393
|
window.cancelAnimationFrame(frameId);
|
|
1422
2394
|
};
|
|
1423
2395
|
}, [isOpen, visibleOptions.length]);
|
|
1424
|
-
(0,
|
|
2396
|
+
(0, import_react8.useEffect)(() => {
|
|
1425
2397
|
if (isOpen) {
|
|
1426
2398
|
return;
|
|
1427
2399
|
}
|
|
1428
2400
|
setFilterQuery("");
|
|
1429
2401
|
}, [isOpen]);
|
|
1430
|
-
(0,
|
|
2402
|
+
(0, import_react8.useEffect)(() => {
|
|
1431
2403
|
if (!isOpen) {
|
|
1432
2404
|
return;
|
|
1433
2405
|
}
|
|
@@ -1443,7 +2415,7 @@ function Select({
|
|
|
1443
2415
|
document.removeEventListener("pointerdown", handlePointerDown);
|
|
1444
2416
|
};
|
|
1445
2417
|
}, [isOpen]);
|
|
1446
|
-
(0,
|
|
2418
|
+
(0, import_react8.useEffect)(() => {
|
|
1447
2419
|
var _a2;
|
|
1448
2420
|
if (isControlled) {
|
|
1449
2421
|
return;
|
|
@@ -1542,7 +2514,7 @@ function Select({
|
|
|
1542
2514
|
const hasSomeVisibleSelected = visibleSelectedCount > 0 && visibleSelectedCount < visibleEnabledValues.length;
|
|
1543
2515
|
const hasAllVisibleSelected = visibleEnabledValues.length > 0 && visibleSelectedCount === visibleEnabledValues.length;
|
|
1544
2516
|
const canToggleVisibleSelection = !disabled && visibleEnabledValues.length > 0;
|
|
1545
|
-
const bulkToggleControl = isMultiSelect ? /* @__PURE__ */ (0,
|
|
2517
|
+
const bulkToggleControl = isMultiSelect ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1546
2518
|
"button",
|
|
1547
2519
|
{
|
|
1548
2520
|
type: "button",
|
|
@@ -1563,39 +2535,27 @@ function Select({
|
|
|
1563
2535
|
height: 20,
|
|
1564
2536
|
padding: 0,
|
|
1565
2537
|
margin: 0,
|
|
1566
|
-
borderRadius: 999,
|
|
1567
|
-
border: `1.5px solid ${hasAllVisibleSelected || hasSomeVisibleSelected ? theme.colors.secondary : (0, import_smartsell_sales_sdk6.withAlpha)(theme.colors.onSurface, 0.22)}`,
|
|
1568
|
-
backgroundColor: hasAllVisibleSelected || hasSomeVisibleSelected ? theme.colors.secondary : theme.colors.surface,
|
|
1569
2538
|
display: "inline-flex",
|
|
1570
2539
|
alignItems: "center",
|
|
1571
2540
|
justifyContent: "center",
|
|
1572
2541
|
flexShrink: 0,
|
|
2542
|
+
border: "none",
|
|
2543
|
+
background: "transparent",
|
|
1573
2544
|
cursor: canToggleVisibleSelection ? "pointer" : "not-allowed",
|
|
1574
2545
|
opacity: canToggleVisibleSelection ? 1 : 0.45
|
|
1575
2546
|
},
|
|
1576
|
-
children:
|
|
1577
|
-
|
|
2547
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2548
|
+
CheckboxIndicator,
|
|
1578
2549
|
{
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
) : hasSomeVisibleSelected ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1588
|
-
"span",
|
|
1589
|
-
{
|
|
1590
|
-
"aria-hidden": "true",
|
|
1591
|
-
style: {
|
|
1592
|
-
width: 8,
|
|
1593
|
-
height: 2,
|
|
1594
|
-
borderRadius: 999,
|
|
1595
|
-
backgroundColor: theme.colors.surface
|
|
1596
|
-
}
|
|
2550
|
+
checked: hasAllVisibleSelected,
|
|
2551
|
+
indeterminate: hasSomeVisibleSelected,
|
|
2552
|
+
disabled: !canToggleVisibleSelection,
|
|
2553
|
+
checkedColor: theme.colors.secondary,
|
|
2554
|
+
iconColor: theme.colors.surface,
|
|
2555
|
+
uncheckedBorderColor: withAlpha(theme.colors.onSurface, 0.22),
|
|
2556
|
+
uncheckedBackgroundColor: theme.colors.surface
|
|
1597
2557
|
}
|
|
1598
|
-
)
|
|
2558
|
+
)
|
|
1599
2559
|
}
|
|
1600
2560
|
) : null;
|
|
1601
2561
|
const moveHighlight = (direction) => {
|
|
@@ -1716,8 +2676,8 @@ function Select({
|
|
|
1716
2676
|
setIsOpen(false);
|
|
1717
2677
|
}
|
|
1718
2678
|
};
|
|
1719
|
-
const select = /* @__PURE__ */ (0,
|
|
1720
|
-
/* @__PURE__ */ (0,
|
|
2679
|
+
const select = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: shellRef, style: { position: "relative", width: "100%" }, children: [
|
|
2680
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1721
2681
|
"button",
|
|
1722
2682
|
{
|
|
1723
2683
|
...buttonPassthroughProps,
|
|
@@ -1744,7 +2704,7 @@ function Select({
|
|
|
1744
2704
|
boxSizing: "border-box",
|
|
1745
2705
|
height: controlMetrics.height,
|
|
1746
2706
|
borderRadius: 16,
|
|
1747
|
-
border: `1px solid ${error ? theme.colors.negative :
|
|
2707
|
+
border: `1px solid ${error ? theme.colors.negative : withAlpha(theme.colors.textLight, 0.5)}`,
|
|
1748
2708
|
backgroundColor: theme.colors.surface,
|
|
1749
2709
|
color: displayLabel ? theme.colors.onSurface : mutedText,
|
|
1750
2710
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
@@ -1764,7 +2724,7 @@ function Select({
|
|
|
1764
2724
|
...style
|
|
1765
2725
|
},
|
|
1766
2726
|
children: [
|
|
1767
|
-
/* @__PURE__ */ (0,
|
|
2727
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1768
2728
|
"span",
|
|
1769
2729
|
{
|
|
1770
2730
|
style: {
|
|
@@ -1778,7 +2738,7 @@ function Select({
|
|
|
1778
2738
|
children: displayContent
|
|
1779
2739
|
}
|
|
1780
2740
|
),
|
|
1781
|
-
/* @__PURE__ */ (0,
|
|
2741
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1782
2742
|
"span",
|
|
1783
2743
|
{
|
|
1784
2744
|
"aria-hidden": "true",
|
|
@@ -1788,14 +2748,14 @@ function Select({
|
|
|
1788
2748
|
top: "50%",
|
|
1789
2749
|
transform: `translateY(-50%) rotate(${isOpen ? 180 : 0}deg)`,
|
|
1790
2750
|
transformOrigin: "center",
|
|
1791
|
-
color: disabled ?
|
|
2751
|
+
color: disabled ? withAlpha(theme.colors.onSurface, 0.42) : mutedText,
|
|
1792
2752
|
display: "flex",
|
|
1793
2753
|
alignItems: "center",
|
|
1794
2754
|
justifyContent: "center",
|
|
1795
2755
|
pointerEvents: "none",
|
|
1796
2756
|
transition: "transform 160ms ease, color 160ms ease"
|
|
1797
2757
|
},
|
|
1798
|
-
children: /* @__PURE__ */ (0,
|
|
2758
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1799
2759
|
"path",
|
|
1800
2760
|
{
|
|
1801
2761
|
d: "M5.75 7.75L10 12l4.25-4.25",
|
|
@@ -1810,7 +2770,7 @@ function Select({
|
|
|
1810
2770
|
]
|
|
1811
2771
|
}
|
|
1812
2772
|
),
|
|
1813
|
-
/* @__PURE__ */ (0,
|
|
2773
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1814
2774
|
"select",
|
|
1815
2775
|
{
|
|
1816
2776
|
...rest,
|
|
@@ -1837,8 +2797,8 @@ function Select({
|
|
|
1837
2797
|
children
|
|
1838
2798
|
}
|
|
1839
2799
|
),
|
|
1840
|
-
isOpen ? /* @__PURE__ */ (0,
|
|
1841
|
-
/* @__PURE__ */ (0,
|
|
2800
|
+
isOpen ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2801
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: `
|
|
1842
2802
|
#${listboxId} {
|
|
1843
2803
|
scrollbar-width: thin;
|
|
1844
2804
|
scrollbar-color: ${scrollbarThumbColor} transparent;
|
|
@@ -1864,7 +2824,7 @@ function Select({
|
|
|
1864
2824
|
background-clip: padding-box;
|
|
1865
2825
|
}
|
|
1866
2826
|
` }),
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
2827
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1868
2828
|
"div",
|
|
1869
2829
|
{
|
|
1870
2830
|
ref: menuRef,
|
|
@@ -1879,7 +2839,7 @@ function Select({
|
|
|
1879
2839
|
overflow: "hidden",
|
|
1880
2840
|
boxSizing: "border-box",
|
|
1881
2841
|
borderRadius: 20,
|
|
1882
|
-
border: `1px solid ${
|
|
2842
|
+
border: `1px solid ${withAlpha(theme.colors.textLight, 0.5)}`,
|
|
1883
2843
|
backgroundColor: surfaceRaised,
|
|
1884
2844
|
// boxShadow: `0 10px 24px ${withAlpha(theme.colors.onSurface, 0.08)}`,
|
|
1885
2845
|
padding: 8,
|
|
@@ -1890,7 +2850,7 @@ function Select({
|
|
|
1890
2850
|
gap: 4
|
|
1891
2851
|
},
|
|
1892
2852
|
children: [
|
|
1893
|
-
hasFilter ? /* @__PURE__ */ (0,
|
|
2853
|
+
hasFilter ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1894
2854
|
"div",
|
|
1895
2855
|
{
|
|
1896
2856
|
style: {
|
|
@@ -1899,12 +2859,12 @@ function Select({
|
|
|
1899
2859
|
justifyContent: "flex-start",
|
|
1900
2860
|
gap: 8,
|
|
1901
2861
|
padding: "4px 4px 10px",
|
|
1902
|
-
borderBottom: `1px solid ${
|
|
2862
|
+
borderBottom: `1px solid ${withAlpha(theme.colors.onSurface, 0.08)}`,
|
|
1903
2863
|
flexShrink: 0
|
|
1904
2864
|
},
|
|
1905
2865
|
children: [
|
|
1906
2866
|
bulkToggleControl,
|
|
1907
|
-
/* @__PURE__ */ (0,
|
|
2867
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1908
2868
|
"input",
|
|
1909
2869
|
{
|
|
1910
2870
|
ref: searchInputRef,
|
|
@@ -1922,7 +2882,7 @@ function Select({
|
|
|
1922
2882
|
style: {
|
|
1923
2883
|
flex: "1 1 auto",
|
|
1924
2884
|
width: "100%",
|
|
1925
|
-
border: `1px solid ${
|
|
2885
|
+
border: `1px solid ${withAlpha(theme.colors.textLight, 0.5)}`,
|
|
1926
2886
|
backgroundColor: theme.colors.surface,
|
|
1927
2887
|
padding: "8px 12px",
|
|
1928
2888
|
borderRadius: 12,
|
|
@@ -1937,7 +2897,7 @@ function Select({
|
|
|
1937
2897
|
)
|
|
1938
2898
|
]
|
|
1939
2899
|
}
|
|
1940
|
-
) : isMultiSelect ? /* @__PURE__ */ (0,
|
|
2900
|
+
) : isMultiSelect ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1941
2901
|
"div",
|
|
1942
2902
|
{
|
|
1943
2903
|
style: {
|
|
@@ -1945,13 +2905,13 @@ function Select({
|
|
|
1945
2905
|
alignItems: "center",
|
|
1946
2906
|
justifyContent: "flex-start",
|
|
1947
2907
|
padding: "4px 4px 10px",
|
|
1948
|
-
borderBottom: `1px solid ${
|
|
2908
|
+
borderBottom: `1px solid ${withAlpha(theme.colors.onSurface, 0.08)}`,
|
|
1949
2909
|
flexShrink: 0
|
|
1950
2910
|
},
|
|
1951
2911
|
children: bulkToggleControl
|
|
1952
2912
|
}
|
|
1953
2913
|
) : null,
|
|
1954
|
-
/* @__PURE__ */ (0,
|
|
2914
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1955
2915
|
"div",
|
|
1956
2916
|
{
|
|
1957
2917
|
id: listboxId,
|
|
@@ -1964,7 +2924,7 @@ function Select({
|
|
|
1964
2924
|
minHeight: 0,
|
|
1965
2925
|
flex: "1 1 auto"
|
|
1966
2926
|
},
|
|
1967
|
-
children: visibleGroups.length === 0 ? /* @__PURE__ */ (0,
|
|
2927
|
+
children: visibleGroups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1968
2928
|
"div",
|
|
1969
2929
|
{
|
|
1970
2930
|
style: {
|
|
@@ -1975,7 +2935,7 @@ function Select({
|
|
|
1975
2935
|
},
|
|
1976
2936
|
children: "No options found."
|
|
1977
2937
|
}
|
|
1978
|
-
) : visibleGroups.map((group) => /* @__PURE__ */ (0,
|
|
2938
|
+
) : visibleGroups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1979
2939
|
"div",
|
|
1980
2940
|
{
|
|
1981
2941
|
style: {
|
|
@@ -1985,7 +2945,7 @@ function Select({
|
|
|
1985
2945
|
marginTop: group.label ? 4 : 0
|
|
1986
2946
|
},
|
|
1987
2947
|
children: [
|
|
1988
|
-
group.label ? /* @__PURE__ */ (0,
|
|
2948
|
+
group.label ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1989
2949
|
"span",
|
|
1990
2950
|
{
|
|
1991
2951
|
style: {
|
|
@@ -2003,7 +2963,7 @@ function Select({
|
|
|
2003
2963
|
const isSelected = selectedValues.includes(option.value);
|
|
2004
2964
|
const isHighlighted = option.value === highlightedValue;
|
|
2005
2965
|
const isActive = isSelected || isHighlighted;
|
|
2006
|
-
return /* @__PURE__ */ (0,
|
|
2966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2007
2967
|
"div",
|
|
2008
2968
|
{
|
|
2009
2969
|
role: "option",
|
|
@@ -2033,13 +2993,13 @@ function Select({
|
|
|
2033
2993
|
borderRadius: 14,
|
|
2034
2994
|
padding: getOptionPadding(controlSize),
|
|
2035
2995
|
cursor: option.disabled ? "not-allowed" : "pointer",
|
|
2036
|
-
color: option.disabled ?
|
|
2996
|
+
color: option.disabled ? withAlpha(theme.colors.onSurface, 0.38) : isActive ? theme.colors.onPrimary : theme.colors.onSurface,
|
|
2037
2997
|
backgroundColor: isSelected ? optionSelectedBackground : isHighlighted ? optionHoverBackground : "transparent",
|
|
2038
2998
|
fontWeight: isSelected ? 700 : 500,
|
|
2039
2999
|
transition: "background-color 140ms ease, color 140ms ease"
|
|
2040
3000
|
},
|
|
2041
3001
|
children: [
|
|
2042
|
-
/* @__PURE__ */ (0,
|
|
3002
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2043
3003
|
"span",
|
|
2044
3004
|
{
|
|
2045
3005
|
style: {
|
|
@@ -2050,23 +3010,19 @@ function Select({
|
|
|
2050
3010
|
minWidth: 0
|
|
2051
3011
|
},
|
|
2052
3012
|
children: [
|
|
2053
|
-
isMultiSelect ? /* @__PURE__ */ (0,
|
|
2054
|
-
|
|
3013
|
+
isMultiSelect ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3014
|
+
CheckboxIndicator,
|
|
2055
3015
|
{
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
backgroundColor: isSelected ? theme.colors.secondary : "transparent",
|
|
2064
|
-
opacity: option.disabled ? 0.45 : 1,
|
|
2065
|
-
transition: "background-color 140ms ease, border-color 140ms ease, opacity 140ms ease"
|
|
2066
|
-
}
|
|
3016
|
+
checked: isSelected,
|
|
3017
|
+
disabled: option.disabled,
|
|
3018
|
+
size: 16,
|
|
3019
|
+
checkedColor: isActive ? theme.colors.onPrimary : theme.colors.primary,
|
|
3020
|
+
iconColor: isActive ? theme.colors.primary : theme.colors.onPrimary,
|
|
3021
|
+
uncheckedBorderColor: isActive ? theme.colors.onPrimary : withAlpha(theme.colors.onSurface, 0.26),
|
|
3022
|
+
uncheckedBackgroundColor: "transparent"
|
|
2067
3023
|
}
|
|
2068
3024
|
) : null,
|
|
2069
|
-
/* @__PURE__ */ (0,
|
|
3025
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2070
3026
|
"span",
|
|
2071
3027
|
{
|
|
2072
3028
|
style: {
|
|
@@ -2083,7 +3039,7 @@ function Select({
|
|
|
2083
3039
|
]
|
|
2084
3040
|
}
|
|
2085
3041
|
),
|
|
2086
|
-
isSelected ? /* @__PURE__ */ (0,
|
|
3042
|
+
!isMultiSelect && isSelected ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2087
3043
|
"span",
|
|
2088
3044
|
{
|
|
2089
3045
|
"aria-hidden": "true",
|
|
@@ -2094,7 +3050,7 @@ function Select({
|
|
|
2094
3050
|
color: theme.colors.primary,
|
|
2095
3051
|
flexShrink: 0
|
|
2096
3052
|
},
|
|
2097
|
-
children: /* @__PURE__ */ (0,
|
|
3053
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2098
3054
|
"path",
|
|
2099
3055
|
{
|
|
2100
3056
|
d: "M5.75 10.25L8.5 13l5.75-6",
|
|
@@ -2122,10 +3078,9 @@ function Select({
|
|
|
2122
3078
|
)
|
|
2123
3079
|
] }) : null
|
|
2124
3080
|
] });
|
|
2125
|
-
return /* @__PURE__ */ (0,
|
|
3081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2126
3082
|
ControlFrame,
|
|
2127
3083
|
{
|
|
2128
|
-
sdk,
|
|
2129
3084
|
label,
|
|
2130
3085
|
hint,
|
|
2131
3086
|
error,
|
|
@@ -2138,15 +3093,13 @@ function Select({
|
|
|
2138
3093
|
}
|
|
2139
3094
|
|
|
2140
3095
|
// src/components/Textarea.tsx
|
|
2141
|
-
var
|
|
2142
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3096
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2143
3097
|
var getPadding = (size) => {
|
|
2144
3098
|
if (size === "sm") return "10px 12px";
|
|
2145
3099
|
if (size === "lg") return "16px 18px";
|
|
2146
3100
|
return "13px 16px";
|
|
2147
3101
|
};
|
|
2148
3102
|
function Textarea({
|
|
2149
|
-
sdk,
|
|
2150
3103
|
label,
|
|
2151
3104
|
hint,
|
|
2152
3105
|
error,
|
|
@@ -2157,9 +3110,9 @@ function Textarea({
|
|
|
2157
3110
|
rows = 5,
|
|
2158
3111
|
...rest
|
|
2159
3112
|
}) {
|
|
2160
|
-
const { theme,
|
|
3113
|
+
const { theme, focusRing } = useUiKitTheme();
|
|
2161
3114
|
const textareaStyle = {
|
|
2162
|
-
border: `1px solid ${error ? theme.colors.negative :
|
|
3115
|
+
border: `1px solid ${error ? theme.colors.negative : withAlpha(theme.colors.textLight, 0.5)}`,
|
|
2163
3116
|
backgroundColor: theme.colors.surface,
|
|
2164
3117
|
color: theme.colors.text,
|
|
2165
3118
|
cursor: disabled ? "not-allowed" : "text",
|
|
@@ -2169,19 +3122,21 @@ function Textarea({
|
|
|
2169
3122
|
borderRadius: 16,
|
|
2170
3123
|
padding: getPadding(controlSize),
|
|
2171
3124
|
outline: "none",
|
|
2172
|
-
boxShadow: error ? `0 0 0 3px ${
|
|
3125
|
+
boxShadow: error ? `0 0 0 3px ${withAlpha(theme.colors.negative, 0.12)}` : `0 0 0 0 ${focusRing}`,
|
|
2173
3126
|
transition: "border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease",
|
|
2174
3127
|
resize: "vertical",
|
|
2175
3128
|
...style
|
|
2176
3129
|
};
|
|
2177
|
-
const textarea = /* @__PURE__ */ (0,
|
|
2178
|
-
return /* @__PURE__ */ (0,
|
|
3130
|
+
const textarea = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("textarea", { ...rest, id, disabled, rows, style: textareaStyle });
|
|
3131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ControlFrame, { label, hint, error, htmlFor: id, required: rest.required, children: textarea });
|
|
2179
3132
|
}
|
|
2180
3133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2181
3134
|
0 && (module.exports = {
|
|
2182
3135
|
Button,
|
|
2183
3136
|
Card,
|
|
3137
|
+
Checkbox,
|
|
2184
3138
|
ComposableModal,
|
|
3139
|
+
DatePicker,
|
|
2185
3140
|
Input,
|
|
2186
3141
|
Modal,
|
|
2187
3142
|
Select,
|