@cwellt_software/cwellt-reactjs-lib 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content/icons/IconLibrary.stories.tsx +18 -18
- package/dist/index.cjs.js +301 -196
- package/dist/index.css +2 -2
- package/dist/index.d.ts +78 -35
- package/dist/index.es.js +301 -196
- package/dist/src/common/functions/colorManipulation.d.ts.map +1 -1
- package/dist/src/common/interfaces/CwDataAttributes.d.ts +5 -0
- package/dist/src/common/interfaces/CwDataAttributes.d.ts.map +1 -0
- package/dist/src/components/control/action/button/CwButtonSwitch.d.ts +3 -3
- package/dist/src/components/control/action/button/CwButtonSwitch.d.ts.map +1 -1
- package/dist/src/components/control/action/search/CwSearchAsync.d.ts +7 -1
- package/dist/src/components/control/action/search/CwSearchAsync.d.ts.map +1 -1
- package/dist/src/components/control/action/search/CwSearchAsync.stories.d.ts +28 -0
- package/dist/src/components/control/action/search/CwSearchAsync.stories.d.ts.map +1 -1
- package/dist/src/components/control/choice/tree-view/CwTreeView.d.ts +4 -4
- package/dist/src/components/control/choice/tree-view/CwTreeView.d.ts.map +1 -1
- package/dist/src/components/control/choice/tree-view/CwTreeView.stories.d.ts +5 -7
- package/dist/src/components/control/choice/tree-view/CwTreeView.stories.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDatePicker.d.ts +3 -2
- package/dist/src/components/control/input/new-dates/CwDatePicker.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDatePicker.stories.d.ts +5 -1
- package/dist/src/components/control/input/new-dates/CwDatePicker.stories.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDatePickerTemporal.d.ts +3 -2
- package/dist/src/components/control/input/new-dates/CwDatePickerTemporal.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateRangePicker.d.ts +8 -2
- package/dist/src/components/control/input/new-dates/CwDateRangePicker.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateRangePicker.stories.d.ts +10 -12
- package/dist/src/components/control/input/new-dates/CwDateRangePicker.stories.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateRangePickerTemporal.d.ts +8 -2
- package/dist/src/components/control/input/new-dates/CwDateRangePickerTemporal.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateTimePicker.d.ts +8 -2
- package/dist/src/components/control/input/new-dates/CwDateTimePicker.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateTimePicker.stories.d.ts +12 -12
- package/dist/src/components/control/input/new-dates/CwDateTimePicker.stories.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateTimePickerCompact.d.ts +8 -2
- package/dist/src/components/control/input/new-dates/CwDateTimePickerCompact.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwDateTimePickerTemporal.d.ts +8 -2
- package/dist/src/components/control/input/new-dates/CwDateTimePickerTemporal.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwTimePicker.d.ts +8 -2
- package/dist/src/components/control/input/new-dates/CwTimePicker.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/CwTimePicker.stories.d.ts +15 -13
- package/dist/src/components/control/input/new-dates/CwTimePicker.stories.d.ts.map +1 -1
- package/dist/src/components/control/input/new-dates/datePickerHelpers.d.ts +10 -0
- package/dist/src/components/control/input/new-dates/datePickerHelpers.d.ts.map +1 -1
- package/dist/src/components/control/input/weekday/CwWeekdaySelector.d.ts +2 -1
- package/dist/src/components/control/input/weekday/CwWeekdaySelector.d.ts.map +1 -1
- package/dist/src/components/control/input/weekday/CwWeekdaySelector.stories.d.ts +3 -0
- package/dist/src/components/control/input/weekday/CwWeekdaySelector.stories.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/NewScheduler.d.ts +2 -1
- package/dist/src/components/custom/scheduler-new/presentation/NewScheduler.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/Scheduler.stories.d.ts +5 -1
- package/dist/src/components/custom/scheduler-new/presentation/Scheduler.stories.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/Event.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/timeline/DivisionLine.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/timeline/TimeLine.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/timeline/WeekEndLine.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/logic/separateEventsToInnerRows.d.ts +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/logic/separateEventsToInnerRows.d.ts.map +1 -1
- package/dist/src/components/display/data/table/CwTable.stories.d.ts +2 -0
- package/dist/src/components/display/data/table/CwTable.stories.d.ts.map +1 -1
- package/dist/src/components/display/graphics/progress/CwProgress.d.ts +13 -8
- package/dist/src/components/display/graphics/progress/CwProgress.d.ts.map +1 -1
- package/dist/src/components/display/graphics/progress/CwProgress.stories.d.ts +21 -5
- package/dist/src/components/display/graphics/progress/CwProgress.stories.d.ts.map +1 -1
- package/dist/src/components/display/text/badge/CwBadge.d.ts +9 -1
- package/dist/src/components/display/text/badge/CwBadge.d.ts.map +1 -1
- package/dist/src/components/display/text/badge/CwBadge.stories.d.ts +5 -0
- package/dist/src/components/display/text/badge/CwBadge.stories.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/storybook/pickerStoryArgs.d.ts +2 -18
- package/dist/src/storybook/pickerStoryArgs.d.ts.map +1 -1
- package/dist/test/common/functions/colorManipulation.test.d.ts +2 -0
- package/dist/test/common/functions/colorManipulation.test.d.ts.map +1 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/separateEventsToInnerRows.test.d.ts +2 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/separateEventsToInnerRows.test.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -92,13 +92,27 @@ function colorToHSL(color) {
|
|
|
92
92
|
l: Math.round(l * 100)
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
+
const HEX_CACHE_LIMIT = 500;
|
|
96
|
+
const hexCache = new Map();
|
|
97
|
+
let canvasContext = null;
|
|
95
98
|
function colorToHEX(color) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const cached = hexCache.get(color);
|
|
100
|
+
if (cached !== undefined)
|
|
101
|
+
return cached;
|
|
102
|
+
if (!canvasContext) {
|
|
103
|
+
canvasContext = document.createElement('canvas').getContext('2d');
|
|
104
|
+
if (!canvasContext)
|
|
105
|
+
throw new Error('Could not create canvas context');
|
|
106
|
+
}
|
|
107
|
+
// A reused context keeps its previous fillStyle when the new color is invalid; reset it to the
|
|
108
|
+
// fresh-canvas default so an invalid color still gives black instead of the last valid color.
|
|
109
|
+
canvasContext.fillStyle = '#000000';
|
|
110
|
+
canvasContext.fillStyle = color;
|
|
111
|
+
const hex = canvasContext.fillStyle;
|
|
112
|
+
if (hexCache.size >= HEX_CACHE_LIMIT)
|
|
113
|
+
hexCache.clear();
|
|
114
|
+
hexCache.set(color, hex);
|
|
115
|
+
return hex;
|
|
102
116
|
}
|
|
103
117
|
function getHSLColor(color, alpha = 1) {
|
|
104
118
|
const hsl = colorToHSL(color);
|
|
@@ -160,7 +174,7 @@ function getContrastColor(color) {
|
|
|
160
174
|
return `hsl(${hsl.h}, ${contrastS}%, ${targetL}%)`;
|
|
161
175
|
}
|
|
162
176
|
|
|
163
|
-
var styles$
|
|
177
|
+
var styles$A = {"cw-tooltip-content":"cw-tooltip-module__cw-tooltip-content__RZczd","cw-tooltip":"cw-tooltip-module__cw-tooltip__1KYig"};
|
|
164
178
|
|
|
165
179
|
// Constants
|
|
166
180
|
const margin$1 = 16;
|
|
@@ -450,7 +464,7 @@ const CwTooltipManager = () => {
|
|
|
450
464
|
if (!state.isVisible || !state.content) {
|
|
451
465
|
return null;
|
|
452
466
|
}
|
|
453
|
-
return createPortal(jsx("div", { ref: tooltipRef, className: styles$
|
|
467
|
+
return createPortal(jsx("div", { ref: tooltipRef, className: styles$A["cw-tooltip-content"], "data-position": actualPosition, "data-visible": state.isVisible, "data-inline": state.displayInline, style: {
|
|
454
468
|
top: `${tooltipPosition.top}px`,
|
|
455
469
|
left: `${tooltipPosition.left}px`,
|
|
456
470
|
opacity: (isPositioned && !isMeasuring) ? 1 : 0,
|
|
@@ -531,7 +545,7 @@ const CwTooltipNew = ({ children, content = null, position = "right", dissapears
|
|
|
531
545
|
useEffect(() => {
|
|
532
546
|
ensureTooltipManager();
|
|
533
547
|
}, []);
|
|
534
|
-
return (jsx("div", { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, className: styles$
|
|
548
|
+
return (jsx("div", { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, className: styles$A["cw-tooltip"], children: children }));
|
|
535
549
|
};
|
|
536
550
|
|
|
537
551
|
const SVG_ICONS = {
|
|
@@ -651,7 +665,7 @@ function resolveBadgeAria(label, loading, hasText) {
|
|
|
651
665
|
return hasText ? {} : { 'aria-hidden': 'true' };
|
|
652
666
|
}
|
|
653
667
|
|
|
654
|
-
var styles$
|
|
668
|
+
var styles$z = {"badge":"cw-badge-module__badge__PKlak"};
|
|
655
669
|
|
|
656
670
|
/**
|
|
657
671
|
* CwBadge - the small coloured circle with a number, used for alert and notification counts.
|
|
@@ -663,6 +677,13 @@ var styles$y = {"badge":"cw-badge-module__badge__PKlak"};
|
|
|
663
677
|
* Precedence: `loading` > `content` > `count` > dot. While loading the badge renders regardless
|
|
664
678
|
* of `showZero`, and the spinner replaces it - circle, background and padding come off.
|
|
665
679
|
*
|
|
680
|
+
* Overlaid on a `CwButton` (its `badge` prop), the corner offset is a public custom-property API,
|
|
681
|
+
* settable on the button, an ancestor, or the badge's own `style`:
|
|
682
|
+
* - `--badge-offset-x` - distance from the button's right edge (`right`). Default
|
|
683
|
+
* `calc(var(--cw-spacing-small) * -1)`.
|
|
684
|
+
* - `--badge-offset-y` - distance from the button's top edge (`top`). Default
|
|
685
|
+
* `calc(var(--cw-spacing-tiny) * -1)`, `-0.125rem` on a large icon button.
|
|
686
|
+
*
|
|
666
687
|
* @example
|
|
667
688
|
* <CwBadge count={3} color="danger" />
|
|
668
689
|
* <CwBadge count={0} showZero={false} />
|
|
@@ -670,7 +691,7 @@ var styles$y = {"badge":"cw-badge-module__badge__PKlak"};
|
|
|
670
691
|
* <CwBadge color="warning" label="Unresolved findings" />
|
|
671
692
|
* <CwBadge count={0} loading />
|
|
672
693
|
*/
|
|
673
|
-
const CwBadge = ({ count, content, color = 'info', variant = 'solid', size = 'small', showZero = true, loading = false, max = 99, label, className = '', style, }) => {
|
|
694
|
+
const CwBadge = ({ count, content, color = 'info', variant = 'solid', size = 'small', showZero = true, loading = false, max = 99, label, className = '', style, ...dataAttributes }) => {
|
|
674
695
|
// null counts as absent, so `content={null}` still renders a dot rather than an empty pill.
|
|
675
696
|
const hasContent = content !== undefined && content !== null;
|
|
676
697
|
if (!loading && !hasContent && count !== undefined && !showZero && normalizeBadgeCount(count) === 0) {
|
|
@@ -680,8 +701,8 @@ const CwBadge = ({ count, content, color = 'info', variant = 'solid', size = 'sm
|
|
|
680
701
|
? formatBadgeCount(count, max)
|
|
681
702
|
: undefined;
|
|
682
703
|
const isDot = !loading && !hasContent && count === undefined;
|
|
683
|
-
const badgeClassNames = ['cw-badge', styles$
|
|
684
|
-
return (jsx("span", { className: badgeClassNames, "data-color": color, "data-variant": variant, "data-size": size, "data-loading": loading ? 'true' : undefined, "data-dot": isDot ? 'true' : undefined, ...resolveBadgeAria(label, loading, !loading && (hasContent || countText !== undefined)), style: style, children: loading ? jsx(CwIcon, { iconId: "spinner", size: "small" }) : hasContent ? content : countText }));
|
|
704
|
+
const badgeClassNames = ['cw-badge', styles$z.badge, className].filter(Boolean).join(' ');
|
|
705
|
+
return (jsx("span", { ...dataAttributes, className: badgeClassNames, "data-color": color, "data-variant": variant, "data-size": size, "data-loading": loading ? 'true' : undefined, "data-dot": isDot ? 'true' : undefined, ...resolveBadgeAria(label, loading, !loading && (hasContent || countText !== undefined)), style: style, children: loading ? jsx(CwIcon, { iconId: "spinner", size: "small" }) : hasContent ? content : countText }));
|
|
685
706
|
};
|
|
686
707
|
|
|
687
708
|
const CW_DEFAULT_MESSAGE_DURATION = 2000;
|
|
@@ -1068,7 +1089,7 @@ function CwLoading({ isLoading = false, text = '', size = 'regular', iconPositio
|
|
|
1068
1089
|
return (jsxs("div", { "aria-busy": isLoading, className: "cw-loading-container", "data-children": !!children, children: [overlay, jsx("div", { className: "cw-loading-disabled-content", children: children })] }));
|
|
1069
1090
|
}
|
|
1070
1091
|
|
|
1071
|
-
var styles$
|
|
1092
|
+
var styles$y = {"skeleton":"cw-skeleton-module__skeleton__Jvx2x","group":"cw-skeleton-module__group__Cm8AU"};
|
|
1072
1093
|
|
|
1073
1094
|
/*
|
|
1074
1095
|
* Internal helper for skeleton allocations (CwSkeleton, tables, cards).
|
|
@@ -1110,8 +1131,8 @@ function CwSkeleton({ variant = 'text', width, height, count = 1, radius, gap })
|
|
|
1110
1131
|
};
|
|
1111
1132
|
// The un-hashed cw-skeleton / cw-skeleton-group classes carry no styles in the
|
|
1112
1133
|
// library - they are stable public hooks for exceptional external overrides.
|
|
1113
|
-
const skeletonClassName = ['cw-skeleton', styles$
|
|
1114
|
-
const groupClassName = ['cw-skeleton-group', styles$
|
|
1134
|
+
const skeletonClassName = ['cw-skeleton', styles$y.skeleton].filter(Boolean).join(' ');
|
|
1135
|
+
const groupClassName = ['cw-skeleton-group', styles$y.group].filter(Boolean).join(' ');
|
|
1115
1136
|
const lineCount = normalizeSkeletonCount(count, 1);
|
|
1116
1137
|
if (lineCount <= 1) {
|
|
1117
1138
|
return (jsx("span", { className: skeletonClassName, "data-variant": variant, "aria-hidden": "true", style: style }));
|
|
@@ -1123,7 +1144,7 @@ function CwSkeleton({ variant = 'text', width, height, count = 1, radius, gap })
|
|
|
1123
1144
|
return (jsx("span", { className: groupClassName, "aria-hidden": "true", style: groupStyle, children: skeletonElements }));
|
|
1124
1145
|
}
|
|
1125
1146
|
|
|
1126
|
-
var styles$
|
|
1147
|
+
var styles$x = {"progress":"cw-progress-module__progress__d-g2-","value":"cw-progress-module__value__Q-DrH","label":"cw-progress-module__label__jwOWp","track":"cw-progress-module__track__572-3","footer":"cw-progress-module__footer__0Wo4G","header":"cw-progress-module__header__mv5ct","fill":"cw-progress-module__fill__fX1UA"};
|
|
1127
1148
|
|
|
1128
1149
|
/**
|
|
1129
1150
|
* CwProgress - a determinate or indeterminate progress bar.
|
|
@@ -1135,7 +1156,7 @@ var styles$w = {"progress":"cw-progress-module__progress__d-g2-","value":"cw-pro
|
|
|
1135
1156
|
* <CwProgress value={62} label="Import" color="success" />
|
|
1136
1157
|
* <CwProgress indeterminate label="Uploading" />
|
|
1137
1158
|
*/
|
|
1138
|
-
function CwProgress({ value, indeterminate = false, label, rightLabel, size = 'regular', layout = 'row', color = 'primary', monoValue = false, prominent = false, className }) {
|
|
1159
|
+
function CwProgress({ value, indeterminate = false, label, rightLabel, footer, size = 'regular', layout = 'row', color = 'primary', monoValue = false, prominent = false, className, style, ...dataAttributes }) {
|
|
1139
1160
|
const labelId = React__default.useId();
|
|
1140
1161
|
// Determinate: a missing or non-finite value is treated as 0 (never NaN), then
|
|
1141
1162
|
// clamped to [0,100] for aria-valuenow and the fill width. Indeterminate has no value.
|
|
@@ -1143,21 +1164,21 @@ function CwProgress({ value, indeterminate = false, label, rightLabel, size = 'r
|
|
|
1143
1164
|
? undefined
|
|
1144
1165
|
: Math.min(Math.max(Number.isFinite(value) ? value : 0, 0), 100);
|
|
1145
1166
|
const percent = clamped !== undefined ? Math.round(clamped) : undefined;
|
|
1146
|
-
const showValue = rightLabel
|
|
1147
|
-
const
|
|
1167
|
+
const showValue = rightLabel != null || (!indeterminate && percent !== undefined);
|
|
1168
|
+
const valueContent = rightLabel ?? (percent !== undefined ? `${percent}%` : '');
|
|
1148
1169
|
// The un-hashed cw-progress class carries no styles in the library - a stable
|
|
1149
1170
|
// public hook for exceptional external overrides only.
|
|
1150
|
-
const rootClassName = ['cw-progress', styles$
|
|
1151
|
-
const labelSpan = label ? jsx("span", { className: styles$
|
|
1152
|
-
const valueLabel = showValue ? (jsx("span", { className: styles$
|
|
1153
|
-
return (jsxs("div", { className: rootClassName, "data-layout": layout, "data-size": size, "data-color": color, "data-prominent": prominent || undefined, "data-indeterminate": indeterminate || undefined, children: [layout === 'column' && (labelSpan || valueLabel) && (jsxs("header", { className: styles$
|
|
1171
|
+
const rootClassName = ['cw-progress', styles$x.progress, className].filter(Boolean).join(' ');
|
|
1172
|
+
const labelSpan = label ? jsx("span", { className: styles$x.label, id: labelId, children: label }) : null;
|
|
1173
|
+
const valueLabel = showValue ? (jsx("span", { className: styles$x.value, "data-mono": monoValue || undefined, children: valueContent })) : null;
|
|
1174
|
+
return (jsxs("div", { ...dataAttributes, className: rootClassName, style: style, "data-layout": layout, "data-size": size, "data-color": color, "data-prominent": prominent || undefined, "data-indeterminate": indeterminate || undefined, children: [layout === 'column' && (labelSpan || valueLabel) && (jsxs("header", { className: styles$x.header, children: [labelSpan, valueLabel] })), layout === 'row' && labelSpan, jsx("div", { className: styles$x.track, role: "progressbar", ...(label && { 'aria-labelledby': labelId }), ...(!indeterminate && percent !== undefined && {
|
|
1154
1175
|
'aria-valuenow': percent,
|
|
1155
1176
|
'aria-valuemin': 0,
|
|
1156
1177
|
'aria-valuemax': 100
|
|
1157
|
-
}), children: jsx("div", { className: styles$
|
|
1178
|
+
}), children: jsx("div", { className: styles$x.fill, style: !indeterminate && clamped !== undefined ? { width: `${clamped}%` } : undefined }) }), layout === 'row' && valueLabel, footer != null && jsx("footer", { className: styles$x.footer, children: footer })] }));
|
|
1158
1179
|
}
|
|
1159
1180
|
|
|
1160
|
-
var styles$
|
|
1181
|
+
var styles$w = {"cw-generic-tooltip-content":"cw-generic-tooltip-module__cw-generic-tooltip-content__la-Si","cw-generic-tooltip":"cw-generic-tooltip-module__cw-generic-tooltip__Ij76M"};
|
|
1161
1182
|
|
|
1162
1183
|
// Constants moved outside to prevent recreation
|
|
1163
1184
|
const margin = 16;
|
|
@@ -1284,12 +1305,12 @@ const CwGenericTooltip = ({ children, content = null, position = defaultPosition
|
|
|
1284
1305
|
const { setTooltipTimeout, clearTooltipTimeout } = useTooltipDelay(() => {
|
|
1285
1306
|
setIsVisible(true);
|
|
1286
1307
|
}, showDelay);
|
|
1287
|
-
const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$
|
|
1308
|
+
const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$w["cw-generic-tooltip-content"]);
|
|
1288
1309
|
// Memoize tooltip content creation
|
|
1289
1310
|
const tooltipContent = useMemo(() => {
|
|
1290
1311
|
if (hide || !isVisible || !content)
|
|
1291
1312
|
return null;
|
|
1292
|
-
return createPortal(jsx("div", { className: styles$
|
|
1313
|
+
return createPortal(jsx("div", { className: styles$w["cw-generic-tooltip-content"], "data-position": actualPosition, "data-visible": isVisible, "data-inline": displayInline, style: {
|
|
1293
1314
|
position: 'fixed',
|
|
1294
1315
|
top: `${tooltipPosition.top}px`,
|
|
1295
1316
|
left: `${tooltipPosition.left}px`,
|
|
@@ -1304,7 +1325,7 @@ const CwGenericTooltip = ({ children, content = null, position = defaultPosition
|
|
|
1304
1325
|
clearTooltipTimeout();
|
|
1305
1326
|
setIsVisible(false);
|
|
1306
1327
|
}, [clearTooltipTimeout]);
|
|
1307
|
-
return (jsxs("div", { ref: containerRef, className: styles$
|
|
1328
|
+
return (jsxs("div", { ref: containerRef, className: styles$w["cw-generic-tooltip"], onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, children: [tooltipContent, children] }));
|
|
1308
1329
|
};
|
|
1309
1330
|
|
|
1310
1331
|
const CwButton = React__default.forwardRef(function CwButton({ text, variant = 'solid', color = 'primary', size = 'medium', iconPosition = 'left', pressed, className = '', icon = "", title, tooltipPosition = "bottom", badge, children, ...buttonProps }, ref) {
|
|
@@ -1372,7 +1393,7 @@ function CwModal(custModalProps) {
|
|
|
1372
1393
|
return (jsx("div", { children: custModalProps.modalState && (jsxs("div", { className: custModalProps.classNameModalOverlay + " cwelltModalOverlay", children: [jsx("div", { className: "cwelltModalOverlayBg", onClick: custModalProps.onCloseModal }), jsx(Draggable, { disabled: isModalDisabled, axis: "both", nodeRef: draggableRef, children: jsxs("div", { className: custModalProps.classNameModal + " cwelltContainerModal", ref: draggableRef, style: widthModalDef !== "40em" ? modalStyle.widthCustomStyle : modalStyle.widthDefStyle, children: [jsxs("div", { className: "cwelltModalHeader", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: [jsx("div", { className: "cwelltModalTitle", children: custModalProps.titleModal }), jsx("button", { className: "cwelltBtnCloseModal", onClick: custModalProps.onCloseModal, children: jsx("span", { className: "cwelltCloseIcon" }) })] }), jsx("div", { className: "cwelltModalBody", children: jsx("div", { className: "cwelltContainerModalBody", style: { position: "relative" }, children: custModalProps.children }) }), isHide === false ? (jsx("footer", { className: "legacy-modal-footer", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: jsx(CwButton, { variant: "icon", icon: "save", title: "Save", onClick: custModalProps.onSaveModal, form: custModalProps.formSaveModal, hidden: custModalProps.HideBtnModal, type: custModalProps.HtmlSubmitModal }) })) : (jsx("div", { style: { display: "none" } }))] }) })] })) }));
|
|
1373
1394
|
}
|
|
1374
1395
|
|
|
1375
|
-
var styles$
|
|
1396
|
+
var styles$v = {"overlayPositioned":"CwConfirmationPopup-module__overlayPositioned__11qYB","popup":"CwConfirmationPopup-module__popup__ahPjM","message":"CwConfirmationPopup-module__message__MnNL4","buttons":"CwConfirmationPopup-module__buttons__fGYYE","button":"CwConfirmationPopup-module__button__ugYQE","confirmButton":"CwConfirmationPopup-module__confirmButton__rTP4S","cancelButton":"CwConfirmationPopup-module__cancelButton__Ry694"};
|
|
1376
1397
|
|
|
1377
1398
|
/**
|
|
1378
1399
|
* Small anchored confirmation for a destructive action.
|
|
@@ -1441,15 +1462,15 @@ function CwConfirmationPopup(props) {
|
|
|
1441
1462
|
onCancel();
|
|
1442
1463
|
}
|
|
1443
1464
|
};
|
|
1444
|
-
return (jsxs(Fragment, { children: [renderChildren(), isOpen && (jsx("div", { className: styles$
|
|
1465
|
+
return (jsxs(Fragment, { children: [renderChildren(), isOpen && (jsx("div", { className: styles$v.overlayPositioned, onClick: handleOverlayClick, children: jsxs("div", { ref: popupRef, className: styles$v.popup, style: {
|
|
1445
1466
|
position: 'absolute',
|
|
1446
1467
|
top: `${position.top}px`,
|
|
1447
1468
|
left: `${position.left}px`,
|
|
1448
1469
|
transform: 'none'
|
|
1449
|
-
}, children: [jsx("p", { className: styles$
|
|
1470
|
+
}, children: [jsx("p", { className: styles$v.message, children: message }), jsxs("div", { className: styles$v.buttons, children: [jsx("button", { className: `${styles$v.button} ${styles$v.confirmButton}`, onClick: onConfirm, children: confirmText }), jsx("button", { className: `${styles$v.button} ${styles$v.cancelButton}`, onClick: onCancel, children: cancelText })] })] }) }))] }));
|
|
1450
1471
|
}
|
|
1451
1472
|
|
|
1452
|
-
var styles$
|
|
1473
|
+
var styles$u = {"cw-dialog-main":"cw-dialog-module__cw-dialog-main__cHxHt","cw-dialog-button-close":"cw-dialog-module__cw-dialog-button-close__9GRd8"};
|
|
1453
1474
|
|
|
1454
1475
|
// Helper function to parse size values
|
|
1455
1476
|
const parseSize = (size) => {
|
|
@@ -1722,7 +1743,7 @@ const CwDialog = props => {
|
|
|
1722
1743
|
}
|
|
1723
1744
|
}
|
|
1724
1745
|
}, [open]);
|
|
1725
|
-
const header = useMemo(() => (jsxs("header", { onMouseDown: handleMouseDown, children: [jsx("span", { children: headline }), customHeader || (jsx("button", { className: styles$
|
|
1746
|
+
const header = useMemo(() => (jsxs("header", { onMouseDown: handleMouseDown, children: [jsx("span", { children: headline }), customHeader || (jsx("button", { className: styles$u["cw-dialog-button-close"], onClick: onClose }))] })), [handleMouseDown, headline, customHeader, onClose]);
|
|
1726
1747
|
const content = useMemo(() => (jsx("section", { children: children })), [children]);
|
|
1727
1748
|
const footer = useMemo(() => (jsx("footer", { children: customFooter || (jsx(CwButton, { variant: "icon", icon: "save", title: "Save", onClick: onSave, tooltipPosition: "top", disabled: disableSave, "data-testid": "cw-dialog-save" })) })), [customFooter, onSave, disableSave]);
|
|
1728
1749
|
const resizeHandles = useMemo(() => size.autoHeight
|
|
@@ -1749,7 +1770,7 @@ const CwDialog = props => {
|
|
|
1749
1770
|
: `${convertFromPx(size.height, size.heightUnit)}${size.heightUnit}`;
|
|
1750
1771
|
return { displayWidth, displayHeight };
|
|
1751
1772
|
}, [size.width, size.height, size.widthUnit, size.heightUnit, size.autoHeight]);
|
|
1752
|
-
const dialogContent = (jsx("div", { "data-has-scrim": hasScrim, className: styles$
|
|
1773
|
+
const dialogContent = (jsx("div", { "data-has-scrim": hasScrim, className: styles$u["cw-dialog-main"], onMouseDown: handleScrimMouseDown, onMouseUp: handleScrimMouseUpOrLeave, onMouseLeave: handleScrimMouseUpOrLeave, "data-pressing": isPressingScrim, children: jsxs("dialog", { ...domProps, ref: dialogRef, style: {
|
|
1753
1774
|
left: `${position.x}px`,
|
|
1754
1775
|
top: `${position.y}px`,
|
|
1755
1776
|
width: displayDimensions.displayWidth,
|
|
@@ -1911,7 +1932,7 @@ function CwAlign(props) {
|
|
|
1911
1932
|
}, children: props.children }));
|
|
1912
1933
|
}
|
|
1913
1934
|
|
|
1914
|
-
var styles$
|
|
1935
|
+
var styles$t = {"card":"cw-card-module__card__HJUT0","clickable":"cw-card-module__clickable__Y-V3X","disabled":"cw-card-module__disabled__0wHh1","content":"cw-card-module__content__ma9qy","headerContent":"cw-card-module__headerContent__x4Jfl","footerTags":"cw-card-module__footerTags__80sSW"};
|
|
1915
1936
|
|
|
1916
1937
|
/**
|
|
1917
1938
|
* CwCard - A simple card component for displaying content in a contained format
|
|
@@ -1937,10 +1958,10 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1937
1958
|
// Construct class names using CSS modules
|
|
1938
1959
|
const cardClassNames = [
|
|
1939
1960
|
'cw-card',
|
|
1940
|
-
styles$
|
|
1961
|
+
styles$t.card,
|
|
1941
1962
|
className,
|
|
1942
|
-
clickable ? styles$
|
|
1943
|
-
disabled ? styles$
|
|
1963
|
+
clickable ? styles$t.clickable : '',
|
|
1964
|
+
disabled ? styles$t.disabled : '',
|
|
1944
1965
|
].filter(Boolean).join(' ');
|
|
1945
1966
|
// Handle click event when card is clickable
|
|
1946
1967
|
const handleClick = () => {
|
|
@@ -1958,15 +1979,15 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1958
1979
|
const hasFooter = hasChips || footer || (hasActions && resolvedDirection === "row");
|
|
1959
1980
|
// Actions component to reuse. While loading, each provided action renders a circular
|
|
1960
1981
|
// ghost sized to the CwButton icon footprint (2rem) - no interactive buttons.
|
|
1961
|
-
const ActionsComponent = hasActions && !disabled ? (jsx("div", { className: styles$
|
|
1982
|
+
const ActionsComponent = hasActions && !disabled ? (jsx("div", { className: styles$t.actions, children: isLoading ? (jsxs(Fragment, { children: [extraActions && jsx(CwSkeleton, { variant: "circle", height: "2rem" }), onEdit && jsx(CwSkeleton, { variant: "circle", height: "2rem" }), onDelete && jsx(CwSkeleton, { variant: "circle", height: "2rem" })] })) : (jsxs(Fragment, { children: [extraActions ?? null, onEdit && jsx(CwButton, { variant: "icon", icon: "edit", onClick: onEdit }), onDelete && jsx(CwButton, { variant: "icon", icon: "delete", color: "danger", onClick: onDelete })] })) })) : null;
|
|
1962
1983
|
return (jsxs("div", { ...(id && { id }), className: cardClassNames, ...(style && { style }), ...(clickable && !isLoading && {
|
|
1963
1984
|
role: 'button',
|
|
1964
1985
|
tabIndex: 0,
|
|
1965
1986
|
onClick: handleClick,
|
|
1966
|
-
}), "data-variant": variant, "data-direction": resolvedDirection, "aria-busy": isLoading || undefined, children: [isLoading ? (jsxs("header", { children: [jsx("div", { className: styles$
|
|
1987
|
+
}), "data-variant": variant, "data-direction": resolvedDirection, "aria-busy": isLoading || undefined, children: [isLoading ? (jsxs("header", { children: [jsx("div", { className: styles$t.headerContent, "data-align": resolvedAlign, children: jsx(CwSkeleton, { width: "8rem", height: "1.5em" }) }), resolvedDirection === "column" && ActionsComponent] })) : (hasHeader && (jsxs("header", { children: [(title || subtitle) && (jsxs("div", { className: styles$t.headerContent, "data-align": resolvedAlign, children: [title && jsx("h5", { children: title }), subtitle && jsx("strong", { children: subtitle })] })), resolvedDirection === "column" && ActionsComponent] }))), jsx("div", { className: styles$t.content, children: isLoading ? jsx(CwSkeleton, { count: normalizeSkeletonCount(skeletonLines, 3) }) : children }), hasFooter && (isLoading ? (jsx("footer", { children: jsx("div", { className: styles$t.footerTags, children: jsx(CwSkeleton, { variant: "rect", width: "4rem", height: "1.5em", radius: "1rem" }) }) })) : (jsxs("footer", { children: [hasChips && (jsx("div", { className: styles$t.footerTags, children: chips.map((chip, index) => (jsx(CwChip, { label: chip.label, colorScheme: chip.colorScheme, className: styles$t.chip, ...(chip.customColor && { customColor: chip.customColor }), ...(chip.variant && { variant: chip.variant }), ...(chip.icon && { icon: chip.icon }) }, index))) })), footer && (jsx("div", { className: styles$t.footerContent, children: footer }))] }))), resolvedDirection === "row" && ActionsComponent] }));
|
|
1967
1988
|
};
|
|
1968
1989
|
|
|
1969
|
-
var styles$
|
|
1990
|
+
var styles$s = {"cardContainer":"cw-card-list-module__cardContainer__l3YEh","pagination":"cw-card-list-module__pagination__5Ay78","pageInfo":"cw-card-list-module__pageInfo__uiMel","emptyState":"cw-card-list-module__emptyState__RlqiS"};
|
|
1970
1991
|
|
|
1971
1992
|
/**
|
|
1972
1993
|
* Option to display in the CwSelect
|
|
@@ -2061,10 +2082,10 @@ function CwCardList({ items, renderCard, pageSize = 10, layout = 'grid', default
|
|
|
2061
2082
|
icon: sortDirection === 'asc' ? 'arrow-up' : 'arrow-down',
|
|
2062
2083
|
onClick: () => setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc'),
|
|
2063
2084
|
title: `Sort ${sortDirection === 'asc' ? 'descending' : 'ascending'}`,
|
|
2064
|
-
}, value: sortKey, onChange: (e) => handleSortChange(e.target.value), children: sortOptions.map(option => (jsx(CwOption, { value: option.key, children: option.label }, option.key))) }) })), isLoading ? (jsx("div", { className: `${styles$
|
|
2085
|
+
}, value: sortKey, onChange: (e) => handleSortChange(e.target.value), children: sortOptions.map(option => (jsx(CwOption, { value: option.key, children: option.label }, option.key))) }) })), isLoading ? (jsx("div", { className: `${styles$s.cardContainer}`, "data-layout": layout, style: gridStyle, "aria-busy": true, children: Array.from({ length: normalizeSkeletonCount(skeletonCards, 6) }, (_, index) => (jsx(CwCard, { isLoading: true, children: null }, `skeleton_${index}`))) })) : sortedItems.length === 0 ? (jsx("div", { className: styles$s.emptyState, children: emptyState || jsx("p", { children: "No items to display" }) })) : (jsxs(Fragment, { children: [jsx("div", { className: `${styles$s.cardContainer}`, "data-layout": layout, style: gridStyle, children: visibleItems.map((item, index) => (jsx(React__default.Fragment, { children: renderCard(item, index) }, keyExtractor ? keyExtractor(item, index) : index))) }), totalPages > 1 && (jsxs("div", { className: styles$s.pagination, children: [jsx(CwButton, { variant: "icon", icon: "chevron-left", disabled: currentPage === 1, onClick: () => setCurrentPage(p => Math.max(1, p - 1)) }), jsxs("span", { className: styles$s.pageInfo, children: [currentPage, " / ", totalPages] }), jsx(CwButton, { variant: "icon", icon: "chevron-right", disabled: currentPage === totalPages, onClick: () => setCurrentPage(p => Math.min(totalPages, p + 1)) })] }))] }))] }));
|
|
2065
2086
|
}
|
|
2066
2087
|
|
|
2067
|
-
var styles$
|
|
2088
|
+
var styles$r = {"cw-accordion":"cw-accordion-module__cw-accordion__ErvlW","cw-accordion-body":"cw-accordion-module__cw-accordion-body__xlI8b"};
|
|
2068
2089
|
|
|
2069
2090
|
/**
|
|
2070
2091
|
* Legacy collapsible section with its own header markup.
|
|
@@ -2079,7 +2100,7 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
2079
2100
|
setVisible_accordionBody(!isVisible_accordionBody);
|
|
2080
2101
|
};
|
|
2081
2102
|
// #endregion
|
|
2082
|
-
return (jsxs("div", { className: styles$
|
|
2103
|
+
return (jsxs("div", { className: styles$r["cw-accordion"], style: CwelltAccordionContainerProps.style, "data-open": isVisible_accordionBody, children: [jsxs("header", { onClick: () => showAccordionBody(), children: [jsx("div", { children: CwelltAccordionContainerProps.desc_text }), jsx("button", { className: "cw-button-icon" })] }), jsx("div", { className: styles$r["cw-accordion-body"], children: CwelltAccordionContainerProps.children })] }));
|
|
2083
2104
|
}
|
|
2084
2105
|
|
|
2085
2106
|
/*
|
|
@@ -2354,7 +2375,7 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
2354
2375
|
}, min: 1, max: totalPages }), jsx("span", { children: "/" }), jsx("span", { children: totalPages }), jsx(CwButton, { onClick: () => handlePageChange(currentPage + 1), disabled: currentPage === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right" }), jsx(CwButton, { onClick: () => handlePageChange(totalPages), disabled: currentPage === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right-double" })] })] }))] }));
|
|
2355
2376
|
}
|
|
2356
2377
|
|
|
2357
|
-
var styles$
|
|
2378
|
+
var styles$q = {"dropIndicator":"cw-sortable-table-module__dropIndicator__ov-Jz","dragging":"cw-sortable-table-module__dragging__MrLrz","saveBar":"cw-sortable-table-module__saveBar__3OdoZ cw-flex-row cw-align-center-center cw-gap-small"};
|
|
2358
2379
|
|
|
2359
2380
|
/**
|
|
2360
2381
|
* Hook that provides state management for CwSortableTable.
|
|
@@ -2417,7 +2438,7 @@ function useSortableTable(initialItems) {
|
|
|
2417
2438
|
}
|
|
2418
2439
|
|
|
2419
2440
|
// ─── Drop indicator row ───────────────────────────────────────────────────────
|
|
2420
|
-
const DropIndicatorRow = ({ colSpan }) => (jsx("tr", { className: styles$
|
|
2441
|
+
const DropIndicatorRow = ({ colSpan }) => (jsx("tr", { className: styles$q.dropIndicator, "aria-hidden": true, children: jsx("td", { colSpan: colSpan, children: jsx("div", {}) }) }));
|
|
2421
2442
|
// ─── Loading skeleton ─────────────────────────────────────────────────────────
|
|
2422
2443
|
// Plain td cells (no local class): the ghost cells get the same global cw-table
|
|
2423
2444
|
// padding as real body cells, so row heights match the loaded rows exactly.
|
|
@@ -2520,11 +2541,11 @@ function CwSortableTable({ columns, data, rowKey = "key", onReorder, loading = f
|
|
|
2520
2541
|
return items.map((item, index) => {
|
|
2521
2542
|
const key = item[rowKey];
|
|
2522
2543
|
const isDragging = draggedItem?.[rowKey] === key;
|
|
2523
|
-
return (jsxs(React__default.Fragment, { children: [dropIndicatorIndex === index && (jsx(DropIndicatorRow, { colSpan: totalCols })), jsxs("tr", { draggable: true, onDragStart: (e) => handleDragStart(e, item), onDragOver: (e) => handleDragOver(e, index), onDragEnd: handleDragEnd, className: isDragging ? styles$
|
|
2544
|
+
return (jsxs(React__default.Fragment, { children: [dropIndicatorIndex === index && (jsx(DropIndicatorRow, { colSpan: totalCols })), jsxs("tr", { draggable: true, onDragStart: (e) => handleDragStart(e, item), onDragOver: (e) => handleDragOver(e, index), onDragEnd: handleDragEnd, className: isDragging ? styles$q.dragging : "", children: [showHandle && (jsx("td", { className: "cw-table-col-action", children: jsx(CwIcon, { iconId: "grip-dots", color: "neutral", style: { opacity: 0.75 } }) })), columns.map(col => (jsx("td", { className: col.className ?? "", style: col.width ? { width: col.width } : undefined, children: renderCell(item, col) }, `${String(key)}_${col.key}`)))] }), index === items.length - 1 && dropIndicatorIndex === items.length && (jsx(DropIndicatorRow, { colSpan: totalCols }))] }, String(key)));
|
|
2524
2545
|
});
|
|
2525
2546
|
};
|
|
2526
2547
|
// ── Render ──────────────────────────────────────────────────────────────
|
|
2527
|
-
return (jsxs("div", { className: `cw-table-container ${className ?? ""}`, style: containerStyle, "aria-busy": loading || undefined, children: [jsxs("table", { className: `cw-table cw-sortable-table ${tableClassName ?? ""}`, style: { width: "100%" }, children: [jsx("thead", { children: jsxs("tr", { children: [showHandle && jsx("th", { className: "cw-table-col-action" }), columns.map(col => (jsx("th", { className: col.className ?? "", style: col.width ? { width: col.width, minWidth: 50 } : undefined, children: col.title }, col.key)))] }) }), jsx("tbody", { children: renderBody() })] }), !loading && hasChanges && (jsxs("footer", { className: styles$
|
|
2548
|
+
return (jsxs("div", { className: `cw-table-container ${className ?? ""}`, style: containerStyle, "aria-busy": loading || undefined, children: [jsxs("table", { className: `cw-table cw-sortable-table ${tableClassName ?? ""}`, style: { width: "100%" }, children: [jsx("thead", { children: jsxs("tr", { children: [showHandle && jsx("th", { className: "cw-table-col-action" }), columns.map(col => (jsx("th", { className: col.className ?? "", style: col.width ? { width: col.width, minWidth: 50 } : undefined, children: col.title }, col.key)))] }) }), jsx("tbody", { children: renderBody() })] }), !loading && hasChanges && (jsxs("footer", { className: styles$q.saveBar, children: [jsx(CwButton, { variant: "outline", color: "neutral", icon: "undo", text: discardLabel, onClick: handleDiscard }), jsx(CwButton, { variant: "solid", color: "primary", icon: "save", text: saveLabel, onClick: () => handleSave(onReorder) })] }))] }));
|
|
2528
2549
|
}
|
|
2529
2550
|
|
|
2530
2551
|
/**
|
|
@@ -2725,7 +2746,7 @@ function CwTableServerSide({ columns, data, totalItems, pagination = false, page
|
|
|
2725
2746
|
}, min: 1, max: totalPages }), jsx("span", { children: "/" }), jsx("span", { children: totalPages }), jsx(CwButton, { onClick: () => handlePageChange(state.page + 1), disabled: state.page === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right" }), jsx(CwButton, { onClick: () => handlePageChange(totalPages), disabled: state.page === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right-double" })] })] }))] }));
|
|
2726
2747
|
}
|
|
2727
2748
|
|
|
2728
|
-
var styles$
|
|
2749
|
+
var styles$p = {"cw-tabs":"cw-tabs-module__cw-tabs__1pmji","cw-tabs-content":"cw-tabs-module__cw-tabs-content__HTp8d"};
|
|
2729
2750
|
|
|
2730
2751
|
const BADGE_COLOR_SCHEMES = ['primary', 'danger', 'warning', 'success', 'info', 'neutral'];
|
|
2731
2752
|
function isBadgeColorScheme(value) {
|
|
@@ -2779,11 +2800,11 @@ function CwTabs(CwTabsProps) {
|
|
|
2779
2800
|
const tabsListStyle = position === 'left' && CwTabsProps.tabsListWidth
|
|
2780
2801
|
? { minWidth: CwTabsProps.tabsListWidth }
|
|
2781
2802
|
: undefined;
|
|
2782
|
-
return (jsxs("div", { id: CwTabsProps.id, "data-testid": CwTabsProps.testId, className: styles$
|
|
2803
|
+
return (jsxs("div", { id: CwTabsProps.id, "data-testid": CwTabsProps.testId, className: styles$p['cw-tabs'] + (CwTabsProps.className ? ` ${CwTabsProps.className}` : "") + "", style: CwTabsProps.style, "data-tabs-position": position, children: [jsx("ul", { style: tabsListStyle, children: CwTabsProps.tabs.map(tab => {
|
|
2783
2804
|
const badgeScheme = tab.badgeColor && isBadgeColorScheme(tab.badgeColor) ? tab.badgeColor : undefined;
|
|
2784
2805
|
const rawBadgeColor = tab.badgeColor && !badgeScheme ? tab.badgeColor : undefined;
|
|
2785
2806
|
return (jsxs("li", { className: `${tab.key === activeTab ? "cw-tab-active" : ""}`, onClick: () => handleTabClick(tab), "data-active": tab.key === activeTab, "data-tab-key": tab.key, "data-badge-themed": tab.badgeColor ? "true" : undefined, children: [jsx(TabIcon, { icon: tab.icon }), tab.title, (tab.badge !== undefined || tab.badgeColor) && (jsx(CwBadge, { count: typeof tab.badge === 'number' ? tab.badge : undefined, content: typeof tab.badge === 'string' ? tab.badge : undefined, size: "medium", color: badgeScheme ?? 'primary', variant: badgeScheme ? 'solid' : 'soft', style: rawBadgeColor ? { backgroundColor: rawBadgeColor, color: getContrastColor(rawBadgeColor) } : undefined }))] }, tab.key));
|
|
2786
|
-
}) }), jsx("div", { className: styles$
|
|
2807
|
+
}) }), jsx("div", { className: styles$p['cw-tabs-content'], "data-active-tab-key": activeTab ?? undefined, style: CwTabsProps.contentHeight ? { '--tabs-height': CwTabsProps.contentHeight } : undefined, children: activeTab !== null && CwTabsProps.tabs.find(tab => tab.key === activeTab)?.content })] }));
|
|
2787
2808
|
}
|
|
2788
2809
|
|
|
2789
2810
|
/**
|
|
@@ -2811,7 +2832,7 @@ const CwExpandable = ({ briefing, onToggle, onOpen, onClose, children, ...detail
|
|
|
2811
2832
|
return (jsxs("details", { ref: myRef, ...detailsProps, className: "cw-expandable", children: [jsx("summary", { children: briefing }), children && jsx("section", { children: children })] }));
|
|
2812
2833
|
};
|
|
2813
2834
|
|
|
2814
|
-
var styles$
|
|
2835
|
+
var styles$o = {"cw-master-detail":"cw-master-detail-module__cw-master-detail__O8-FA","resizer":"cw-master-detail-module__resizer__hvGhL","detail":"cw-master-detail-module__detail__BG4Dm","skeletonRow":"cw-master-detail-module__skeletonRow__6BUgt","detailSkeleton":"cw-master-detail-module__detailSkeleton__GcDS4","detail-empty":"cw-master-detail-module__detail-empty__KFScK"};
|
|
2815
2836
|
|
|
2816
2837
|
/*
|
|
2817
2838
|
* Fixed rem widths for the ghosts: the master rows and detail panel size their
|
|
@@ -2855,12 +2876,12 @@ const CwMasterDetail = ({ id, className, style, items, selectedKey, onSelect, de
|
|
|
2855
2876
|
document.body.style.userSelect = '';
|
|
2856
2877
|
};
|
|
2857
2878
|
}, [isResizing, minMasterWidth, maxMasterWidth]);
|
|
2858
|
-
const rootClassName = [styles$
|
|
2879
|
+
const rootClassName = [styles$o['cw-master-detail'], className].filter(Boolean).join(' ');
|
|
2859
2880
|
return (jsxs("div", { id: id, ref: containerRef, className: rootClassName, style: style, "aria-busy": loading || undefined, children: [jsxs("aside", { style: { width: masterWidth, minWidth: masterWidth }, children: [showSearch && (jsx("search", { children: jsx("input", { type: "text", placeholder: searchPlaceholder, onChange: (e) => onSearch?.(e.target.value) }) })), masterHeader && (jsx("header", { children: masterHeader })), jsx("ul", { children: loading
|
|
2860
|
-
? Array.from({ length: skeletonRows }, (_unused, rowIndex) => (jsxs("li", { "aria-hidden": "true", children: [jsx(CwSkeleton, { variant: "circle", height: "2rem" }), jsxs("div", { className: styles$
|
|
2861
|
-
: items.map((item) => (jsx("li", { "data-master-key": item.key, "data-selected": item.key === selectedKey, "data-disabled": item.disabled, onClick: () => onSelect?.(item.key), children: item.content }, item.key))) }), masterFooter && (jsx("footer", { children: masterFooter }))] }), resizable && (jsx("div", { className: styles$
|
|
2881
|
+
? Array.from({ length: skeletonRows }, (_unused, rowIndex) => (jsxs("li", { "aria-hidden": "true", children: [jsx(CwSkeleton, { variant: "circle", height: "2rem" }), jsxs("div", { className: styles$o.skeletonRow, children: [jsx(CwSkeleton, { variant: "text", width: MASTER_TITLE_WIDTHS[rowIndex % MASTER_TITLE_WIDTHS.length] }), jsx(CwSkeleton, { variant: "text", width: MASTER_SUBTITLE_WIDTH })] })] }, `skeleton_${rowIndex}`)))
|
|
2882
|
+
: items.map((item) => (jsx("li", { "data-master-key": item.key, "data-selected": item.key === selectedKey, "data-disabled": item.disabled, onClick: () => onSelect?.(item.key), children: item.content }, item.key))) }), masterFooter && (jsx("footer", { children: masterFooter }))] }), resizable && (jsx("div", { className: styles$o.resizer, "data-resizing": isResizing, onMouseDown: handleMouseDown })), jsx("section", { className: styles$o.detail, children: loading ? (jsxs("div", { className: styles$o.detailSkeleton, "aria-hidden": "true", children: [jsx(CwSkeleton, { variant: "text", width: "14rem", height: "1.5em" }), jsx(CwSkeleton, { variant: "text", width: "22rem" }), jsx(CwSkeleton, { variant: "text", width: "18rem" }), jsx(CwSkeleton, { variant: "text", width: "20rem" })] })) : selectedKey && detailContent
|
|
2862
2883
|
? detailContent
|
|
2863
|
-
: (jsx("div", { className: styles$
|
|
2884
|
+
: (jsx("div", { className: styles$o['detail-empty'], children: emptyDetail ?? 'Select an item to view details' })) })] }));
|
|
2864
2885
|
};
|
|
2865
2886
|
|
|
2866
2887
|
/*
|
|
@@ -2900,7 +2921,7 @@ const CwKeyValueList = ({ items, className = "", emptyValue = "-", direction = "
|
|
|
2900
2921
|
return (jsx("dl", { className: `cw-keyvalue-list ${className}`, "data-direction": groupLayout?.direction, "data-align": groupLayout?.align, "data-justify": groupLayout?.justify, "data-gap": groupLayout?.gap, "aria-busy": loading || undefined, ...htmlProps, children: renderItems() }));
|
|
2901
2922
|
};
|
|
2902
2923
|
|
|
2903
|
-
var styles$
|
|
2924
|
+
var styles$n = {"sortableList":"cw-sortable-list-module__sortableList__PyLO-","sortableItem":"cw-sortable-list-module__sortableItem__FAnn2","readOnly":"cw-sortable-list-module__readOnly__r7GcH","dragging":"cw-sortable-list-module__dragging__MD715","moved":"cw-sortable-list-module__moved__sE6-N","expandedContent":"cw-sortable-list-module__expandedContent__Kocna","sortableHandle":"cw-sortable-list-module__sortableHandle__HvYBK","sortableContent":"cw-sortable-list-module__sortableContent__C6JhR","sortableTitle":"cw-sortable-list-module__sortableTitle__EgWXr","sortableExtraContent":"cw-sortable-list-module__sortableExtraContent__s4LSv","sortableActions":"cw-sortable-list-module__sortableActions__gwQOU","dropIndicator":"cw-sortable-list-module__dropIndicator__MNSF-","emptyMessage":"cw-sortable-list-module__emptyMessage__gMpaL"};
|
|
2904
2925
|
|
|
2905
2926
|
function CwSortableList({ items, onReorder, renderItem, className = '', movedItems = new Set(), emptyMessage = "No elements to show", readOnly = false, maxHeight = "300px", }) {
|
|
2906
2927
|
const [draggedItem, setDraggedItem] = useState(null);
|
|
@@ -2963,15 +2984,15 @@ function CwSortableList({ items, onReorder, renderItem, className = '', movedIte
|
|
|
2963
2984
|
}
|
|
2964
2985
|
};
|
|
2965
2986
|
if (items.length === 0) {
|
|
2966
|
-
return (jsx("div", { className: `${styles$
|
|
2987
|
+
return (jsx("div", { className: `${styles$n.sortableList} ${styles$n.emptyState} ${className}`, children: jsx("div", { className: styles$n.emptyMessage, children: emptyMessage }) }));
|
|
2967
2988
|
}
|
|
2968
|
-
return (jsx("div", { className: `${styles$
|
|
2989
|
+
return (jsx("div", { className: `${styles$n.sortableList} ${className}`, style: { maxHeight }, children: items.map((item, index) => {
|
|
2969
2990
|
const { title, extraContent, actions, showHandle = true, expandedContent } = renderItem(item);
|
|
2970
2991
|
const isDragging = draggedItem?.id === item.id;
|
|
2971
2992
|
const isMoved = movedItems.has(item.id);
|
|
2972
2993
|
const canExpand = Boolean(expandedContent);
|
|
2973
2994
|
const isExpanded = expandedItems.has(item.id);
|
|
2974
|
-
return (jsxs(React__default.Fragment, { children: [dropIndicatorIndex === index && jsx("div", { className: styles$
|
|
2995
|
+
return (jsxs(React__default.Fragment, { children: [dropIndicatorIndex === index && jsx("div", { className: styles$n.dropIndicator }), jsxs("div", { className: `${styles$n.sortableItem} ${isDragging ? styles$n.dragging : ''} ${isMoved ? styles$n.moved : ''} ${readOnly ? styles$n.readOnly : ''}`, draggable: !readOnly, onDragStart: (e) => handleDragStart(e, item), onDragOver: (e) => handleDragOver(e, index), onDragEnd: handleDragEnd, children: [jsxs("header", { children: [canExpand ? (jsx(CwButton, { variant: "icon", onClick: () => toggleExpanded(item.id), type: "button", title: isExpanded ? "Collapse" : "Expand", icon: isExpanded ? "chevron-up" : "chevron-down" })) : showHandle ? (jsx("div", { className: styles$n.sortableHandle, children: jsx(CwIcon, { iconId: "grip-dots" }) })) : null, jsxs("div", { className: styles$n.sortableContent, children: [jsx("div", { className: styles$n.sortableTitle, children: title }), extraContent && jsx("div", { className: styles$n.sortableExtraContent, children: extraContent })] }), jsx("div", { className: styles$n.sortableActions, children: actions })] }), isExpanded && expandedContent && (jsx("div", { className: styles$n.expandedContent, children: expandedContent }))] }), !readOnly && dropIndicatorIndex === items.length && index === items.length - 1 && (jsx("div", { className: styles$n.dropIndicator }))] }, item.id));
|
|
2975
2996
|
}) }));
|
|
2976
2997
|
}
|
|
2977
2998
|
|
|
@@ -3098,7 +3119,7 @@ const CwTableGrouped = props => {
|
|
|
3098
3119
|
group.rows.map((child, j) => (jsx("tr", { "data-row": true, "data-row-last-of-group": j == group.rows.length - 1, children: child.cells.map((cell, k) => (jsx("td", { children: cell.content }, k))) }, j)))] }, i))) }), jsx("tfoot", {})] }) }));
|
|
3099
3120
|
};
|
|
3100
3121
|
|
|
3101
|
-
var styles$
|
|
3122
|
+
var styles$m = {"fileUploadContainer":"cw-file-upload-multiple-module__fileUploadContainer__liEc1","hiddenInput":"cw-file-upload-multiple-module__hiddenInput__TZBBI","uploadArea":"cw-file-upload-multiple-module__uploadArea__DdOhs","uploadAreaDisabled":"cw-file-upload-multiple-module__uploadAreaDisabled__VWeFX","uploadTitle":"cw-file-upload-multiple-module__uploadTitle__gjRk8","uploadSubtitle":"cw-file-upload-multiple-module__uploadSubtitle__Z0S5t","filesContainer":"cw-file-upload-multiple-module__filesContainer__g44PY","fileItem":"cw-file-upload-multiple-module__fileItem__w27Dg","fileIcon":"cw-file-upload-multiple-module__fileIcon__iJJUX","fileExtension":"cw-file-upload-multiple-module__fileExtension__vOuHv","fileInfo":"cw-file-upload-multiple-module__fileInfo__R5ZTv","fileName":"cw-file-upload-multiple-module__fileName__DjepK","fileSize":"cw-file-upload-multiple-module__fileSize__b8GSm","smallButton":"cw-file-upload-multiple-module__smallButton__siUAh"};
|
|
3102
3123
|
|
|
3103
3124
|
const DEFAULT_LABELS$1 = {
|
|
3104
3125
|
uploadDisabled: 'Upload disabled',
|
|
@@ -3284,12 +3305,12 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
3284
3305
|
}
|
|
3285
3306
|
}
|
|
3286
3307
|
};
|
|
3287
|
-
return (jsxs("div", { className: `${styles$
|
|
3308
|
+
return (jsxs("div", { className: `${styles$m.fileUploadContainer} ${fileUploadProps.className}`, children: [jsx("input", { ref: fileInputRef, type: "file", name: fileUploadProps.name, accept: fileUploadProps.accept, multiple: fileUploadProps.multiple, onChange: handleFileSelectInternal, disabled: fileUploadProps.disabled, "aria-label": "files", className: styles$m.hiddenInput }), selectedFiles.length === 0 && !existingFile ? (jsxs("div", { className: `${styles$m.uploadArea} ${fileUploadProps.disabled ? styles$m.uploadAreaDisabled : ''}`, onDragOver: handleDragOver, onDrop: handleDrop, onClick: !fileUploadProps.disabled ? handleButtonClick : undefined, children: [jsx(CwIcon, { iconId: "upload" }), jsx("p", { className: `${styles$m.uploadTitle}`, children: fileUploadProps.disabled ? labels.uploadDisabled : labels.clickToUpload }), jsxs("p", { className: `${styles$m.uploadSubtitle}`, children: [fileUploadProps.accept ? labels.acceptedFiles(fileUploadProps.accept) : labels.allTypesAccepted, !fileUploadProps.multiple && ` ${labels.singleFileOnly}`] })] })) : selectedFiles.length === 0 && existingFile ? (jsxs("div", { className: styles$m.filesContainer, children: [jsxs("div", { className: styles$m.fileItem, children: [jsxs("div", { className: styles$m.fileIcon, children: [jsx(CwIcon, { iconId: "page" }), jsx("span", { className: styles$m.fileExtension, children: getFileExtension(existingFile) })] }), jsx("div", { className: styles$m.fileInfo, children: jsx("p", { className: styles$m.fileName, children: existingFile }) }), jsx(CwButton, { variant: "icon", icon: "close", color: "neutral", onClick: () => {
|
|
3288
3309
|
setExistingFile(undefined);
|
|
3289
3310
|
if (fileUploadProps.onSelect) {
|
|
3290
3311
|
fileUploadProps.onSelect(null);
|
|
3291
3312
|
}
|
|
3292
|
-
}, disabled: fileUploadProps.disabled, className: styles$
|
|
3313
|
+
}, disabled: fileUploadProps.disabled, className: styles$m.smallButton })] }), jsx(CwButton, { text: labels.changeFile, icon: "refresh", onClick: handleButtonClick, disabled: fileUploadProps.disabled })] })) : (jsxs("div", { className: styles$m.filesContainer, children: [jsxs("header", { className: "cw-flex-row cw-align-between-center cw-flex-wrap", children: [jsx("small", { className: styles$m.filesCount, children: fileUploadProps.statusText ?? labels.filesSelected(selectedFiles.length) }), jsxs("div", { className: "cw-flex-row", children: [fileUploadProps.onConfirm && selectedFiles.length > 0 && (jsx(CwButton, { onClick: () => {
|
|
3293
3314
|
let files = fileInputRef.current?.files ?? null;
|
|
3294
3315
|
if (!files) {
|
|
3295
3316
|
const dataTransfer = new DataTransfer();
|
|
@@ -3297,7 +3318,7 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
3297
3318
|
files = dataTransfer.files;
|
|
3298
3319
|
}
|
|
3299
3320
|
fileUploadProps.onConfirm?.(files);
|
|
3300
|
-
}, disabled: fileUploadProps.disabled || fileUploadProps.confirmDisabled, icon: "upload", text: fileUploadProps.confirmLabel ?? labels.upload })), !fileUploadProps.hideClearAll && (jsx(CwButton, { onClick: removeAllFiles, disabled: fileUploadProps.disabled, color: "danger", variant: "outline", icon: "delete", text: labels.clearAll }))] })] }), selectedFiles.map((file, index) => (jsxs("div", { className: styles$
|
|
3321
|
+
}, disabled: fileUploadProps.disabled || fileUploadProps.confirmDisabled, icon: "upload", text: fileUploadProps.confirmLabel ?? labels.upload })), !fileUploadProps.hideClearAll && (jsx(CwButton, { onClick: removeAllFiles, disabled: fileUploadProps.disabled, color: "danger", variant: "outline", icon: "delete", text: labels.clearAll }))] })] }), selectedFiles.map((file, index) => (jsxs("div", { className: styles$m.fileItem, children: [jsxs("div", { className: styles$m.fileIcon, children: [jsx(CwIcon, { iconId: "page" }), jsx("span", { className: styles$m.fileExtension, children: getFileExtension(file.name) })] }), jsxs("div", { className: styles$m.fileInfo, children: [jsx("p", { className: styles$m.fileName, children: file.name }), jsxs("p", { className: styles$m.fileSize, children: [(file.size / 1024).toFixed(1), " KB"] })] }), jsx(CwButton, { variant: "icon", icon: "close", color: "neutral", onClick: () => removeFile(index), className: styles$m.smallButton })] }, `${file.name}-${file.size}`))), fileUploadProps.multiple && (jsx(CwButton, { text: labels.addMoreFiles, icon: "plus", variant: "outline", onClick: handleButtonClick, disabled: fileUploadProps.disabled })), !fileUploadProps.multiple && (jsx(CwButton, { text: labels.changeFile, icon: "refresh", onClick: handleButtonClick, disabled: fileUploadProps.disabled }))] }))] }));
|
|
3301
3322
|
}
|
|
3302
3323
|
|
|
3303
3324
|
/**
|
|
@@ -3350,7 +3371,7 @@ function CwDigit(props) {
|
|
|
3350
3371
|
return (jsxs("div", { className: "cw-input-text", "data-direction": labelProps ? flexDirection : "column", "data-feedback-position": feedbackPosition, children: [jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxs("div", { className: "cw-input-button", children: [jsx("input", { type: "number", ...inputProps, "aria-describedby": describedBy }), buttonProps && jsx(CwButton, { ...buttonProps })] })] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-info", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
3351
3372
|
}
|
|
3352
3373
|
|
|
3353
|
-
var styles$
|
|
3374
|
+
var styles$l = {"colorPreview":"cw-color-picker-module__colorPreview__ylJcD","hueBar":"cw-color-picker-module__hueBar__bFhyC","hueBarSlider":"cw-color-picker-module__hueBarSlider__D53IV","colorPickerInteractiveArea":"cw-color-picker-module__colorPickerInteractiveArea__KZFR1","colorArea":"cw-color-picker-module__colorArea__xgpSE","colorAreaOverlay":"cw-color-picker-module__colorAreaOverlay__pmgOc","hueBackground":"cw-color-picker-module__hueBackground__Mks78","whiteGradient":"cw-color-picker-module__whiteGradient__Bt-fU","blackGradient":"cw-color-picker-module__blackGradient__VnEKJ","colorAreaCursor":"cw-color-picker-module__colorAreaCursor__lotg3"};
|
|
3354
3375
|
|
|
3355
3376
|
const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }) => {
|
|
3356
3377
|
const [rgb, setRgb] = useState({ r: 255, g: 255, b: 255 });
|
|
@@ -3553,13 +3574,13 @@ const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }
|
|
|
3553
3574
|
// Calculate background color for the main area based on current hue
|
|
3554
3575
|
const hueColor = hsvToRgb(hsv.h, 100, 100);
|
|
3555
3576
|
const hueHex = rgbToHex(hueColor.r, hueColor.g, hueColor.b);
|
|
3556
|
-
return (jsxs("div", { className: "cw-flex-column cw-gap-small", children: [jsxs("div", { className: "cw-flex-row cw-align-between-center cw-gap-small", children: [jsx("div", { className: styles$
|
|
3577
|
+
return (jsxs("div", { className: "cw-flex-column cw-gap-small", children: [jsxs("div", { className: "cw-flex-row cw-align-between-center cw-gap-small", children: [jsx("div", { className: styles$l.colorPreview, style: { backgroundColor: hexColor, color: getContrastColor(hexColor) }, children: previewText }), jsx("button", { type: "button", className: "cw-button", onClick: toggleInputMode, style: { minWidth: "3ch" }, children: inputMode === 'hex' ? 'RGB' : 'HEX' })] }), jsx("div", { className: "color-inputs-row", children: inputMode === 'hex' ? (jsx("input", { type: "text", value: hexColor, onChange: handleHexChange })) : (jsxs("div", { className: "cw-grid-base-3 cw-gap-small", children: [jsxs("div", { children: [jsx("label", { children: "R:" }), jsx("input", { type: "number", name: "r", min: "0", max: "255", value: rgb.r, onChange: handleRgbChange })] }), jsxs("div", { children: [jsx("label", { children: "G:" }), jsx("input", { type: "number", name: "g", min: "0", max: "255", value: rgb.g, onChange: handleRgbChange })] }), jsxs("div", { children: [jsx("label", { children: "B:" }), jsx("input", { type: "number", name: "b", min: "0", max: "255", value: rgb.b, onChange: handleRgbChange })] })] })) }), jsxs("div", { className: styles$l.colorPickerInteractiveArea, children: [jsx("div", { className: styles$l.hueBar, ref: hueBarRef, onClick: handleHueBarClick, children: jsx("div", { className: styles$l.hueBarSlider, style: { top: `${(360 - hsv.h) / 360 * 100}%` } }) }), jsxs("div", { className: styles$l.colorArea, ref: colorAreaRef, onClick: handleColorAreaClick, children: [jsxs("div", { className: styles$l.colorAreaOverlay, children: [jsx("div", { className: styles$l.hueBackground, style: { backgroundColor: hueHex } }), jsx("div", { className: styles$l.whiteGradient }), jsx("div", { className: styles$l.blackGradient })] }), jsx("div", { className: styles$l.colorAreaCursor, style: {
|
|
3557
3578
|
left: `${hsv.s}%`,
|
|
3558
3579
|
top: `${100 - hsv.v}%`
|
|
3559
3580
|
} })] })] })] }));
|
|
3560
3581
|
};
|
|
3561
3582
|
|
|
3562
|
-
var styles$
|
|
3583
|
+
var styles$k = {"container":"cw-input-color-module__container__x7gpk","selectColor":"cw-input-color-module__selectColor__DTo3V","disabled":"cw-input-color-module__disabled__O1fK5","readOnly":"cw-input-color-module__readOnly__HL-Bz","colorDropdown":"cw-input-color-module__colorDropdown__pX2bc"};
|
|
3563
3584
|
|
|
3564
3585
|
const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, readOnly = false, width = '4rem', height = '2rem', labelProps, layoutProps, className, style, }) => {
|
|
3565
3586
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -3692,11 +3713,11 @@ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled
|
|
|
3692
3713
|
break;
|
|
3693
3714
|
}
|
|
3694
3715
|
};
|
|
3695
|
-
return (jsxs("div", { className: `cw-input-color ${styles$
|
|
3716
|
+
return (jsxs("div", { className: `cw-input-color ${styles$k.container}${className ? ` ${className}` : ''}`, style: style, "data-direction": layoutProps?.direction ?? "row", "data-align": layoutProps?.align, children: [labelProps && (jsx(CwLabel, { ...labelProps })), jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$k.selectColor} ${disabled ? styles$k.disabled : ''} ${readOnly ? styles$k.readOnly : ''}`, style: {
|
|
3696
3717
|
width,
|
|
3697
3718
|
height,
|
|
3698
3719
|
backgroundColor: value,
|
|
3699
|
-
}, "aria-label": "Open color picker", "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-readonly": readOnly, role: "button", tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown }), isOpen && createPortal(jsx("div", { ref: dropdownRef, className: styles$
|
|
3720
|
+
}, "aria-label": "Open color picker", "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-readonly": readOnly, role: "button", tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown }), isOpen && createPortal(jsx("div", { ref: dropdownRef, className: styles$k.colorDropdown, style: dropdownStyle, role: "dialog", "aria-modal": "true", "aria-label": "Color picker", children: jsx(CwColorPicker, { initialColor: value, onChange: handleColorChange, previewText: previewText }) }), document.body)] }));
|
|
3700
3721
|
};
|
|
3701
3722
|
|
|
3702
3723
|
/**
|
|
@@ -3951,7 +3972,7 @@ function CwInputDateText(props) {
|
|
|
3951
3972
|
return (jsx("div", { className: "cw-input-date-text", children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxs("div", { children: [jsx("input", { type: "text", disabled: disabled, maxLength: 10, onChange: onChangeInputText, pattern: "^$ --|[.0-9\\/\\-]{10}", placeholder: format.toLowerCase(), readOnly: readOnly, ref: textInputRef, required: required, size: width, tabIndex: tabIndex, value: displayedDate }), jsxs("span", { children: [jsx(CwIcon, { iconId: "calendar" }), jsx("input", { type: "date", disabled: disabled, onChange: onChangeInputDate, readOnly: readOnly, ref: dateInputRef, tabIndex: -1, value: date, ...inputProps })] })] }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
|
|
3952
3973
|
}
|
|
3953
3974
|
|
|
3954
|
-
var styles$
|
|
3975
|
+
var styles$j = {"hiddenInput":"cw-input-image-module__hiddenInput__pS7hb","dropZone":"cw-input-image-module__dropZone__ygrGu","title":"cw-input-image-module__title__Rji5M","subtitle":"cw-input-image-module__subtitle__djYYu","container":"cw-input-image-module__container__qh7Tm"};
|
|
3955
3976
|
|
|
3956
3977
|
const DEFAULT_LABELS = {
|
|
3957
3978
|
dropImageHere: "Drop image here",
|
|
@@ -4030,7 +4051,7 @@ function CwInputImage(props) {
|
|
|
4030
4051
|
const file = e.currentTarget.files?.[0];
|
|
4031
4052
|
void handleFile(file ?? null);
|
|
4032
4053
|
};
|
|
4033
|
-
return (jsxs("div", { className: `cw-input-image ${styles$
|
|
4054
|
+
return (jsxs("div", { className: `cw-input-image ${styles$j.container}`, "data-size": size, children: [jsxs("div", { onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, className: styles$j.dropZone, children: [jsx(CwIcon, { iconId: "upload" }), jsxs("div", { className: "cw-flex-column cw-gap-tiny", children: [jsx("p", { className: styles$j.title, children: labels.dropImageHere }), jsx("p", { className: styles$j.subtitle, children: labels.acceptedFormats(allowedFormats.join(", ").replace(/image\//g, "")) })] })] }), jsxs("div", { className: "cw-flex-row cw-align-center-center cw-gap-small", children: [jsx(CwButton, { onClick: onPasteButtonClick, icon: "paste", text: labels.paste, size: size }), jsx(CwButton, { onClick: () => inputRef.current?.click(), icon: "folder-open", text: labels.browse, size: size })] }), jsx("input", { ref: inputRef, type: "file", accept: allowedFormats.join(","), onChange: handleFileChange, className: styles$j.hiddenInput, ...inputProps })] }));
|
|
4034
4055
|
}
|
|
4035
4056
|
|
|
4036
4057
|
/**
|
|
@@ -4162,7 +4183,7 @@ const CwImageArea = forwardRef((props, ref) => {
|
|
|
4162
4183
|
});
|
|
4163
4184
|
CwImageArea.displayName = "CwImageArea";
|
|
4164
4185
|
|
|
4165
|
-
var styles$
|
|
4186
|
+
var styles$i = {"container":"cw-weekday-selector-module__container__pwcvx","days":"cw-weekday-selector-module__days__Dd3RH"};
|
|
4166
4187
|
|
|
4167
4188
|
/* 2024-01-01 was a Monday. Formatted in UTC so a negative browser offset cannot shift a day. */
|
|
4168
4189
|
const MONDAY_UTC = Date.UTC(2024, 0, 1);
|
|
@@ -4343,7 +4364,7 @@ class Weekdays {
|
|
|
4343
4364
|
}
|
|
4344
4365
|
}
|
|
4345
4366
|
|
|
4346
|
-
const CwWeekdaySelector = ({ value = "mtwrfsu", onChange, disabled = false, labelProps, layout, feedback, locale = "en-GB", className }) => {
|
|
4367
|
+
const CwWeekdaySelector = ({ value = "mtwrfsu", onChange, disabled = false, labelProps, layout, feedback, locale = "en-GB", className, ...dataAttributes }) => {
|
|
4347
4368
|
const selectedDays = Weekdays.tryFromString(value).toArray();
|
|
4348
4369
|
const dayNames = useMemo(() => getWeekdayNames(locale), [locale]);
|
|
4349
4370
|
const handleChange = (day, checked) => {
|
|
@@ -4360,16 +4381,16 @@ const CwWeekdaySelector = ({ value = "mtwrfsu", onChange, disabled = false, labe
|
|
|
4360
4381
|
// Points at the label element rather than copying its text, which also covers a labelProps that
|
|
4361
4382
|
// carries children instead of `text`.
|
|
4362
4383
|
const labelId = labelProps?.id ?? `${feedbackId}-label`;
|
|
4363
|
-
return (jsxs("div", { className: `cw-weekday-selector ${styles$
|
|
4384
|
+
return (jsxs("div", { ...dataAttributes, className: `cw-weekday-selector ${styles$i.container}${className ? ` ${className}` : ""}`, "data-direction": labelProps ? layout?.direction ?? "row" : "column", "data-align": layout?.align, "data-gap": layout?.gap, children: [labelProps && jsx(CwLabel, { id: labelId, ...labelProps }), jsx("div", { role: "group", className: styles$i.days, "aria-labelledby": labelProps ? labelId : undefined, "aria-describedby": describedBy, children: Weekdays.getFullWeek().map(day => (jsx("input", { type: "checkbox", "data-day": day, "data-letter": dayNames[day].letter, "aria-label": dayNames[day].full, title: dayNames[day].full, checked: selectedDays.includes(day), onChange: (e) => handleChange(day, e.target.checked), disabled: disabled }, day))) }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
4364
4385
|
};
|
|
4365
4386
|
|
|
4366
|
-
var styles$
|
|
4387
|
+
var styles$h = {"check-container":"cw-check-module__check-container__4nscZ","group":"cw-check-module__group__6JCQo","options":"cw-check-module__options__-g9LF"};
|
|
4367
4388
|
|
|
4368
4389
|
function CwCheck(props) {
|
|
4369
4390
|
const { labelProps, labelText, direction, alignment, className, ...inputProps } = props;
|
|
4370
4391
|
const resolvedDirection = direction ?? alignment ?? "row";
|
|
4371
4392
|
const displayText = labelProps?.text ?? labelText;
|
|
4372
|
-
return (jsx("div", { className: `cw-check ${styles$
|
|
4393
|
+
return (jsx("div", { className: `cw-check ${styles$h["check-container"]}${className ? ` ${className}` : ''}`, children: jsxs("label", { "data-direction": resolvedDirection, children: [jsx("input", { type: "checkbox", ...inputProps }), displayText && (jsx("span", { className: "cw-icon-text", children: displayText }))] }) }));
|
|
4373
4394
|
}
|
|
4374
4395
|
|
|
4375
4396
|
function CwCheckbox(CwCheckboxProps) {
|
|
@@ -4423,14 +4444,14 @@ function CwCheckboxGroup({ options, value = [], onChange, labelProps, groupLayou
|
|
|
4423
4444
|
?? (optionsAlignment === "column" ? "row" : "column");
|
|
4424
4445
|
// Each checkbox's box-to-text layout is the opposite of the options flow, mirroring CwRadioGroup.
|
|
4425
4446
|
const checkDirection = itemDirection === "row" ? "column" : "row";
|
|
4426
|
-
return (jsxs("div", { className: `cw-checkbox-group ${styles$
|
|
4447
|
+
return (jsxs("div", { className: `cw-checkbox-group ${styles$h.group}${className ? ` ${className}` : ""}`, "data-testid": dataTestId, "data-direction": labelProps ? groupDirection : "column", "data-align": groupLayout?.align, "data-gap": groupLayout?.gap, children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsx("div", { className: styles$h.options, role: "group", "aria-label": labelProps?.text, "aria-describedby": describedBy, "aria-required": required || undefined, "data-direction": itemDirection, "data-gap": itemLayout?.gap, children: options.map((option) => (jsx(CwCheck, { labelProps: { text: option.label }, checked: value.includes(option.value), disabled: disabled || option.disabled, direction: checkDirection, onChange: (e) => handleChange(option.value, e.currentTarget.checked) }, option.value))) }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
4427
4448
|
}
|
|
4428
4449
|
|
|
4429
|
-
var styles$
|
|
4450
|
+
var styles$g = {"radio":"cw-radio-module__radio__5sh7a","group":"cw-radio-module__group__br-HM","options":"cw-radio-module__options__LSw7M"};
|
|
4430
4451
|
|
|
4431
4452
|
/** Single native radio input. Building block for CwRadioGroup. */
|
|
4432
4453
|
function CwRadio({ label, direction = "row", className, ...inputProps }) {
|
|
4433
|
-
return (jsxs("label", { className: `cw-radio ${styles$
|
|
4454
|
+
return (jsxs("label", { className: `cw-radio ${styles$g.radio}${className ? ` ${className}` : ""}`, "data-direction": direction, children: [jsx("input", { type: "radio", ...inputProps }), label && jsx("span", { children: label })] }));
|
|
4434
4455
|
}
|
|
4435
4456
|
|
|
4436
4457
|
/**
|
|
@@ -4457,7 +4478,7 @@ function CwRadioGroup({ options, value, onChange, labelProps, groupLayout, itemL
|
|
|
4457
4478
|
// (itemLayout column) reads best with the circle beside the text; a side-by-side row reads
|
|
4458
4479
|
// best with the circle above the text.
|
|
4459
4480
|
const radioDirection = itemLayout?.direction === "row" ? "column" : "row";
|
|
4460
|
-
return (jsxs("div", { className: `cw-radio-group ${styles$
|
|
4481
|
+
return (jsxs("div", { className: `cw-radio-group ${styles$g.group}${className ? ` ${className}` : ""}`, "data-testid": dataTestId, "data-direction": labelProps ? (groupLayout?.direction ?? "column") : "column", "data-align": groupLayout?.align, "data-gap": groupLayout?.gap, children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsx("div", { className: styles$g.options, role: "radiogroup", "aria-describedby": describedBy, "aria-labelledby": ariaLabelledby, "aria-label": ariaLabelledby ? undefined : (ariaLabel ?? labelProps?.text), "aria-required": required || undefined, "data-direction": itemLayout?.direction ?? "column", "data-gap": itemLayout?.gap, children: options.map((option) => (jsx(CwRadio, { name: groupName, label: option.label, direction: radioDirection, checked: value === option.value, required: required, disabled: disabled || option.disabled, onChange: () => onChange(option.value) }, option.value))) }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
4461
4482
|
}
|
|
4462
4483
|
|
|
4463
4484
|
function CwToggle(props) {
|
|
@@ -4598,7 +4619,7 @@ function useDropdownPortal({ anchorRef, isOpen, onClose, positionStrategy = defa
|
|
|
4598
4619
|
return { panelRef, panelStyle: style, renderPanel };
|
|
4599
4620
|
}
|
|
4600
4621
|
|
|
4601
|
-
var styles$
|
|
4622
|
+
var styles$f = {"dropdown":"cw-dropdown-module__dropdown__EFZ9M cw-choice-dropdown-module__dropdown__P0b4j","option":"cw-dropdown-module__option__TuMdI cw-choice-dropdown-module__option__uR-ro","optionFocused":"cw-dropdown-module__optionFocused__7LGaC cw-choice-dropdown-module__optionFocused__BYMxj","optionSelected":"cw-dropdown-module__optionSelected__OiXIc cw-choice-dropdown-module__optionSelected__Lt8Xg","optionDisabled":"cw-dropdown-module__optionDisabled__lYM6w cw-choice-dropdown-module__optionDisabled__n3scM","emptyState":"cw-dropdown-module__emptyState__gp8KT cw-choice-dropdown-module__emptyState__HO0Y7","searchBox":"cw-dropdown-module__searchBox__Bx0JE cw-choice-dropdown-module__searchBox__0gox7","searchInput":"cw-dropdown-module__searchInput__JrxCK cw-choice-dropdown-module__searchInput__G5oRs","value":"cw-dropdown-module__value__i-7IN","colorCircle":"cw-dropdown-module__colorCircle__5kgiT cw-choice-dropdown-module__colorCircle__x7mI9"};
|
|
4602
4623
|
|
|
4603
4624
|
/**
|
|
4604
4625
|
* Custom dropdown component with colour-coded options, optional search filter, and full
|
|
@@ -4712,12 +4733,12 @@ function CwDropdown({ options, value, onChange, labelProps, alignProps, placehol
|
|
|
4712
4733
|
}
|
|
4713
4734
|
}, [isOpen, highlightedIndex, filteredOptions, handleOptionSelect]);
|
|
4714
4735
|
const flexDirection = alignProps?.flexDirection ?? "row";
|
|
4715
|
-
return (jsx("div", { ref: containerRef, className: `cw-dropdown${className ? ` ${className}` : ""}`, "data-direction": flexDirection, style: style, ...otherProps, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && jsx(CwLabel, { id: labelId, ...labelProps }), jsxs("div", { className: styles$
|
|
4716
|
-
styles$
|
|
4717
|
-
value === option.value ? styles$
|
|
4718
|
-
highlightedIndex === index ? styles$
|
|
4719
|
-
option.disabled ? styles$
|
|
4720
|
-
].filter(Boolean).join(" "), onClick: () => !option.disabled && handleOptionSelect(option.value), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": value === option.value, "aria-disabled": option.disabled, children: [option.color && (jsx("span", { className: styles$
|
|
4736
|
+
return (jsx("div", { ref: containerRef, className: `cw-dropdown${className ? ` ${className}` : ""}`, "data-direction": flexDirection, style: style, ...otherProps, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && jsx(CwLabel, { id: labelId, ...labelProps }), jsxs("div", { className: styles$f.value, children: [jsxs("div", { className: "cw-dropdown-wrapper", ref: wrapperRef, children: [jsxs("button", { type: "button", className: "cw-dropdown-trigger", onClick: handleTriggerClick, onKeyDown: handleKeyDown, disabled: disabled, "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-labelledby": labelProps ? `${labelId} ${valueId}` : undefined, "aria-label": labelProps ? undefined : (selectedOption?.label || placeholder), "aria-describedby": describedBy, children: [jsx("div", { className: "cw-dropdown-trigger-content", id: valueId, children: selectedOption ? (jsxs(Fragment, { children: [selectedOption.color && (jsx("span", { className: styles$f.colorCircle, style: { backgroundColor: selectedOption.color } })), jsx("span", { children: selectedOption.label })] })) : (jsx("span", { className: "cw-dropdown-placeholder", children: placeholder })) }), jsx(CwIcon, { iconId: "chevron-down", size: "small" })] }), renderPanel(jsxs("div", { ref: panelRef, className: styles$f.dropdown, style: panelStyle, role: "listbox", onKeyDown: handleKeyDown, children: [allowSearch && (jsx("div", { className: styles$f.searchBox, children: jsx("input", { ref: inputRef, type: "text", placeholder: "Search...", value: searchText, onChange: handleSearchChange, onKeyDown: handleKeyDown, className: styles$f.searchInput, autoComplete: "off" }) })), jsx("ul", { children: filteredOptions.length > 0 ? (filteredOptions.map((option, index) => (jsxs("li", { ref: highlightedIndex === index ? highlightedItemRef : null, className: [
|
|
4737
|
+
styles$f.option,
|
|
4738
|
+
value === option.value ? styles$f.optionSelected : "",
|
|
4739
|
+
highlightedIndex === index ? styles$f.optionFocused : "",
|
|
4740
|
+
option.disabled ? styles$f.optionDisabled : "",
|
|
4741
|
+
].filter(Boolean).join(" "), onClick: () => !option.disabled && handleOptionSelect(option.value), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": value === option.value, "aria-disabled": option.disabled, children: [option.color && (jsx("span", { className: styles$f.colorCircle, style: { backgroundColor: option.color } })), jsx("span", { children: option.label })] }, option.value)))) : (jsx("li", { className: styles$f.emptyState, children: "No options available" })) })] }))] }), feedbackMessages.map((item, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": item.type, "aria-live": "polite", children: item.message }, index)))] })] }) }));
|
|
4721
4742
|
}
|
|
4722
4743
|
|
|
4723
4744
|
/**
|
|
@@ -4734,7 +4755,7 @@ function CwDropdownFilter(props) {
|
|
|
4734
4755
|
return (jsxs("div", { id: props.IdContent, className: containerClassName, children: [props.children, isVisible && (jsx("nav", { className: "cw-dropdown-menu", style: inlineStyles, onMouseLeave: props.onMouseLeave, id: props.idDropDownFilter, role: "menu", children: jsx("ul", { role: "none", children: props.DataSourceDropDownItem?.map((item) => (jsx("li", { id: item.IdDropDown_filter, role: "menuitem", children: item.dropDownFilter_desc }, item.IdDropDown_filter))) }) }))] }));
|
|
4735
4756
|
}
|
|
4736
4757
|
|
|
4737
|
-
var styles$
|
|
4758
|
+
var styles$e = {"container":"cw-popover-button-module__container__YSWQU","panel":"cw-popover-button-module__panel__C-BTn"};
|
|
4738
4759
|
|
|
4739
4760
|
/**
|
|
4740
4761
|
* Button that toggles a floating panel with arbitrary children.
|
|
@@ -4813,7 +4834,7 @@ function CwPopoverButton({ children, panelWidth = "auto", placement = "bottom-st
|
|
|
4813
4834
|
}
|
|
4814
4835
|
panel.showPopover();
|
|
4815
4836
|
}, [placement]);
|
|
4816
|
-
return (jsxs("div", { ref: containerRef, className: styles$
|
|
4837
|
+
return (jsxs("div", { ref: containerRef, className: styles$e.container, children: [jsx(CwButton, { ...buttonProps, onClick: handleClick }), jsx("div", { ref: panelCallbackRef, className: `${styles$e.panel}${panelClassName ? ` ${panelClassName}` : ""}`, style: { width: panelWidth }, children: children })] }));
|
|
4817
4838
|
}
|
|
4818
4839
|
|
|
4819
4840
|
function itemsToMultiFilterTags(items, nameKey, valueKey, category, primaryColor, onPrimaryColor) {
|
|
@@ -4831,13 +4852,13 @@ function itemsToMultiFilterTags(items, nameKey, valueKey, category, primaryColor
|
|
|
4831
4852
|
return result;
|
|
4832
4853
|
}
|
|
4833
4854
|
|
|
4834
|
-
var styles$
|
|
4855
|
+
var styles$d = {"cw-multifilter-tag":"cw-multi-filter-tag-module__cw-multifilter-tag__Epda-"};
|
|
4835
4856
|
|
|
4836
4857
|
const CwMultiFilterTag = props => {
|
|
4837
4858
|
const { ID, Name, Value, Category, Removable, PrimaryColor, Selectable, Selected } = props;
|
|
4838
4859
|
const backgroundColor = `rgb(${PrimaryColor.r},${PrimaryColor.g},${PrimaryColor.b})`;
|
|
4839
4860
|
const isOutlineMode = Selected && !Removable;
|
|
4840
|
-
return (jsx("li", { className: styles$
|
|
4861
|
+
return (jsx("li", { className: styles$d["cw-multifilter-tag"], id: ID, "data-value": Value, "data-category": Category, "data-selected": !!Selected, title: props.tooltip ?? Name, onClick: () => {
|
|
4841
4862
|
if (Selectable)
|
|
4842
4863
|
props.OnSelect?.(props);
|
|
4843
4864
|
}, children: jsx(CwChip, { label: Name, colorScheme: "custom", customColor: backgroundColor, variant: isOutlineMode ? "outline" : "soft", closable: Removable, onClose: () => props.OnRemove?.(props),
|
|
@@ -4847,7 +4868,7 @@ const CwMultiFilterTag = props => {
|
|
|
4847
4868
|
} : undefined }) }));
|
|
4848
4869
|
};
|
|
4849
4870
|
|
|
4850
|
-
var styles$
|
|
4871
|
+
var styles$c = {"cw-multi-filter-catalog-container":"cw-multi-filter-module__cw-multi-filter-catalog-container__S3nsq","cw-multi-filter":"cw-multi-filter-module__cw-multi-filter__zipBK","category-selected":"cw-multi-filter-module__category-selected__eYbes","cw-multi-filter-search":"cw-multi-filter-module__cw-multi-filter-search__eyHr0 cw-choice-input-box-module__inputBox__gHY9d"};
|
|
4851
4872
|
|
|
4852
4873
|
/**
|
|
4853
4874
|
* A multiple filter selector, a MULTI-SELECT even. Allows users to select and filter items based on tags.
|
|
@@ -5088,9 +5109,9 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
5088
5109
|
inputRef.current?.focus();
|
|
5089
5110
|
}
|
|
5090
5111
|
};
|
|
5091
|
-
return (jsxs("form", { ref: componentRef, id: id, "data-testid": testId, className: `${styles$
|
|
5112
|
+
return (jsxs("form", { ref: componentRef, id: id, "data-testid": testId, className: `${styles$c["cw-multi-filter"]}${className ? ` ${className}` : ""}`, style: style, onSubmit: (e) => {
|
|
5092
5113
|
e.preventDefault();
|
|
5093
|
-
}, children: [jsxs("div", { onClick: handleDivClick, ref: wrapperRef, className: styles$
|
|
5114
|
+
}, children: [jsxs("div", { onClick: handleDivClick, ref: wrapperRef, className: styles$c["cw-multi-filter-search"], style: isPanelOpen ? { outline: "1px solid var(--cw-outline-variant)" } : {}, children: [jsxs("ul", { id: id + "_selected_filters", children: [Array.from(selectedTags).map(tag => (createElement(CwMultiFilterTag, { ...tag, key: tag.ID, Selectable: false, Removable: true, OnRemove: () => removeTag(tag.ID) }))), jsx("input", { type: "text", id: id + "_input", ref: inputRef, value: inputTextValue, spellCheck: false, onFocus: () => setIsPanelOpen(true), onChange: e => handleInputText(e.currentTarget.value), autoComplete: "off", placeholder: selectedTags.size === 0 ? placeholder : "", onKeyDown: e => {
|
|
5094
5115
|
switch (e.key) {
|
|
5095
5116
|
case "Enter":
|
|
5096
5117
|
case "Tab": {
|
|
@@ -5117,7 +5138,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
5117
5138
|
break;
|
|
5118
5139
|
}
|
|
5119
5140
|
}
|
|
5120
|
-
} })] }), selectedTags.size > 0 && (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onMouseDown: e => e.preventDefault(), onClick: (e) => { e.stopPropagation(); onChangeSelectedTags(new Set()); setIsPanelOpen(false); }, tabIndex: -1, "aria-label": "Clear all" }))] }), renderPanel(jsxs("section", { ref: panelRef, className: styles$
|
|
5141
|
+
} })] }), selectedTags.size > 0 && (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onMouseDown: e => e.preventDefault(), onClick: (e) => { e.stopPropagation(); onChangeSelectedTags(new Set()); setIsPanelOpen(false); }, tabIndex: -1, "aria-label": "Clear all" }))] }), renderPanel(jsxs("section", { ref: panelRef, className: styles$c["cw-multi-filter-catalog-container"], style: panelStyle, children: [jsxs("nav", { children: [jsx("button", { className: selectedCategory === "All" ? styles$c["category-selected"] : undefined, onClick: () => handleClickCategory("All"), children: allCategoriesLabel }), Array.from(categoriesMappedToTags().keys()).map(category => (jsx("button", { className: selectedCategory === category ? styles$c["category-selected"] : undefined, style: {
|
|
5121
5142
|
backgroundColor: getColor(category).primary,
|
|
5122
5143
|
color: getColor(category).onPrimary,
|
|
5123
5144
|
}, onClick: () => handleClickCategory(category), children: category }, category)))] }), jsx("ul", { children: displayTags
|
|
@@ -5143,7 +5164,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
5143
5164
|
} }, props.ID))) })] }))] }));
|
|
5144
5165
|
};
|
|
5145
5166
|
|
|
5146
|
-
var styles$
|
|
5167
|
+
var styles$b = {"container":"cw-tag-selector-module__container__-do8i","value":"cw-tag-selector-module__value__TDAy3","inputBox":"cw-tag-selector-module__inputBox__3NGz9 cw-choice-input-box-module__inputBox__gHY9d","disabled":"cw-tag-selector-module__disabled__vbud9 cw-choice-input-box-module__disabled__TFAnC","dropdown":"cw-tag-selector-module__dropdown__X6Dob cw-choice-dropdown-module__dropdown__P0b4j","option":"cw-tag-selector-module__option__2UQ7g cw-choice-dropdown-module__option__uR-ro","optionFocused":"cw-tag-selector-module__optionFocused__8-lv8 cw-choice-dropdown-module__optionFocused__BYMxj","optionDot":"cw-tag-selector-module__optionDot__CdFlG cw-choice-dropdown-module__colorCircle__x7mI9","selectAll":"cw-tag-selector-module__selectAll__HyvMA"};
|
|
5147
5168
|
|
|
5148
5169
|
/**
|
|
5149
5170
|
* Multi-select input with chip tags and searchable dropdown.
|
|
@@ -5281,13 +5302,13 @@ function CwTagSelector({ id, options, value, onChange, labelProps, iconProps, al
|
|
|
5281
5302
|
const feedbackId = useId();
|
|
5282
5303
|
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
5283
5304
|
const describedBy = feedbackIds.join(" ") || undefined;
|
|
5284
|
-
return (jsxs("div", { ref: containerRef, className: `${styles$
|
|
5285
|
-
inputRef.current?.focus(); }, children: [selectedOptions.map(opt => (jsx(CwChip, { label: opt.label, colorScheme: opt.color ? "custom" : "info", customColor: opt.color, closable: !disabled, onClose: () => handleRemove(opt.value) }, opt.value))), jsx("input", { ref: inputRef, type: "text", value: search, onChange: handleInputChange, onFocus: handleInputFocus, onKeyDown: handleKeyDown, placeholder: selectedOptions.length === 0 ? placeholder : "", disabled: disabled, autoComplete: "off", "aria-describedby": describedBy }), value.length > 0 && !disabled && (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onMouseDown: (e) => e.preventDefault(), onClick: (e) => { e.stopPropagation(); onChange([]); setSearch(""); setOpen(false); }, tabIndex: -1, "aria-label": "Clear all" }))] }), feedbackMessages.map((fb, i) => (jsx("p", { id: feedbackIds[i], className: "cw-input-feedback", "data-color": fb.type, "aria-live": "polite", children: fb.message }, i)))] })] }), renderPanel((showSelectAll || filtered.length > 0) ? (jsxs("div", { ref: panelRef, className: styles$
|
|
5305
|
+
return (jsxs("div", { ref: containerRef, className: `${styles$b.container}${className ? ` ${className}` : ""}`, style: style, id: id, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxs("div", { className: styles$b.value, children: [jsxs("div", { className: `${styles$b.inputBox}${disabled ? ` ${styles$b.disabled}` : ""}`, ref: inputBoxRef, onClick: () => { if (!disabled)
|
|
5306
|
+
inputRef.current?.focus(); }, children: [selectedOptions.map(opt => (jsx(CwChip, { label: opt.label, colorScheme: opt.color ? "custom" : "info", customColor: opt.color, closable: !disabled, onClose: () => handleRemove(opt.value) }, opt.value))), jsx("input", { ref: inputRef, type: "text", value: search, onChange: handleInputChange, onFocus: handleInputFocus, onKeyDown: handleKeyDown, placeholder: selectedOptions.length === 0 ? placeholder : "", disabled: disabled, autoComplete: "off", "aria-describedby": describedBy }), value.length > 0 && !disabled && (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onMouseDown: (e) => e.preventDefault(), onClick: (e) => { e.stopPropagation(); onChange([]); setSearch(""); setOpen(false); }, tabIndex: -1, "aria-label": "Clear all" }))] }), feedbackMessages.map((fb, i) => (jsx("p", { id: feedbackIds[i], className: "cw-input-feedback", "data-color": fb.type, "aria-live": "polite", children: fb.message }, i)))] })] }), renderPanel((showSelectAll || filtered.length > 0) ? (jsxs("div", { ref: panelRef, className: styles$b.dropdown, style: panelStyle, children: [showSelectAll && !search && (jsxs("div", { className: styles$b.selectAll, onMouseDown: (e) => e.preventDefault(), onClick: handleToggleAll, children: [jsx("input", { type: "checkbox", checked: allSelected, readOnly: true, tabIndex: -1 }), allSelected ? "Deselect all" : "Select all"] })), jsx("ul", { ref: listRef, children: filtered.map((opt, idx) => (jsxs("li", { className: `${styles$b.option}${idx === focusedIndex ? ` ${styles$b.optionFocused}` : ""}`, onMouseDown: (e) => e.preventDefault(), onClick: () => handleSelect(opt.value), onMouseEnter: () => setFocusedIndex(idx), title: opt.tooltip, children: [opt.color && jsx("span", { className: styles$b.optionDot, style: { backgroundColor: opt.color } }), opt.label] }, opt.value))) })] })) : null)] }));
|
|
5286
5307
|
}
|
|
5287
5308
|
|
|
5288
|
-
var styles$
|
|
5309
|
+
var styles$a = {"tree-container":"cw-tree-view-module__tree-container__NN-HJ","tree-wrapper":"cw-tree-view-module__tree-wrapper__keBZI","tree-item":"cw-tree-view-module__tree-item__prE9N","tree-node":"cw-tree-view-module__tree-node__wfro9","selected":"cw-tree-view-module__selected__XJQ0w","non-selectable":"cw-tree-view-module__non-selectable__YuPSx","tree-children":"cw-tree-view-module__tree-children__ji8CZ","empty-state":"cw-tree-view-module__empty-state__yvRjo","tree-label":"cw-tree-view-module__tree-label__ss3Nf","tree-spacer":"cw-tree-view-module__tree-spacer__E9Ud2"};
|
|
5289
5310
|
|
|
5290
|
-
function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId: initialSelectedId = null }) {
|
|
5311
|
+
function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId: initialSelectedId = null, ...dataAttributes }) {
|
|
5291
5312
|
const [expanded, setExpanded] = useState(new Set());
|
|
5292
5313
|
// const [selectedId, setSelectedId] = useState<string | number | null>(initialSelectedId);
|
|
5293
5314
|
const [selectedId, setSelectedId] = useState(null);
|
|
@@ -5352,10 +5373,10 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
5352
5373
|
const isLeaf = !hasChildren;
|
|
5353
5374
|
const isSelected = selectedId?.toString().toLowerCase() === node.id.toString().toLowerCase();
|
|
5354
5375
|
const selectable = allowParentSelection || isLeaf;
|
|
5355
|
-
return (jsxs("div", { className: styles$
|
|
5356
|
-
styles$
|
|
5357
|
-
isSelected && styles$
|
|
5358
|
-
!selectable && styles$
|
|
5376
|
+
return (jsxs("div", { className: styles$a["tree-item"], children: [jsxs("div", { className: [
|
|
5377
|
+
styles$a["tree-node"],
|
|
5378
|
+
isSelected && styles$a["selected"],
|
|
5379
|
+
!selectable && styles$a["non-selectable"]
|
|
5359
5380
|
].filter(Boolean).join(' '), style: { paddingLeft: `${depth * 24 + 8}px` }, onClick: () => {
|
|
5360
5381
|
if (selectable) {
|
|
5361
5382
|
setSelectedId(node.id);
|
|
@@ -5364,7 +5385,10 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
5364
5385
|
else {
|
|
5365
5386
|
toggleExpand(node.id);
|
|
5366
5387
|
}
|
|
5367
|
-
}, children: [hasChildren && (jsx(
|
|
5388
|
+
}, children: [hasChildren && (jsx(CwButton, { variant: "icon", color: "neutral", icon: isExpanded ? "chevron-down" : "chevron-right", "aria-expanded": isExpanded, "aria-label": `${isExpanded ? "Collapse" : "Expand"} ${node.label}`, onClick: (event) => {
|
|
5389
|
+
event.stopPropagation();
|
|
5390
|
+
toggleExpand(node.id);
|
|
5391
|
+
} })), jsx("div", { className: `${styles$a["tree-label"]} ${!hasChildren ? styles$a["tree-spacer"] : ''}`, children: node.label })] }), hasChildren && isExpanded && (jsx("div", { className: styles$a["tree-children"], children: node.children.map((child) => renderNode(child, depth + 1)) }))] }, node.id));
|
|
5368
5392
|
};
|
|
5369
5393
|
// Function to search for nodes that match the search term
|
|
5370
5394
|
const searchInTree = (nodes, searchTerm) => {
|
|
@@ -5388,7 +5412,7 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
5388
5412
|
return results;
|
|
5389
5413
|
};
|
|
5390
5414
|
const filteredData = searchInTree(data, search);
|
|
5391
|
-
return (jsxs("div", { className: `cw-tree-view ${styles$
|
|
5415
|
+
return (jsxs("div", { ...dataAttributes, className: `cw-tree-view ${styles$a["tree-container"]}`, children: [jsxs("header", { children: [jsx("input", { type: "text", placeholder: "Search in tree...", value: search, onChange: (e) => setSearch(e.target.value) }), search && (jsx(CwButton, { onClick: () => setSearch(""), type: "button", icon: "close", variant: "icon", color: "neutral" }))] }), jsx("div", { className: styles$a["tree-wrapper"], children: filteredData.length > 0 ? (filteredData.map((node) => renderNode(node))) : (jsxs("div", { className: styles$a["empty-state"], children: [jsx(CwIcon, { iconId: "comment" }), search ? "No results found" : "There are no items"] })) })] }));
|
|
5392
5416
|
}
|
|
5393
5417
|
|
|
5394
5418
|
const EXACT_PHRASE = /"([^"]+)"/g;
|
|
@@ -5456,7 +5480,7 @@ function sortNavItems(items, alphabetically) {
|
|
|
5456
5480
|
return [...items].sort((first, second) => first.label.localeCompare(second.label));
|
|
5457
5481
|
}
|
|
5458
5482
|
|
|
5459
|
-
var styles$
|
|
5483
|
+
var styles$9 = {"menu":"cw-nav-menu-module__menu__LmeQg","expandIndicator":"cw-nav-menu-module__expandIndicator__TBSdQ","favorites":"cw-nav-menu-module__favorites__Esaqd","favoritesContent":"cw-nav-menu-module__favoritesContent__l5DGG","favoriteStar":"cw-nav-menu-module__favoriteStar__J-jzg","emptyMessage":"cw-nav-menu-module__emptyMessage__-CQNd","skeleton":"cw-nav-menu-module__skeleton__INQqF"};
|
|
5460
5484
|
|
|
5461
5485
|
const SKELETON_ROW_COUNT = 5;
|
|
5462
5486
|
const defaultRenderLink = (item, children) => (jsx("a", { href: item.href, children: children }));
|
|
@@ -5468,13 +5492,13 @@ function CwNavMenu({ items, loading = false, isActive, renderLink = defaultRende
|
|
|
5468
5492
|
const renderItem = (item, level) => {
|
|
5469
5493
|
const children = item.children;
|
|
5470
5494
|
if (children && children.length > 0) {
|
|
5471
|
-
return (jsx("li", { children: jsxs("details", { "data-level": level, open: hasActiveDescendant(item) || undefined, children: [jsxs("summary", { children: [item.icon && jsx(CwIcon, { iconId: item.icon, size: level >= 2 ? "small" : "medium" }), item.label, (showExpandIndicator || level >= 2) && (jsx(CwIcon, { iconId: "chevron-down", size: "small", className: styles$
|
|
5495
|
+
return (jsx("li", { children: jsxs("details", { "data-level": level, open: hasActiveDescendant(item) || undefined, children: [jsxs("summary", { children: [item.icon && jsx(CwIcon, { iconId: item.icon, size: level >= 2 ? "small" : "medium" }), item.label, (showExpandIndicator || level >= 2) && (jsx(CwIcon, { iconId: "chevron-down", size: "small", className: styles$9.expandIndicator }))] }), jsx("ul", { children: children.map(child => renderItem(child, level + 1)) })] }) }, item.id));
|
|
5472
5496
|
}
|
|
5473
|
-
return (jsx("li", { "data-active": isActive?.(item) ? "true" : undefined, children: renderLink(item, jsxs(Fragment, { children: [item.icon && jsx(CwIcon, { iconId: item.icon, size: "medium" }), item.label, isFavorite?.(item) && jsx(CwIcon, { iconId: "star", size: "small", className: styles$
|
|
5497
|
+
return (jsx("li", { "data-active": isActive?.(item) ? "true" : undefined, children: renderLink(item, jsxs(Fragment, { children: [item.icon && jsx(CwIcon, { iconId: item.icon, size: "medium" }), item.label, isFavorite?.(item) && jsx(CwIcon, { iconId: "star", size: "small", className: styles$9.favoriteStar })] })) }, item.id));
|
|
5474
5498
|
};
|
|
5475
|
-
return (jsxs("nav", { ...navProps, className: [styles$
|
|
5476
|
-
? Array.from({ length: SKELETON_ROW_COUNT }, (_unused, index) => (jsx("li", { className: styles$
|
|
5477
|
-
: visibleItems.map(item => renderItem(item, 1)) }), showEmptyMessage && jsx("p", { className: styles$
|
|
5499
|
+
return (jsxs("nav", { ...navProps, className: [styles$9.menu, className].filter(Boolean).join(" "), "aria-busy": loading || undefined, children: [favoritesSlot && (jsxs("details", { open: true, ...favoritesProps, className: [styles$9.favorites, favoritesProps?.className].filter(Boolean).join(" "), children: [jsxs("summary", { children: [jsx(CwIcon, { iconId: "star", size: "medium" }), favoritesLabel] }), jsx("div", { className: styles$9.favoritesContent, children: favoritesSlot })] })), beforeTreeSlot, jsx("ul", { children: loading
|
|
5500
|
+
? Array.from({ length: SKELETON_ROW_COUNT }, (_unused, index) => (jsx("li", { className: styles$9.skeleton, children: jsx(CwSkeleton, { height: "var(--cw-size-small)", radius: "var(--cw-border-radius-small)" }) }, index)))
|
|
5501
|
+
: visibleItems.map(item => renderItem(item, 1)) }), showEmptyMessage && jsx("p", { className: styles$9.emptyMessage, children: emptyMessage })] }));
|
|
5478
5502
|
}
|
|
5479
5503
|
|
|
5480
5504
|
var dropdownStyles = {"dropdown":"cw-choice-dropdown-module__dropdown__P0b4j","option":"cw-choice-dropdown-module__option__uR-ro","optionFocused":"cw-choice-dropdown-module__optionFocused__BYMxj"};
|
|
@@ -5640,6 +5664,8 @@ function CwSearchInput(optionsProps) {
|
|
|
5640
5664
|
return (jsxs("div", { className: `cw-search-input ${className || ""}`, style: style, ...otherProps, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsx("input", { ref: inputRef, id: id, type: "text", value: searchText, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: handleInputFocus, onBlur: handleInputBlur, placeholder: placeholder, className: "cw-input-search", disabled: disabled, autoFocus: autoFocus, autoComplete: "off", role: "combobox", "aria-haspopup": "listbox", "aria-expanded": showDropdown && filteredOptions.length > 0, "aria-controls": listboxId, "aria-activedescendant": highlightedIndex >= 0 ? optionId(highlightedIndex) : undefined }), isLoading && (jsx("div", { className: "cw-search-input-loading", children: jsx(CwIcon, { iconId: "spinner" }) })), jsx("div", { className: "cw-search-input-icons", children: searchText && !disabled && !isLoading ? (jsx(CwButton, { type: "button", onClick: handleClearClick, "aria-label": "Clear search", variant: "icon", icon: "close", color: "neutral" })) : (iconProps ? jsx(CwIcon, { ...iconProps }) : jsx(CwIcon, { iconId: "search" })) })] })] }), renderPanel(jsx("div", { ref: panelRef, id: listboxId, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsx("ul", { children: filteredOptions.map((option, index) => (jsx("li", { id: optionId(index), className: `${dropdownStyles.option}${index === highlightedIndex ? ` ${dropdownStyles.optionFocused}` : ""}`, onClick: () => handleOptionSelect(option), onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: renderOption ? renderOption(option) : option.description }, option.id))) }) }))] }));
|
|
5641
5665
|
}
|
|
5642
5666
|
|
|
5667
|
+
var styles$8 = {"value":"cw-search-async-module__value__z53xT"};
|
|
5668
|
+
|
|
5643
5669
|
/**
|
|
5644
5670
|
* Generic API-backed search input. Fetches matching options from a caller-supplied `onSearch`
|
|
5645
5671
|
* callback as the user types (debounced), renders them in a portal-based dropdown with keyboard
|
|
@@ -5661,7 +5687,7 @@ function CwSearchInput(optionsProps) {
|
|
|
5661
5687
|
* icon={{ iconId: 'control-tower' }}
|
|
5662
5688
|
* />
|
|
5663
5689
|
*/
|
|
5664
|
-
const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveSelection, icon, placeholder = "Search…", minChars = 2, debounceMs = 300, disabled = false, required = false, initialDisplayText, searchTrigger, labelProps, alignProps, width, className = "", }) => {
|
|
5690
|
+
const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveSelection, icon, placeholder = "Search…", minChars = 2, debounceMs = 300, disabled = false, required = false, initialDisplayText, searchTrigger, labelProps, alignProps, width, className = "", feedback, ...dataAttributes }) => {
|
|
5665
5691
|
// State
|
|
5666
5692
|
const [inputValue, setInputValue] = useState("");
|
|
5667
5693
|
const [options, setOptions] = useState([]);
|
|
@@ -5682,6 +5708,12 @@ const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveS
|
|
|
5682
5708
|
// Stable ids wiring the combobox input to its listbox popup for assistive tech.
|
|
5683
5709
|
const listboxId = useId();
|
|
5684
5710
|
const optionId = (index) => `${listboxId}-opt-${index}`;
|
|
5711
|
+
const feedbackMessages = feedback
|
|
5712
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
5713
|
+
: [];
|
|
5714
|
+
const feedbackId = useId();
|
|
5715
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
5716
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
5685
5717
|
// Cancel a pending initial-value resolve when the user takes over (typing / clearing / reset),
|
|
5686
5718
|
// so a slow resolve can't overwrite newer input and the loading flag never sticks.
|
|
5687
5719
|
const cancelInitialResolve = useCallback(() => {
|
|
@@ -5893,10 +5925,10 @@ const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveS
|
|
|
5893
5925
|
abortRef.current?.abort();
|
|
5894
5926
|
}, []);
|
|
5895
5927
|
const direction = alignProps?.flexDirection || "row";
|
|
5896
|
-
return (jsxs("div", { className: `cw-search-input ${className}`, style: {
|
|
5928
|
+
return (jsxs("div", { ...dataAttributes, className: `cw-search-input ${className}`, style: {
|
|
5897
5929
|
...(width ? { width } : {}),
|
|
5898
5930
|
...(labelProps?.labelWidth ? { "--label-width": labelProps.labelWidth } : {}),
|
|
5899
|
-
}, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: handleInputFocus, placeholder: isInitialLoading ? "Loading…" : placeholder, disabled: disabled, required: required, autoComplete: "off", role: "combobox", "aria-haspopup": "listbox", "aria-expanded": showDropdown, "aria-controls": listboxId, "aria-activedescendant": highlightedIndex >= 0 ? optionId(highlightedIndex) : undefined, title: tooltipText }), (isLoading || isInitialLoading) && (jsx("div", { className: "cw-search-input-loading", children: jsx(CwIcon, { iconId: "spinner" }) })), jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selection", variant: "icon", icon: "close", color: "neutral" })) : (icon ? jsx(CwIcon, { ...icon }) : jsx(CwIcon, { iconId: "search" })) })] })] }), renderPanel(jsx("div", { ref: panelRef, id: listboxId, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsx("ul", { children: options.map((option, index) => (jsx("li", { id: optionId(index), className: `${dropdownStyles.option}${index === highlightedIndex ? ` ${dropdownStyles.optionFocused}` : ""}`, onClick: () => handleOptionSelect(option.id), onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: option.subLabel ? (jsxs("span", { className: "cw-search-async-option-lines", children: [jsx("span", { children: option.label }), jsx("span", { className: "cw-search-async-option-sub", children: option.subLabel })] })) : (option.label) }, option.id))) }) }))] }));
|
|
5931
|
+
}, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$8.value, children: [jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: handleInputFocus, placeholder: isInitialLoading ? "Loading…" : placeholder, disabled: disabled, required: required, autoComplete: "off", role: "combobox", "aria-haspopup": "listbox", "aria-expanded": showDropdown, "aria-controls": listboxId, "aria-activedescendant": highlightedIndex >= 0 ? optionId(highlightedIndex) : undefined, "aria-describedby": describedBy, title: tooltipText }), (isLoading || isInitialLoading) && (jsx("div", { className: "cw-search-input-loading", children: jsx(CwIcon, { iconId: "spinner" }) })), jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selection", variant: "icon", icon: "close", color: "neutral" })) : (icon ? jsx(CwIcon, { ...icon }) : jsx(CwIcon, { iconId: "search" })) })] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }), renderPanel(jsx("div", { ref: panelRef, id: listboxId, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsx("ul", { children: options.map((option, index) => (jsx("li", { id: optionId(index), className: `${dropdownStyles.option}${index === highlightedIndex ? ` ${dropdownStyles.optionFocused}` : ""}`, onClick: () => handleOptionSelect(option.id), onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: option.subLabel ? (jsxs("span", { className: "cw-search-async-option-lines", children: [jsx("span", { children: option.label }), jsx("span", { className: "cw-search-async-option-sub", children: option.subLabel })] })) : (option.label) }, option.id))) }) }))] }));
|
|
5900
5932
|
};
|
|
5901
5933
|
|
|
5902
5934
|
var styles$7 = {"menu":"cw-context-menu-module__menu__tXmun","item":"cw-context-menu-module__item__-ko8L","arrow":"cw-context-menu-module__arrow__LHZmQ"};
|
|
@@ -6248,9 +6280,9 @@ var styles$5 = {"switch":"cw-button-switch-module__switch__vdWV-","segment":"cw-
|
|
|
6248
6280
|
* onChange={setView}
|
|
6249
6281
|
* />
|
|
6250
6282
|
*/
|
|
6251
|
-
function CwButtonSwitch({ options, value, onChange, size = "medium", color = "primary", iconOnly = false, direction = "row", disabled = false, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby,
|
|
6283
|
+
function CwButtonSwitch({ options, value, onChange, size = "medium", color = "primary", iconOnly = false, direction = "row", disabled = false, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...dataAttributes }) {
|
|
6252
6284
|
const { getSegmentProps } = useRovingSingleSelect(options, value, onChange);
|
|
6253
|
-
return (jsx("div", { className: `cw-button-switch ${styles$5.switch}`, role: "radiogroup", "aria-labelledby": ariaLabelledby, "aria-label": ariaLabelledby ? undefined : ariaLabel, "data-direction": direction,
|
|
6285
|
+
return (jsx("div", { ...dataAttributes, className: `cw-button-switch ${styles$5.switch}`, role: "radiogroup", "aria-labelledby": ariaLabelledby, "aria-label": ariaLabelledby ? undefined : ariaLabel, "data-direction": direction, children: options.map((option, index) => {
|
|
6254
6286
|
const selected = option.value === value;
|
|
6255
6287
|
const segmentProps = getSegmentProps(index);
|
|
6256
6288
|
return (jsx(CwButton, { text: iconOnly ? undefined : option.label, title: iconOnly ? option.label : undefined, icon: option.icon, size: size, color: color, variant: selected ? "solid" : "outline", role: "radio", "aria-checked": selected, disabled: disabled || option.disabled, onClick: () => onChange(option.value), className: `${styles$5.segment}${iconOnly ? ` ${styles$5.iconOnly}` : ""}`, tabIndex: segmentProps.tabIndex, ref: segmentProps.ref, onKeyDown: segmentProps.onKeyDown }, option.value));
|
|
@@ -6345,7 +6377,7 @@ function usePickerPopup({ anchorRef, isOpen, onClose, position = "left-bottom" }
|
|
|
6345
6377
|
return { popupRef: panelRef, popupStyle: panelStyle, renderPopup: renderPanel };
|
|
6346
6378
|
}
|
|
6347
6379
|
|
|
6348
|
-
function CwDatePicker({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, defaultMonth, labelProps, alignProps, placeholder = "Select a date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, locale = enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, }) {
|
|
6380
|
+
function CwDatePicker({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, defaultMonth, labelProps, alignProps, placeholder = "Select a date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, locale = enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, ...dataAttributes }) {
|
|
6349
6381
|
const [isOpen, setIsOpen] = useState(false);
|
|
6350
6382
|
const [inputValue, setInputValue] = useState("");
|
|
6351
6383
|
const containerRef = useRef(null);
|
|
@@ -6535,7 +6567,7 @@ function CwDatePicker({ value, onChange, minDate, maxDate, disabledDates, disabl
|
|
|
6535
6567
|
...(maxDate ? [{ after: maxDate }] : []),
|
|
6536
6568
|
...(disabledMatcher ? [disabledMatcher] : []),
|
|
6537
6569
|
], [disabledDates, minDate, maxDate, disabledMatcher]);
|
|
6538
|
-
return (jsx("div", { ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsx(DayPicker, { mode: "single", selected: value || undefined, defaultMonth: defaultMonth || value || undefined, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
6570
|
+
return (jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsx(DayPicker, { mode: "single", selected: value || undefined, defaultMonth: defaultMonth || value || undefined, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
6539
6571
|
today: new Date(),
|
|
6540
6572
|
}, modifiersClassNames: {
|
|
6541
6573
|
today: "rdp-day-today",
|
|
@@ -6813,8 +6845,14 @@ const getPresetsByKeys = (keys) => {
|
|
|
6813
6845
|
.filter(preset => preset !== undefined);
|
|
6814
6846
|
};
|
|
6815
6847
|
|
|
6816
|
-
function CwDateRangePicker({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, maxRangeDays, defaultMonth, labelProps, alignProps, placeholderFrom = "From date", placeholderTo = "To date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 2, showPresets = false, presetKeys, customPresets, }) {
|
|
6848
|
+
function CwDateRangePicker({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, maxRangeDays, defaultMonth, labelProps, alignProps, placeholderFrom = "From date", placeholderTo = "To date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 2, showPresets = false, presetKeys, customPresets, feedback, ...dataAttributes }) {
|
|
6817
6849
|
const [isOpen, setIsOpen] = useState(false);
|
|
6850
|
+
const feedbackMessages = feedback
|
|
6851
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
6852
|
+
: [];
|
|
6853
|
+
const feedbackId = useId();
|
|
6854
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
6855
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
6818
6856
|
const [inputFromValue, setInputFromValue] = useState("");
|
|
6819
6857
|
const [inputToValue, setInputToValue] = useState("");
|
|
6820
6858
|
const [rangeErrorMessage, setRangeErrorMessage] = useState(null);
|
|
@@ -7178,11 +7216,11 @@ function CwDateRangePicker({ value, onChange, minDate, maxDate, disabledDates, d
|
|
|
7178
7216
|
}
|
|
7179
7217
|
return undefined;
|
|
7180
7218
|
}, [value]);
|
|
7181
|
-
return (jsx("div", { ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputFromRef, type: "text", value: inputFromValue, placeholder: placeholderFrom, onChange: handleInputFromChange, onBlur: () => handleInputBlur('from'), onClick: handleInputFromClick, onKeyDown: (e) => handleInputKeyDown(e, 'from'), disabled: disabled, required: required, size: displayFormat.length, "data-focused": focusedInput === 'from' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputToRef, type: "text", value: inputToValue, placeholder: placeholderTo, onChange: handleInputToChange, onBlur: () => handleInputBlur('to'), onClick: handleInputToClick, onKeyDown: (e) => handleInputKeyDown(e, 'to'), disabled: disabled, required: required, size: displayFormat.length, "data-focused": focusedInput === 'to' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsx(DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonth || value?.from || undefined, modifiers: {
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7219
|
+
return (jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputFromRef, type: "text", value: inputFromValue, placeholder: placeholderFrom, onChange: handleInputFromChange, onBlur: () => handleInputBlur('from'), onClick: handleInputFromClick, onKeyDown: (e) => handleInputKeyDown(e, 'from'), disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length, "data-focused": focusedInput === 'from' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputToRef, type: "text", value: inputToValue, placeholder: placeholderTo, onChange: handleInputToChange, onBlur: () => handleInputBlur('to'), onClick: handleInputToClick, onKeyDown: (e) => handleInputKeyDown(e, 'to'), disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length, "data-focused": focusedInput === 'to' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsx(DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonth || value?.from || undefined, modifiers: {
|
|
7220
|
+
today: new Date(),
|
|
7221
|
+
}, modifiersClassNames: {
|
|
7222
|
+
today: "rdp-day-today",
|
|
7223
|
+
} })] }), jsx("div", { role: "alert", "aria-live": "polite", className: rangeStyles.rangeError, children: rangeErrorMessage })] }))] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) }));
|
|
7186
7224
|
}
|
|
7187
7225
|
|
|
7188
7226
|
var timeStyles = {"timePickerPopup":"cw-time-picker-module__timePickerPopup__BN63t","timePickerList":"cw-time-picker-module__timePickerList__E88pr","selected":"cw-time-picker-module__selected__qVnfL","field":"cw-time-picker-module__field__kPvGN","narrow":"cw-time-picker-module__narrow__Z7lCI"};
|
|
@@ -7190,9 +7228,16 @@ var timeStyles = {"timePickerPopup":"cw-time-picker-module__timePickerPopup__BN6
|
|
|
7190
7228
|
const isMobileDevice = () => {
|
|
7191
7229
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
7192
7230
|
};
|
|
7193
|
-
function CwTimePicker({ value, onChange, interval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", useNative = isMobileDevice(), }) {
|
|
7231
|
+
function CwTimePicker({ value, onChange, interval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", useNative = isMobileDevice(), feedback, ...dataAttributes }) {
|
|
7194
7232
|
const [isOpen, setIsOpen] = useState(false);
|
|
7195
7233
|
const [inputValue, setInputValue] = useState("");
|
|
7234
|
+
const feedbackMessages = feedback
|
|
7235
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
7236
|
+
: [];
|
|
7237
|
+
const feedbackId = useId();
|
|
7238
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
7239
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
7240
|
+
const feedbackElements = feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)));
|
|
7196
7241
|
const containerRef = useRef(null);
|
|
7197
7242
|
const wrapperRef = useRef(null);
|
|
7198
7243
|
const inputRef = useRef(null);
|
|
@@ -7344,13 +7389,13 @@ function CwTimePicker({ value, onChange, interval = 15, minTime, maxTime, labelP
|
|
|
7344
7389
|
const displayValue = inputValue;
|
|
7345
7390
|
// If using native time input
|
|
7346
7391
|
if (useNative) {
|
|
7347
|
-
return (jsx("div", { className: `cw-timepicker cw-timepicker-native ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsx("div", { className: styles$4.pickerWrapper, children: jsx("input", { type: "time", value: displayValue, onChange: handleNativeChange, min: minTime, max: maxTime, step: interval * 60, disabled: disabled, required: required, placeholder: placeholder, className: "cw-timepicker-native" }) })] }) }));
|
|
7392
|
+
return (jsx("div", { ...dataAttributes, className: `cw-timepicker cw-timepicker-native ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsx("div", { className: styles$4.pickerWrapper, children: jsx("input", { type: "time", value: displayValue, onChange: handleNativeChange, min: minTime, max: maxTime, step: interval * 60, disabled: disabled, required: required, placeholder: placeholder, "aria-describedby": describedBy, className: "cw-timepicker-native" }) }), feedbackElements] })] }) }));
|
|
7348
7393
|
}
|
|
7349
7394
|
// Custom time picker
|
|
7350
|
-
return (jsx("div", { ref: containerRef, className: `cw-timepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { ref: wrapperRef, className: `${styles$4.pickerWrapper} ${timeStyles.field}${showClear ? "" : ` ${timeStyles.narrow}`}`, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, required: required, maxLength: 5 }), showClear && (jsx("div", { className: styles$4.pickerIcons, children: value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", icon: "close", color: "neutral", onClick: handleClear, tabIndex: -1, "aria-label": "Clear time" })) : (jsx(CwIcon, { iconId: "clock" })) })), renderPopup(jsx("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${timeStyles.timePickerPopup}`, style: popupStyle, children: jsx("div", { className: timeStyles.timePickerList, children: timeOptions.map((time) => {
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7395
|
+
return (jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-timepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: `${styles$4.pickerWrapper} ${timeStyles.field}${showClear ? "" : ` ${timeStyles.narrow}`}`, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, "aria-describedby": describedBy, required: required, maxLength: 5 }), showClear && (jsx("div", { className: styles$4.pickerIcons, children: value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", icon: "close", color: "neutral", onClick: handleClear, tabIndex: -1, "aria-label": "Clear time" })) : (jsx(CwIcon, { iconId: "clock" })) })), renderPopup(jsx("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${timeStyles.timePickerPopup}`, style: popupStyle, children: jsx("div", { className: timeStyles.timePickerList, children: timeOptions.map((time) => {
|
|
7396
|
+
const isSelected = time === value;
|
|
7397
|
+
return (jsx("button", { ref: isSelected ? selectedItemRef : null, type: "button", className: isSelected ? timeStyles.selected : "", onClick: () => handleTimeSelect(time), children: time }, time));
|
|
7398
|
+
}) }) }))] }), feedbackElements] })] }) }));
|
|
7354
7399
|
}
|
|
7355
7400
|
|
|
7356
7401
|
/**
|
|
@@ -7410,7 +7455,12 @@ function combineDateTimeInOffset(date, hours, minutes, timezoneOffset) {
|
|
|
7410
7455
|
return new Date(zdt.epochMilliseconds);
|
|
7411
7456
|
}
|
|
7412
7457
|
|
|
7413
|
-
function CwDateTimePicker({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, datePlaceholder = "dd.MM.yyyy", timePlaceholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showNowButton = false, nowLabel = "Now", locale = enGB, timezoneOffset, }) {
|
|
7458
|
+
function CwDateTimePicker({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, datePlaceholder = "dd.MM.yyyy", timePlaceholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showNowButton = false, nowLabel = "Now", locale = enGB, timezoneOffset, feedback, ...dataAttributes }) {
|
|
7459
|
+
const feedbackMessages = feedback
|
|
7460
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
7461
|
+
: [];
|
|
7462
|
+
const feedbackId = useId();
|
|
7463
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
7414
7464
|
// ========================================
|
|
7415
7465
|
// PROPS NORMALIZATION
|
|
7416
7466
|
// ========================================
|
|
@@ -7650,13 +7700,19 @@ function CwDateTimePicker({ value, onChange, minDateTime, maxDateTime, disabledD
|
|
|
7650
7700
|
const displayMaxDate = useMemo(() => normalizedMaxDateTime && timezoneOffset !== undefined
|
|
7651
7701
|
? getDateInOffset(normalizedMaxDateTime, timezoneOffset)
|
|
7652
7702
|
: normalizedMaxDateTime, [normalizedMaxDateTime, timezoneOffset]);
|
|
7653
|
-
return jsx("div", { className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsx(CwDatePicker, { value: selectedDate, onChange: handleDateChange, minDate: displayMinDate, maxDate: displayMaxDate, disabledDates: disabledDates, disabledMatcher: disabledMatcher, placeholder: datePlaceholder, disabled: disabled, required: required, showClear: showClear, numberOfMonths: numberOfMonths, popupPosition: popupPosition, locale: locale }), jsx(CwTimePicker, { value: selectedTime, onChange: handleTimeChange, interval: timeInterval, minTime: timeRestrictions.minTime, maxTime: timeRestrictions.maxTime, placeholder: timePlaceholder, disabled: disabled, required: required, showClear: showClear, popupPosition: popupPosition }), showNowButton && (jsx(CwButton, { type: "button", variant: "outline", onClick: handleNowClick, disabled: disabled, text: nowLabel }))] })] }) });
|
|
7703
|
+
return jsx("div", { ...dataAttributes, className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsx(CwDatePicker, { value: selectedDate, onChange: handleDateChange, minDate: displayMinDate, maxDate: displayMaxDate, disabledDates: disabledDates, disabledMatcher: disabledMatcher, placeholder: datePlaceholder, disabled: disabled, required: required, showClear: showClear, numberOfMonths: numberOfMonths, popupPosition: popupPosition, locale: locale }), jsx(CwTimePicker, { value: selectedTime, onChange: handleTimeChange, interval: timeInterval, minTime: timeRestrictions.minTime, maxTime: timeRestrictions.maxTime, placeholder: timePlaceholder, disabled: disabled, required: required, showClear: showClear, popupPosition: popupPosition }), showNowButton && (jsx(CwButton, { type: "button", variant: "outline", onClick: handleNowClick, disabled: disabled, text: nowLabel }))] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) });
|
|
7654
7704
|
}
|
|
7655
7705
|
|
|
7656
7706
|
var compactStyles = {"compactPopup":"cw-datetime-compact-module__compactPopup__GiuNY","calendarWrapper":"cw-datetime-compact-module__calendarWrapper__P4Nlq","timeWrapper":"cw-datetime-compact-module__timeWrapper__uMe-A","compactTimeList":"cw-datetime-compact-module__compactTimeList__MzSQT"};
|
|
7657
7707
|
|
|
7658
|
-
function CwDateTimePickerCompact({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "dd.mm.yyyy HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, nowLabel = "Now", timeLabel = "Time", locale = enGB, yearRangeStart, yearRangeEnd, }) {
|
|
7708
|
+
function CwDateTimePickerCompact({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "dd.mm.yyyy HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, nowLabel = "Now", timeLabel = "Time", locale = enGB, yearRangeStart, yearRangeEnd, feedback, ...dataAttributes }) {
|
|
7659
7709
|
const [isOpen, setIsOpen] = useState(false);
|
|
7710
|
+
const feedbackMessages = feedback
|
|
7711
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
7712
|
+
: [];
|
|
7713
|
+
const feedbackId = useId();
|
|
7714
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
7715
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
7660
7716
|
const [inputValue, setInputValue] = useState("");
|
|
7661
7717
|
const [selectedDate, setSelectedDate] = useState(value);
|
|
7662
7718
|
const [selectedTime, setSelectedTime] = useState("");
|
|
@@ -7900,14 +7956,14 @@ function CwDateTimePickerCompact({ value, onChange, minDateTime, maxDateTime, di
|
|
|
7900
7956
|
...(maxDateTime ? [{ after: maxDateTime }] : []),
|
|
7901
7957
|
...(disabledMatcher ? [disabledMatcher] : []),
|
|
7902
7958
|
], [disabledDates, minDateTime, maxDateTime, disabledMatcher]);
|
|
7903
|
-
return (jsx("div", { ref: containerRef, className: `cw-datetimepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, required: required, maxLength: 16 }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear datetime" })) : (jsx(CwIcon, { iconId: "calendar-time" })) }), renderPopup(jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${compactStyles.compactPopup}`, style: popupStyle, children: [jsxs("div", { className: compactStyles.calendarWrapper, children: [jsx(DayPicker, { mode: "single", selected: selectedDate, onSelect: handleDaySelect, defaultMonth: selectedDate, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7959
|
+
return (jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-datetimepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, "aria-describedby": describedBy, required: required, maxLength: 16 }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear datetime" })) : (jsx(CwIcon, { iconId: "calendar-time" })) }), renderPopup(jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${compactStyles.compactPopup}`, style: popupStyle, children: [jsxs("div", { className: compactStyles.calendarWrapper, children: [jsx(DayPicker, { mode: "single", selected: selectedDate, onSelect: handleDaySelect, defaultMonth: selectedDate, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
7960
|
+
today: new Date(),
|
|
7961
|
+
}, modifiersClassNames: {
|
|
7962
|
+
today: "rdp-day-today",
|
|
7963
|
+
} }), showTodayButton && (jsx("footer", { className: "cw-flex-row cw-align-center-center", children: jsx(CwButton, { type: "button", variant: "outline", icon: "check-big", onClick: handleNowClick, text: nowLabel }) }))] }), jsxs("div", { className: compactStyles.timeWrapper, children: [jsxs("header", { children: [jsx(CwIcon, { iconId: "clock", size: "medium" }), jsx("span", { children: timeLabel })] }), jsx("div", { ref: timeListRef, className: `${timeStyles.timePickerList} ${compactStyles.compactTimeList}`, children: timeOptions.map((time) => {
|
|
7964
|
+
const isSelected = time === selectedTime;
|
|
7965
|
+
return (jsx("button", { type: "button", className: isSelected ? timeStyles.selected : "", onClick: () => handleTimeSelect(time), children: time }, time));
|
|
7966
|
+
}) })] })] }))] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) }));
|
|
7911
7967
|
}
|
|
7912
7968
|
|
|
7913
7969
|
/**
|
|
@@ -7932,14 +7988,11 @@ function resolveTwoDigitYear(twoDigitYear, currentYear) {
|
|
|
7932
7988
|
}
|
|
7933
7989
|
const parseDate = (dateString, formatStr) => {
|
|
7934
7990
|
try {
|
|
7935
|
-
if (dateString.length < 10) {
|
|
7936
|
-
return undefined;
|
|
7937
|
-
}
|
|
7938
7991
|
const cleanString = dateString.trim();
|
|
7939
7992
|
if (!cleanString)
|
|
7940
7993
|
return undefined;
|
|
7941
7994
|
const parts = cleanString.split(/[\/\-.]/);
|
|
7942
|
-
if (parts.length !== 3)
|
|
7995
|
+
if (parts.length !== 3 || parts.some(part => !/^\d{1,4}$/.test(part)))
|
|
7943
7996
|
return undefined;
|
|
7944
7997
|
let day;
|
|
7945
7998
|
let month;
|
|
@@ -7971,7 +8024,7 @@ const parseDate = (dateString, formatStr) => {
|
|
|
7971
8024
|
if (year < 100) {
|
|
7972
8025
|
year = resolveTwoDigitYear(year);
|
|
7973
8026
|
}
|
|
7974
|
-
return Temporal.PlainDate.from({ year, month, day });
|
|
8027
|
+
return Temporal.PlainDate.from({ year, month, day }, { overflow: "reject" });
|
|
7975
8028
|
}
|
|
7976
8029
|
catch {
|
|
7977
8030
|
return undefined;
|
|
@@ -7984,6 +8037,17 @@ const validate = (parsed, minDate, maxDate) => {
|
|
|
7984
8037
|
&& (!maxDate || Temporal.PlainDate.compare(parsed, maxDate) <= 0);
|
|
7985
8038
|
return parsed && isValid;
|
|
7986
8039
|
};
|
|
8040
|
+
/** Same keystroke rule as the Date-valued pickers: shorter text (5.5.2000) only commits on blur. */
|
|
8041
|
+
const TYPED_DATE_MIN_LENGTH = 10;
|
|
8042
|
+
/** What a keystroke in the date input emits: a valid in-range date, a clear on empty text, or nothing while typing. */
|
|
8043
|
+
function resolveTypedDate(text, displayFormat, minDate, maxDate) {
|
|
8044
|
+
if (text === "")
|
|
8045
|
+
return { emit: true, date: undefined };
|
|
8046
|
+
if (text.length < TYPED_DATE_MIN_LENGTH)
|
|
8047
|
+
return { emit: false };
|
|
8048
|
+
const parsed = parseDate(text, displayFormat);
|
|
8049
|
+
return parsed && validate(parsed, minDate, maxDate) ? { emit: true, date: parsed } : { emit: false };
|
|
8050
|
+
}
|
|
7987
8051
|
/** Temporal.PlainDate -> JS Date (for DayPicker interop) */
|
|
7988
8052
|
function plainDateToJsDate(pd) {
|
|
7989
8053
|
return new Date(pd.year, pd.month - 1, pd.day);
|
|
@@ -8005,7 +8069,7 @@ function formatPlainDate(pd, fmt) {
|
|
|
8005
8069
|
.replace("dd", String(pd.day).padStart(2, "0"));
|
|
8006
8070
|
}
|
|
8007
8071
|
|
|
8008
|
-
function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, defaultMonth, labelProps, alignProps, placeholder = "Select a date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, locale = enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, }) {
|
|
8072
|
+
function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, defaultMonth, labelProps, alignProps, placeholder = "Select a date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, locale = enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, ...dataAttributes }) {
|
|
8009
8073
|
const [isOpen, setIsOpen] = useState(false);
|
|
8010
8074
|
// Initialize with the formatted value so the input is controlled from the first render
|
|
8011
8075
|
const [inputValue, setInputValue] = useState(() => value ? formatPlainDate(value, displayFormat) : "");
|
|
@@ -8030,14 +8094,17 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8030
8094
|
onClose: handleClose,
|
|
8031
8095
|
position: popupPosition,
|
|
8032
8096
|
});
|
|
8033
|
-
// Sync input value with prop value
|
|
8097
|
+
// Sync input value with prop value; not while focused, so text is never rewritten under the cursor (blur reformats)
|
|
8034
8098
|
useEffect(() => {
|
|
8035
8099
|
const currentStr = value?.toString();
|
|
8036
8100
|
const prevStr = prevValueRef.current?.toString();
|
|
8037
8101
|
if (currentStr !== prevStr || prevDisplayFormatRef.current !== displayFormat) {
|
|
8038
8102
|
prevValueRef.current = value;
|
|
8039
8103
|
prevDisplayFormatRef.current = displayFormat;
|
|
8040
|
-
|
|
8104
|
+
const isTyping = inputRef.current !== null && inputRef.current === document.activeElement;
|
|
8105
|
+
if (!isTyping) {
|
|
8106
|
+
setInputValue(formatInputValue(value));
|
|
8107
|
+
}
|
|
8041
8108
|
}
|
|
8042
8109
|
}, [value, displayFormat, formatInputValue]);
|
|
8043
8110
|
const handleDaySelect = useCallback((date) => {
|
|
@@ -8061,11 +8128,12 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8061
8128
|
}
|
|
8062
8129
|
}, [disabled]);
|
|
8063
8130
|
const handleInputChange = useCallback((e) => {
|
|
8064
|
-
const newValue = e.
|
|
8131
|
+
const newValue = e.currentTarget.value;
|
|
8065
8132
|
setInputValue(newValue);
|
|
8066
|
-
const
|
|
8067
|
-
|
|
8068
|
-
|
|
8133
|
+
const change = resolveTypedDate(newValue, displayFormat, minDate, maxDate);
|
|
8134
|
+
if (change.emit) {
|
|
8135
|
+
onChange(change.date);
|
|
8136
|
+
}
|
|
8069
8137
|
}, [displayFormat, minDate, maxDate, onChange]);
|
|
8070
8138
|
const handleInputBlur = useCallback(() => {
|
|
8071
8139
|
const trimmedValue = inputValue?.trim();
|
|
@@ -8095,9 +8163,10 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8095
8163
|
const isTodayValid = validate(today, minDate, maxDate);
|
|
8096
8164
|
if (isTodayValid) {
|
|
8097
8165
|
onChange(today);
|
|
8166
|
+
setInputValue(formatInputValue(today));
|
|
8098
8167
|
setIsOpen(false);
|
|
8099
8168
|
}
|
|
8100
|
-
}, [minDate, maxDate, onChange]);
|
|
8169
|
+
}, [formatInputValue, minDate, maxDate, onChange]);
|
|
8101
8170
|
// Derive start/end months for the year dropdown range, guarding against inverted yearRange props
|
|
8102
8171
|
const dropdownStartMonth = useMemo(() => {
|
|
8103
8172
|
const inferredStart = minDate ? minDate.year : Temporal.Now.plainDateISO().year - 10;
|
|
@@ -8122,7 +8191,7 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8122
8191
|
const defaultMonthJsDate = defaultMonth
|
|
8123
8192
|
? new Date(defaultMonth.year, defaultMonth.month - 1, 1)
|
|
8124
8193
|
: selectedJsDate;
|
|
8125
|
-
return (jsx("div", { ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsx(DayPicker, { mode: "single", selected: selectedJsDate, defaultMonth: defaultMonthJsDate, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8194
|
+
return (jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsx(DayPicker, { mode: "single", selected: selectedJsDate, defaultMonth: defaultMonthJsDate, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8126
8195
|
today: new Date(),
|
|
8127
8196
|
}, modifiersClassNames: {
|
|
8128
8197
|
today: "rdp-day-today",
|
|
@@ -8409,7 +8478,12 @@ function useCwDateTimePickerTemporal({ value, onChange, minDateTime, maxDateTime
|
|
|
8409
8478
|
};
|
|
8410
8479
|
}
|
|
8411
8480
|
|
|
8412
|
-
function CwDateTimePickerTemporal({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, datePlaceholder = "dd.MM.yyyy", timePlaceholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showNowButton = false, nowLabel = "Now", locale = enGB, }) {
|
|
8481
|
+
function CwDateTimePickerTemporal({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, datePlaceholder = "dd.MM.yyyy", timePlaceholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showNowButton = false, nowLabel = "Now", locale = enGB, feedback, ...dataAttributes }) {
|
|
8482
|
+
const feedbackMessages = feedback
|
|
8483
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
8484
|
+
: [];
|
|
8485
|
+
const feedbackId = useId();
|
|
8486
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
8413
8487
|
const picker = useCwDateTimePickerTemporal({
|
|
8414
8488
|
value,
|
|
8415
8489
|
onChange,
|
|
@@ -8418,7 +8492,7 @@ function CwDateTimePickerTemporal({ value, onChange, minDateTime, maxDateTime, d
|
|
|
8418
8492
|
minTime,
|
|
8419
8493
|
maxTime,
|
|
8420
8494
|
});
|
|
8421
|
-
return jsx("div", { className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsx(CwDatePickerTemporal, { value: picker.date, onChange: picker.selectDate, minDate: picker.minDate, maxDate: picker.maxDate, disabledDates: disabledDates, disabledMatcher: disabledMatcher, placeholder: datePlaceholder, disabled: disabled, required: required, showClear: showClear, numberOfMonths: numberOfMonths, popupPosition: popupPosition, locale: locale }), jsx(CwTimePicker, { value: picker.time, onChange: picker.selectTime, interval: timeInterval, minTime: picker.effectiveMinTime, maxTime: picker.effectiveMaxTime, placeholder: timePlaceholder, disabled: disabled, required: required, showClear: showClear, popupPosition: popupPosition }), showNowButton && (jsx(CwButton, { type: "button", variant: "outline", onClick: picker.selectNow, disabled: disabled, text: nowLabel }))] })] }) });
|
|
8495
|
+
return jsx("div", { ...dataAttributes, className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsx(CwDatePickerTemporal, { value: picker.date, onChange: picker.selectDate, minDate: picker.minDate, maxDate: picker.maxDate, disabledDates: disabledDates, disabledMatcher: disabledMatcher, placeholder: datePlaceholder, disabled: disabled, required: required, showClear: showClear, numberOfMonths: numberOfMonths, popupPosition: popupPosition, locale: locale }), jsx(CwTimePicker, { value: picker.time, onChange: picker.selectTime, interval: timeInterval, minTime: picker.effectiveMinTime, maxTime: picker.effectiveMaxTime, placeholder: timePlaceholder, disabled: disabled, required: required, showClear: showClear, popupPosition: popupPosition }), showNowButton && (jsx(CwButton, { type: "button", variant: "outline", onClick: picker.selectNow, disabled: disabled, text: nowLabel }))] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) });
|
|
8422
8496
|
}
|
|
8423
8497
|
|
|
8424
8498
|
// dateRangePresetsTemporal.ts
|
|
@@ -8561,8 +8635,14 @@ const PRESET_LIBRARY_TEMPORAL = {
|
|
|
8561
8635
|
*/
|
|
8562
8636
|
const getPresetsByKeysTemporal = (keys) => keys.map((key) => PRESET_LIBRARY_TEMPORAL[key]).filter((preset) => preset !== undefined);
|
|
8563
8637
|
|
|
8564
|
-
function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, maxRangeDays, defaultMonth, labelProps, alignProps, placeholderFrom = "From date", placeholderTo = "To date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 2, locale = enGB, yearRangeStart, yearRangeEnd, showPresets = false, presetKeys, customPresets, }) {
|
|
8638
|
+
function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, maxRangeDays, defaultMonth, labelProps, alignProps, placeholderFrom = "From date", placeholderTo = "To date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 2, locale = enGB, yearRangeStart, yearRangeEnd, showPresets = false, presetKeys, customPresets, feedback, ...dataAttributes }) {
|
|
8565
8639
|
const [isOpen, setIsOpen] = useState(false);
|
|
8640
|
+
const feedbackMessages = feedback
|
|
8641
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
8642
|
+
: [];
|
|
8643
|
+
const feedbackId = useId();
|
|
8644
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
8645
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
8566
8646
|
const [inputFromValue, setInputFromValue] = useState("");
|
|
8567
8647
|
const [inputToValue, setInputToValue] = useState("");
|
|
8568
8648
|
const [rangeErrorMessage, setRangeErrorMessage] = useState(null);
|
|
@@ -8722,7 +8802,7 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
|
|
|
8722
8802
|
const handleInputFromChange = useCallback((e) => {
|
|
8723
8803
|
const newValue = e.currentTarget.value;
|
|
8724
8804
|
setInputFromValue(newValue);
|
|
8725
|
-
const parsed = parseDate(newValue, displayFormat);
|
|
8805
|
+
const parsed = newValue.length >= TYPED_DATE_MIN_LENGTH ? parseDate(newValue, displayFormat) : undefined;
|
|
8726
8806
|
if (parsed) {
|
|
8727
8807
|
if (validate(parsed, minDate, maxDate) && validateRange(parsed, value?.to)) {
|
|
8728
8808
|
onChange({ from: parsed, to: value?.to });
|
|
@@ -8735,7 +8815,7 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
|
|
|
8735
8815
|
const handleInputToChange = useCallback((e) => {
|
|
8736
8816
|
const newValue = e.currentTarget.value;
|
|
8737
8817
|
setInputToValue(newValue);
|
|
8738
|
-
const parsed = parseDate(newValue, displayFormat);
|
|
8818
|
+
const parsed = newValue.length >= TYPED_DATE_MIN_LENGTH ? parseDate(newValue, displayFormat) : undefined;
|
|
8739
8819
|
if (parsed) {
|
|
8740
8820
|
if (validate(parsed, minDate, maxDate) && validateRange(value?.from, parsed)) {
|
|
8741
8821
|
onChange({ from: value?.from, to: parsed });
|
|
@@ -8864,11 +8944,11 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
|
|
|
8864
8944
|
const defaultMonthJsDate = defaultMonth
|
|
8865
8945
|
? new Date(defaultMonth.year, defaultMonth.month - 1, 1)
|
|
8866
8946
|
: (value?.from ? plainDateToJsDate(value.from) : undefined);
|
|
8867
|
-
return (jsx("div", { ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputFromRef, type: "text", value: inputFromValue, placeholder: placeholderFrom, onChange: handleInputFromChange, onBlur: () => handleInputBlur('from'), onClick: handleInputFromClick, onKeyDown: (e) => handleInputKeyDown(e, 'from'), disabled: disabled, required: required, size: displayFormat.length, "data-focused": focusedInput === 'from' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputToRef, type: "text", value: inputToValue, placeholder: placeholderTo, onChange: handleInputToChange, onBlur: () => handleInputBlur('to'), onClick: handleInputToClick, onKeyDown: (e) => handleInputKeyDown(e, 'to'), disabled: disabled, required: required, size: displayFormat.length, "data-focused": focusedInput === 'to' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsx(DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonthJsDate, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8947
|
+
return (jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.value, children: [jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputFromRef, type: "text", value: inputFromValue, placeholder: placeholderFrom, onChange: handleInputFromChange, onBlur: () => handleInputBlur('from'), onClick: handleInputFromClick, onKeyDown: (e) => handleInputKeyDown(e, 'from'), disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length, "data-focused": focusedInput === 'from' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputToRef, type: "text", value: inputToValue, placeholder: placeholderTo, onChange: handleInputToChange, onBlur: () => handleInputBlur('to'), onClick: handleInputToClick, onKeyDown: (e) => handleInputKeyDown(e, 'to'), disabled: disabled, "aria-describedby": describedBy, required: required, size: displayFormat.length, "data-focused": focusedInput === 'to' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsx(DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonthJsDate, locale: locale, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8948
|
+
today: new Date(),
|
|
8949
|
+
}, modifiersClassNames: {
|
|
8950
|
+
today: "rdp-day-today",
|
|
8951
|
+
} })] }), jsx("div", { role: "alert", "aria-live": "polite", className: rangeStyles.rangeError, children: rangeErrorMessage })] }))] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) }));
|
|
8872
8952
|
}
|
|
8873
8953
|
|
|
8874
8954
|
function dateFromPercentage(startDate, visibleDays, percentage) {
|
|
@@ -9011,7 +9091,7 @@ class OnClickContextMenu {
|
|
|
9011
9091
|
}
|
|
9012
9092
|
}
|
|
9013
9093
|
|
|
9014
|
-
var styles$3 = {"scheduler-header":"scheduler-header-module__scheduler-header__Y7SNV","scheduler-header-divisions":"scheduler-header-module__scheduler-header-divisions__1JrNe","scheduler-timeline-now":"scheduler-header-module__scheduler-timeline-now__naREv","scheduler-timeline-label":"scheduler-header-module__scheduler-timeline-label__mLVAp","scheduler-header-title":"scheduler-header-module__scheduler-header-title__Jzy94","scheduler-dates":"scheduler-header-module__scheduler-dates__O7ePQ","current-day":"scheduler-header-module__current-day__FpHiv","scheduler-hours":"scheduler-header-module__scheduler-hours__ZDCVj"};
|
|
9094
|
+
var styles$3 = {"scheduler-header":"scheduler-header-module__scheduler-header__Y7SNV","scheduler-header-divisions":"scheduler-header-module__scheduler-header-divisions__1JrNe","scheduler-timeline-now":"scheduler-header-module__scheduler-timeline-now__naREv","scheduler-timeline-label":"scheduler-header-module__scheduler-timeline-label__mLVAp","scheduler-header-title":"scheduler-header-module__scheduler-header-title__Jzy94","title-cell":"scheduler-header-module__title-cell__mz7Ki","title":"scheduler-header-module__title__TuJVn","scheduler-dates":"scheduler-header-module__scheduler-dates__O7ePQ","current-day":"scheduler-header-module__current-day__FpHiv","scheduler-hours":"scheduler-header-module__scheduler-hours__ZDCVj"};
|
|
9015
9095
|
|
|
9016
9096
|
const getNow$1 = (isUtc) => {
|
|
9017
9097
|
let now = new Date();
|
|
@@ -9021,18 +9101,16 @@ const getNow$1 = (isUtc) => {
|
|
|
9021
9101
|
return now;
|
|
9022
9102
|
};
|
|
9023
9103
|
const TimeLine = ({ left, top = "0px", height, color, width = "2px", zIndexNumber = 0, isHeader, isUtc = false }) => {
|
|
9024
|
-
const [currentTime, setCurrentTime] = useState(getNow$1(isUtc));
|
|
9104
|
+
const [currentTime, setCurrentTime] = useState(() => getNow$1(isUtc));
|
|
9025
9105
|
useEffect(() => {
|
|
9106
|
+
if (!isHeader) {
|
|
9107
|
+
return;
|
|
9108
|
+
}
|
|
9026
9109
|
const interval = setInterval(() => {
|
|
9027
9110
|
setCurrentTime(getNow$1(isUtc));
|
|
9028
|
-
}, 60000);
|
|
9111
|
+
}, 60000);
|
|
9029
9112
|
return () => clearInterval(interval);
|
|
9030
|
-
}, [isUtc]);
|
|
9031
|
-
const timeString = currentTime.toLocaleTimeString([], {
|
|
9032
|
-
hour: '2-digit',
|
|
9033
|
-
minute: '2-digit',
|
|
9034
|
-
hour12: false
|
|
9035
|
-
});
|
|
9113
|
+
}, [isUtc, isHeader]);
|
|
9036
9114
|
return (jsx("div", { style: {
|
|
9037
9115
|
position: "absolute",
|
|
9038
9116
|
top: top,
|
|
@@ -9044,7 +9122,11 @@ const TimeLine = ({ left, top = "0px", height, color, width = "2px", zIndexNumbe
|
|
|
9044
9122
|
zIndex: zIndexNumber,
|
|
9045
9123
|
}, className: styles$3["scheduler-timeline-now"], children: isHeader && (jsx("span", { style: {
|
|
9046
9124
|
color: color,
|
|
9047
|
-
}, className: styles$3["scheduler-timeline-label"], children:
|
|
9125
|
+
}, className: styles$3["scheduler-timeline-label"], children: currentTime.toLocaleTimeString([], {
|
|
9126
|
+
hour: '2-digit',
|
|
9127
|
+
minute: '2-digit',
|
|
9128
|
+
hour12: false
|
|
9129
|
+
}) })) }));
|
|
9048
9130
|
};
|
|
9049
9131
|
|
|
9050
9132
|
function isToday(startDate, endDate) {
|
|
@@ -9071,7 +9153,7 @@ const SchedulerHeaderDivision = ({ topDivisions, bottomDivisions, classification
|
|
|
9071
9153
|
};
|
|
9072
9154
|
|
|
9073
9155
|
const HeaderTitle = ({ title, dividerText, width }) => {
|
|
9074
|
-
return (jsxs("div", { className: styles$3["scheduler-header-title"], style: { width: width }, children: [jsx("div", { children: jsx("
|
|
9156
|
+
return (jsxs("div", { className: styles$3["scheduler-header-title"], style: { width: width }, children: [jsx("div", { className: styles$3["title-cell"], children: jsx("span", { className: styles$3.title, children: title }) }), jsx("div", { children: jsx("span", { children: dividerText }) })] }));
|
|
9075
9157
|
};
|
|
9076
9158
|
|
|
9077
9159
|
const SchedulerHeader = ({ content, divisions, visibleDays, selectedDate, width, onEvent, timeLinePercentage, isUtc }) => {
|
|
@@ -9109,7 +9191,7 @@ function getStartEnd(day) {
|
|
|
9109
9191
|
};
|
|
9110
9192
|
}
|
|
9111
9193
|
|
|
9112
|
-
var styles$2 = {"hide-scrollbar":"new-scheduler-module__hide-scrollbar__33GG9","scheduler-event":"new-scheduler-module__scheduler-event__gphwn","scheduler-event-container":"new-scheduler-module__scheduler-event-container__-h1xm","time-marker":"new-scheduler-module__time-marker__2BejU","scheduler-event-text":"new-scheduler-module__scheduler-event-text__zjvd7"};
|
|
9194
|
+
var styles$2 = {"hide-scrollbar":"new-scheduler-module__hide-scrollbar__33GG9","scheduler-event":"new-scheduler-module__scheduler-event__gphwn","scheduler-event-container":"new-scheduler-module__scheduler-event-container__-h1xm","time-marker":"new-scheduler-module__time-marker__2BejU","color-bars":"new-scheduler-module__color-bars__MhMF7","scheduler-event-text":"new-scheduler-module__scheduler-event-text__zjvd7"};
|
|
9113
9195
|
|
|
9114
9196
|
const BackgroundEvent = ({ value, heightRem }) => {
|
|
9115
9197
|
const backColor = getHSLColor(value.color, value.alpha ?? 0.5);
|
|
@@ -9239,7 +9321,7 @@ const eventsCollide = (event1, event2) => {
|
|
|
9239
9321
|
return eventInsideOther || eventCollideStart || eventCollideEnd;
|
|
9240
9322
|
};
|
|
9241
9323
|
// Function to separate events into non-colliding rows
|
|
9242
|
-
const
|
|
9324
|
+
const computeInnerRows = (events) => {
|
|
9243
9325
|
const sortedEvents = [...events].sort((a, b) => {
|
|
9244
9326
|
const aOrder = a.order ?? Number.MAX_SAFE_INTEGER;
|
|
9245
9327
|
const bOrder = b.order ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -9264,15 +9346,44 @@ const separateEventsToInnerRows = (events) => {
|
|
|
9264
9346
|
}
|
|
9265
9347
|
return rows;
|
|
9266
9348
|
};
|
|
9349
|
+
// The scheduler asks for the same row's lanes several times per repaint (total height, virtual-list
|
|
9350
|
+
// item size, row render). Row event arrays keep their identity until their events change, so the
|
|
9351
|
+
// array itself is the cache key.
|
|
9352
|
+
const innerRowsCache = new WeakMap();
|
|
9353
|
+
const separateEventsToInnerRows = (events) => {
|
|
9354
|
+
const cached = innerRowsCache.get(events);
|
|
9355
|
+
if (cached) {
|
|
9356
|
+
return cached;
|
|
9357
|
+
}
|
|
9358
|
+
const rows = computeInnerRows(events);
|
|
9359
|
+
innerRowsCache.set(events, rows);
|
|
9360
|
+
return rows;
|
|
9361
|
+
};
|
|
9267
9362
|
|
|
9268
9363
|
const DivisionLine = ({ left, top = "0px", height, isDayBoundary }) => {
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9364
|
+
return (jsx("div", { style: {
|
|
9365
|
+
position: "absolute",
|
|
9366
|
+
top: top,
|
|
9367
|
+
height: height,
|
|
9368
|
+
left: left + "%",
|
|
9369
|
+
width: isDayBoundary ? "2px" : "1px",
|
|
9370
|
+
background: isDayBoundary ? "rgba(255,255,255,1)" : "rgba(255,255,255,0.8)",
|
|
9371
|
+
pointerEvents: "none",
|
|
9372
|
+
zIndex: 0,
|
|
9373
|
+
} }));
|
|
9272
9374
|
};
|
|
9273
9375
|
|
|
9274
9376
|
const WeekEndLine = ({ left, top = "0px", height, widthPercentage }) => {
|
|
9275
|
-
return (jsx(
|
|
9377
|
+
return (jsx("div", { style: {
|
|
9378
|
+
position: "absolute",
|
|
9379
|
+
top: top,
|
|
9380
|
+
height: height,
|
|
9381
|
+
left: left + "%",
|
|
9382
|
+
width: widthPercentage + "%",
|
|
9383
|
+
background: "rgba(0,0,0,0.05)",
|
|
9384
|
+
pointerEvents: "none",
|
|
9385
|
+
zIndex: 0,
|
|
9386
|
+
} }));
|
|
9276
9387
|
};
|
|
9277
9388
|
|
|
9278
9389
|
var styles$1 = {"scheduler-row-header":"scheduler-row-module__scheduler-row-header__S-iv4"};
|
|
@@ -9398,16 +9509,7 @@ const SchedulerEvent = ({ value, heightRem, onEvent, maxEventHeightRem }) => {
|
|
|
9398
9509
|
flex: 1,
|
|
9399
9510
|
alignItems: "center",
|
|
9400
9511
|
width: "100%",
|
|
9401
|
-
}, children: value.rectangleColors && value.rectangleColors.length > 0 ? (jsx("div", { style: {
|
|
9402
|
-
display: "flex",
|
|
9403
|
-
width: "100%",
|
|
9404
|
-
}, children: value.rectangleColors.map((item, i) => (jsx("div", { className: "cwellt_rectangle_indicator", style: {
|
|
9405
|
-
backgroundColor: item,
|
|
9406
|
-
flex: 1,
|
|
9407
|
-
height: "8px",
|
|
9408
|
-
margin: 0,
|
|
9409
|
-
padding: 0,
|
|
9410
|
-
} }, value.id + "_" + i))) })) : (value.name) })] }), value.isResizable && (jsx(EventSideDrag, { heightRem: effectiveHeight * 0.7, onStartEvent: () => {
|
|
9512
|
+
}, children: value.rectangleColors && value.rectangleColors.length > 0 ? (jsx("div", { className: styles$2["color-bars"], children: value.rectangleColors.map((item, i) => (jsx("div", { style: { backgroundColor: item } }, value.id + "_" + i))) })) : (value.name) })] }), value.isResizable && (jsx(EventSideDrag, { heightRem: effectiveHeight * 0.7, onStartEvent: () => {
|
|
9411
9513
|
onEvent(new OnRightDragStart(value.id));
|
|
9412
9514
|
} }))] }), value.primaryTimeMarkerColor && (jsx("div", { className: styles$2["time-marker"], style: {
|
|
9413
9515
|
backgroundColor: value.primaryTimeMarkerColor,
|
|
@@ -9805,6 +9907,8 @@ const groupByRowIdStable = (items, prev) => {
|
|
|
9805
9907
|
const Scheduler = (props) => {
|
|
9806
9908
|
const { header: headerContent, id, events: eventsState, backgroundEvents, indicatorRows: allIndicatorRows = [], contextMenuItems, EventComp, RowTitleComp, orderCategories = ["title"], useOrderCategory, onEvent, groupRowColors, rowHeaderWidth = 180, rowHeightRem = 1.75, maxEventHeightRem, } = props;
|
|
9807
9909
|
const BackgroundEventComp = props.BackgroundEventComp ?? BackgroundEvent;
|
|
9910
|
+
// Picked by prefix: a rest spread would also put every non-destructured prop on the DOM.
|
|
9911
|
+
const dataAttributes = Object.fromEntries(Object.entries(props).filter(([key]) => key.startsWith("data-")));
|
|
9808
9912
|
const [constraintElement, setConstraintElement] = useState(null);
|
|
9809
9913
|
const rows = useOrderCategory === false
|
|
9810
9914
|
? props.rows
|
|
@@ -9813,9 +9917,10 @@ const Scheduler = (props) => {
|
|
|
9813
9917
|
// const rowHeaderWidth = "180px";
|
|
9814
9918
|
const { selectedDate, visibleDays, isUtc, isHeaderVisible, visibleRows: stateVisibleRows } = props.state;
|
|
9815
9919
|
const events = useMemo(() => filterVisibleEvents(eventsState, selectedDate, visibleDays), [eventsState, selectedDate, visibleDays]);
|
|
9920
|
+
// The virtual list caches row sizes: anything getItemSize depends on must reset them.
|
|
9816
9921
|
useEffect(() => {
|
|
9817
9922
|
instanceRef.current?.resetAfterIndex(0);
|
|
9818
|
-
}, [orderCategories, props.rows.length, events, allIndicatorRows]);
|
|
9923
|
+
}, [orderCategories, props.rows.length, events, allIndicatorRows, rowHeightRem]);
|
|
9819
9924
|
// Bucket events / backgroundEvents / indicatorRows by rowId once per render
|
|
9820
9925
|
// instead of running events.filter() per row inside the row renderer.
|
|
9821
9926
|
// Reuse previous bucket arrays when their contents are unchanged so the
|
|
@@ -9930,7 +10035,7 @@ const Scheduler = (props) => {
|
|
|
9930
10035
|
return rowsNumber * effectiveRowHeight * pixelsInRem + indicatorPixels;
|
|
9931
10036
|
}, [rows, eventsByRow, indicatorRowsByRow, rowHeightRem]);
|
|
9932
10037
|
// Render
|
|
9933
|
-
return (jsx(TooltipConstraintContext.Provider, { value: constraintElement, children: jsxs("div", { ref: setConstraintElement, id: id, style: {
|
|
10038
|
+
return (jsx(TooltipConstraintContext.Provider, { value: constraintElement, children: jsxs("div", { ...dataAttributes, ref: setConstraintElement, id: id, style: {
|
|
9934
10039
|
position: "relative",
|
|
9935
10040
|
height: `${schedulerContentHeight + 4}rem`,
|
|
9936
10041
|
overflowY: "auto",
|