@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.cjs.js
CHANGED
|
@@ -112,13 +112,27 @@ function colorToHSL(color) {
|
|
|
112
112
|
l: Math.round(l * 100)
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
const HEX_CACHE_LIMIT = 500;
|
|
116
|
+
const hexCache = new Map();
|
|
117
|
+
let canvasContext = null;
|
|
115
118
|
function colorToHEX(color) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const cached = hexCache.get(color);
|
|
120
|
+
if (cached !== undefined)
|
|
121
|
+
return cached;
|
|
122
|
+
if (!canvasContext) {
|
|
123
|
+
canvasContext = document.createElement('canvas').getContext('2d');
|
|
124
|
+
if (!canvasContext)
|
|
125
|
+
throw new Error('Could not create canvas context');
|
|
126
|
+
}
|
|
127
|
+
// A reused context keeps its previous fillStyle when the new color is invalid; reset it to the
|
|
128
|
+
// fresh-canvas default so an invalid color still gives black instead of the last valid color.
|
|
129
|
+
canvasContext.fillStyle = '#000000';
|
|
130
|
+
canvasContext.fillStyle = color;
|
|
131
|
+
const hex = canvasContext.fillStyle;
|
|
132
|
+
if (hexCache.size >= HEX_CACHE_LIMIT)
|
|
133
|
+
hexCache.clear();
|
|
134
|
+
hexCache.set(color, hex);
|
|
135
|
+
return hex;
|
|
122
136
|
}
|
|
123
137
|
function getHSLColor(color, alpha = 1) {
|
|
124
138
|
const hsl = colorToHSL(color);
|
|
@@ -180,7 +194,7 @@ function getContrastColor(color) {
|
|
|
180
194
|
return `hsl(${hsl.h}, ${contrastS}%, ${targetL}%)`;
|
|
181
195
|
}
|
|
182
196
|
|
|
183
|
-
var styles$
|
|
197
|
+
var styles$A = {"cw-tooltip-content":"cw-tooltip-module__cw-tooltip-content__RZczd","cw-tooltip":"cw-tooltip-module__cw-tooltip__1KYig"};
|
|
184
198
|
|
|
185
199
|
// Constants
|
|
186
200
|
const margin$1 = 16;
|
|
@@ -470,7 +484,7 @@ const CwTooltipManager = () => {
|
|
|
470
484
|
if (!state.isVisible || !state.content) {
|
|
471
485
|
return null;
|
|
472
486
|
}
|
|
473
|
-
return reactDom.createPortal(jsxRuntime.jsx("div", { ref: tooltipRef, className: styles$
|
|
487
|
+
return reactDom.createPortal(jsxRuntime.jsx("div", { ref: tooltipRef, className: styles$A["cw-tooltip-content"], "data-position": actualPosition, "data-visible": state.isVisible, "data-inline": state.displayInline, style: {
|
|
474
488
|
top: `${tooltipPosition.top}px`,
|
|
475
489
|
left: `${tooltipPosition.left}px`,
|
|
476
490
|
opacity: (isPositioned && !isMeasuring) ? 1 : 0,
|
|
@@ -551,7 +565,7 @@ const CwTooltipNew = ({ children, content = null, position = "right", dissapears
|
|
|
551
565
|
React.useEffect(() => {
|
|
552
566
|
ensureTooltipManager();
|
|
553
567
|
}, []);
|
|
554
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, className: styles$
|
|
568
|
+
return (jsxRuntime.jsx("div", { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, className: styles$A["cw-tooltip"], children: children }));
|
|
555
569
|
};
|
|
556
570
|
|
|
557
571
|
const SVG_ICONS = {
|
|
@@ -671,7 +685,7 @@ function resolveBadgeAria(label, loading, hasText) {
|
|
|
671
685
|
return hasText ? {} : { 'aria-hidden': 'true' };
|
|
672
686
|
}
|
|
673
687
|
|
|
674
|
-
var styles$
|
|
688
|
+
var styles$z = {"badge":"cw-badge-module__badge__PKlak"};
|
|
675
689
|
|
|
676
690
|
/**
|
|
677
691
|
* CwBadge - the small coloured circle with a number, used for alert and notification counts.
|
|
@@ -683,6 +697,13 @@ var styles$y = {"badge":"cw-badge-module__badge__PKlak"};
|
|
|
683
697
|
* Precedence: `loading` > `content` > `count` > dot. While loading the badge renders regardless
|
|
684
698
|
* of `showZero`, and the spinner replaces it - circle, background and padding come off.
|
|
685
699
|
*
|
|
700
|
+
* Overlaid on a `CwButton` (its `badge` prop), the corner offset is a public custom-property API,
|
|
701
|
+
* settable on the button, an ancestor, or the badge's own `style`:
|
|
702
|
+
* - `--badge-offset-x` - distance from the button's right edge (`right`). Default
|
|
703
|
+
* `calc(var(--cw-spacing-small) * -1)`.
|
|
704
|
+
* - `--badge-offset-y` - distance from the button's top edge (`top`). Default
|
|
705
|
+
* `calc(var(--cw-spacing-tiny) * -1)`, `-0.125rem` on a large icon button.
|
|
706
|
+
*
|
|
686
707
|
* @example
|
|
687
708
|
* <CwBadge count={3} color="danger" />
|
|
688
709
|
* <CwBadge count={0} showZero={false} />
|
|
@@ -690,7 +711,7 @@ var styles$y = {"badge":"cw-badge-module__badge__PKlak"};
|
|
|
690
711
|
* <CwBadge color="warning" label="Unresolved findings" />
|
|
691
712
|
* <CwBadge count={0} loading />
|
|
692
713
|
*/
|
|
693
|
-
const CwBadge = ({ count, content, color = 'info', variant = 'solid', size = 'small', showZero = true, loading = false, max = 99, label, className = '', style, }) => {
|
|
714
|
+
const CwBadge = ({ count, content, color = 'info', variant = 'solid', size = 'small', showZero = true, loading = false, max = 99, label, className = '', style, ...dataAttributes }) => {
|
|
694
715
|
// null counts as absent, so `content={null}` still renders a dot rather than an empty pill.
|
|
695
716
|
const hasContent = content !== undefined && content !== null;
|
|
696
717
|
if (!loading && !hasContent && count !== undefined && !showZero && normalizeBadgeCount(count) === 0) {
|
|
@@ -700,8 +721,8 @@ const CwBadge = ({ count, content, color = 'info', variant = 'solid', size = 'sm
|
|
|
700
721
|
? formatBadgeCount(count, max)
|
|
701
722
|
: undefined;
|
|
702
723
|
const isDot = !loading && !hasContent && count === undefined;
|
|
703
|
-
const badgeClassNames = ['cw-badge', styles$
|
|
704
|
-
return (jsxRuntime.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 ? jsxRuntime.jsx(CwIcon, { iconId: "spinner", size: "small" }) : hasContent ? content : countText }));
|
|
724
|
+
const badgeClassNames = ['cw-badge', styles$z.badge, className].filter(Boolean).join(' ');
|
|
725
|
+
return (jsxRuntime.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 ? jsxRuntime.jsx(CwIcon, { iconId: "spinner", size: "small" }) : hasContent ? content : countText }));
|
|
705
726
|
};
|
|
706
727
|
|
|
707
728
|
const CW_DEFAULT_MESSAGE_DURATION = 2000;
|
|
@@ -1088,7 +1109,7 @@ function CwLoading({ isLoading = false, text = '', size = 'regular', iconPositio
|
|
|
1088
1109
|
return (jsxRuntime.jsxs("div", { "aria-busy": isLoading, className: "cw-loading-container", "data-children": !!children, children: [overlay, jsxRuntime.jsx("div", { className: "cw-loading-disabled-content", children: children })] }));
|
|
1089
1110
|
}
|
|
1090
1111
|
|
|
1091
|
-
var styles$
|
|
1112
|
+
var styles$y = {"skeleton":"cw-skeleton-module__skeleton__Jvx2x","group":"cw-skeleton-module__group__Cm8AU"};
|
|
1092
1113
|
|
|
1093
1114
|
/*
|
|
1094
1115
|
* Internal helper for skeleton allocations (CwSkeleton, tables, cards).
|
|
@@ -1130,8 +1151,8 @@ function CwSkeleton({ variant = 'text', width, height, count = 1, radius, gap })
|
|
|
1130
1151
|
};
|
|
1131
1152
|
// The un-hashed cw-skeleton / cw-skeleton-group classes carry no styles in the
|
|
1132
1153
|
// library - they are stable public hooks for exceptional external overrides.
|
|
1133
|
-
const skeletonClassName = ['cw-skeleton', styles$
|
|
1134
|
-
const groupClassName = ['cw-skeleton-group', styles$
|
|
1154
|
+
const skeletonClassName = ['cw-skeleton', styles$y.skeleton].filter(Boolean).join(' ');
|
|
1155
|
+
const groupClassName = ['cw-skeleton-group', styles$y.group].filter(Boolean).join(' ');
|
|
1135
1156
|
const lineCount = normalizeSkeletonCount(count, 1);
|
|
1136
1157
|
if (lineCount <= 1) {
|
|
1137
1158
|
return (jsxRuntime.jsx("span", { className: skeletonClassName, "data-variant": variant, "aria-hidden": "true", style: style }));
|
|
@@ -1143,7 +1164,7 @@ function CwSkeleton({ variant = 'text', width, height, count = 1, radius, gap })
|
|
|
1143
1164
|
return (jsxRuntime.jsx("span", { className: groupClassName, "aria-hidden": "true", style: groupStyle, children: skeletonElements }));
|
|
1144
1165
|
}
|
|
1145
1166
|
|
|
1146
|
-
var styles$
|
|
1167
|
+
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"};
|
|
1147
1168
|
|
|
1148
1169
|
/**
|
|
1149
1170
|
* CwProgress - a determinate or indeterminate progress bar.
|
|
@@ -1155,7 +1176,7 @@ var styles$w = {"progress":"cw-progress-module__progress__d-g2-","value":"cw-pro
|
|
|
1155
1176
|
* <CwProgress value={62} label="Import" color="success" />
|
|
1156
1177
|
* <CwProgress indeterminate label="Uploading" />
|
|
1157
1178
|
*/
|
|
1158
|
-
function CwProgress({ value, indeterminate = false, label, rightLabel, size = 'regular', layout = 'row', color = 'primary', monoValue = false, prominent = false, className }) {
|
|
1179
|
+
function CwProgress({ value, indeterminate = false, label, rightLabel, footer, size = 'regular', layout = 'row', color = 'primary', monoValue = false, prominent = false, className, style, ...dataAttributes }) {
|
|
1159
1180
|
const labelId = React.useId();
|
|
1160
1181
|
// Determinate: a missing or non-finite value is treated as 0 (never NaN), then
|
|
1161
1182
|
// clamped to [0,100] for aria-valuenow and the fill width. Indeterminate has no value.
|
|
@@ -1163,21 +1184,21 @@ function CwProgress({ value, indeterminate = false, label, rightLabel, size = 'r
|
|
|
1163
1184
|
? undefined
|
|
1164
1185
|
: Math.min(Math.max(Number.isFinite(value) ? value : 0, 0), 100);
|
|
1165
1186
|
const percent = clamped !== undefined ? Math.round(clamped) : undefined;
|
|
1166
|
-
const showValue = rightLabel
|
|
1167
|
-
const
|
|
1187
|
+
const showValue = rightLabel != null || (!indeterminate && percent !== undefined);
|
|
1188
|
+
const valueContent = rightLabel ?? (percent !== undefined ? `${percent}%` : '');
|
|
1168
1189
|
// The un-hashed cw-progress class carries no styles in the library - a stable
|
|
1169
1190
|
// public hook for exceptional external overrides only.
|
|
1170
|
-
const rootClassName = ['cw-progress', styles$
|
|
1171
|
-
const labelSpan = label ? jsxRuntime.jsx("span", { className: styles$
|
|
1172
|
-
const valueLabel = showValue ? (jsxRuntime.jsx("span", { className: styles$
|
|
1173
|
-
return (jsxRuntime.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) && (jsxRuntime.jsxs("header", { className: styles$
|
|
1191
|
+
const rootClassName = ['cw-progress', styles$x.progress, className].filter(Boolean).join(' ');
|
|
1192
|
+
const labelSpan = label ? jsxRuntime.jsx("span", { className: styles$x.label, id: labelId, children: label }) : null;
|
|
1193
|
+
const valueLabel = showValue ? (jsxRuntime.jsx("span", { className: styles$x.value, "data-mono": monoValue || undefined, children: valueContent })) : null;
|
|
1194
|
+
return (jsxRuntime.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) && (jsxRuntime.jsxs("header", { className: styles$x.header, children: [labelSpan, valueLabel] })), layout === 'row' && labelSpan, jsxRuntime.jsx("div", { className: styles$x.track, role: "progressbar", ...(label && { 'aria-labelledby': labelId }), ...(!indeterminate && percent !== undefined && {
|
|
1174
1195
|
'aria-valuenow': percent,
|
|
1175
1196
|
'aria-valuemin': 0,
|
|
1176
1197
|
'aria-valuemax': 100
|
|
1177
|
-
}), children: jsxRuntime.jsx("div", { className: styles$
|
|
1198
|
+
}), children: jsxRuntime.jsx("div", { className: styles$x.fill, style: !indeterminate && clamped !== undefined ? { width: `${clamped}%` } : undefined }) }), layout === 'row' && valueLabel, footer != null && jsxRuntime.jsx("footer", { className: styles$x.footer, children: footer })] }));
|
|
1178
1199
|
}
|
|
1179
1200
|
|
|
1180
|
-
var styles$
|
|
1201
|
+
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"};
|
|
1181
1202
|
|
|
1182
1203
|
// Constants moved outside to prevent recreation
|
|
1183
1204
|
const margin = 16;
|
|
@@ -1304,12 +1325,12 @@ const CwGenericTooltip = ({ children, content = null, position = defaultPosition
|
|
|
1304
1325
|
const { setTooltipTimeout, clearTooltipTimeout } = useTooltipDelay(() => {
|
|
1305
1326
|
setIsVisible(true);
|
|
1306
1327
|
}, showDelay);
|
|
1307
|
-
const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$
|
|
1328
|
+
const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$w["cw-generic-tooltip-content"]);
|
|
1308
1329
|
// Memoize tooltip content creation
|
|
1309
1330
|
const tooltipContent = React.useMemo(() => {
|
|
1310
1331
|
if (hide || !isVisible || !content)
|
|
1311
1332
|
return null;
|
|
1312
|
-
return reactDom.createPortal(jsxRuntime.jsx("div", { className: styles$
|
|
1333
|
+
return reactDom.createPortal(jsxRuntime.jsx("div", { className: styles$w["cw-generic-tooltip-content"], "data-position": actualPosition, "data-visible": isVisible, "data-inline": displayInline, style: {
|
|
1313
1334
|
position: 'fixed',
|
|
1314
1335
|
top: `${tooltipPosition.top}px`,
|
|
1315
1336
|
left: `${tooltipPosition.left}px`,
|
|
@@ -1324,7 +1345,7 @@ const CwGenericTooltip = ({ children, content = null, position = defaultPosition
|
|
|
1324
1345
|
clearTooltipTimeout();
|
|
1325
1346
|
setIsVisible(false);
|
|
1326
1347
|
}, [clearTooltipTimeout]);
|
|
1327
|
-
return (jsxRuntime.jsxs("div", { ref: containerRef, className: styles$
|
|
1348
|
+
return (jsxRuntime.jsxs("div", { ref: containerRef, className: styles$w["cw-generic-tooltip"], onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, children: [tooltipContent, children] }));
|
|
1328
1349
|
};
|
|
1329
1350
|
|
|
1330
1351
|
const CwButton = React.forwardRef(function CwButton({ text, variant = 'solid', color = 'primary', size = 'medium', iconPosition = 'left', pressed, className = '', icon = "", title, tooltipPosition = "bottom", badge, children, ...buttonProps }, ref) {
|
|
@@ -1392,7 +1413,7 @@ function CwModal(custModalProps) {
|
|
|
1392
1413
|
return (jsxRuntime.jsx("div", { children: custModalProps.modalState && (jsxRuntime.jsxs("div", { className: custModalProps.classNameModalOverlay + " cwelltModalOverlay", children: [jsxRuntime.jsx("div", { className: "cwelltModalOverlayBg", onClick: custModalProps.onCloseModal }), jsxRuntime.jsx(Draggable, { disabled: isModalDisabled, axis: "both", nodeRef: draggableRef, children: jsxRuntime.jsxs("div", { className: custModalProps.classNameModal + " cwelltContainerModal", ref: draggableRef, style: widthModalDef !== "40em" ? modalStyle.widthCustomStyle : modalStyle.widthDefStyle, children: [jsxRuntime.jsxs("div", { className: "cwelltModalHeader", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: [jsxRuntime.jsx("div", { className: "cwelltModalTitle", children: custModalProps.titleModal }), jsxRuntime.jsx("button", { className: "cwelltBtnCloseModal", onClick: custModalProps.onCloseModal, children: jsxRuntime.jsx("span", { className: "cwelltCloseIcon" }) })] }), jsxRuntime.jsx("div", { className: "cwelltModalBody", children: jsxRuntime.jsx("div", { className: "cwelltContainerModalBody", style: { position: "relative" }, children: custModalProps.children }) }), isHide === false ? (jsxRuntime.jsx("footer", { className: "legacy-modal-footer", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: jsxRuntime.jsx(CwButton, { variant: "icon", icon: "save", title: "Save", onClick: custModalProps.onSaveModal, form: custModalProps.formSaveModal, hidden: custModalProps.HideBtnModal, type: custModalProps.HtmlSubmitModal }) })) : (jsxRuntime.jsx("div", { style: { display: "none" } }))] }) })] })) }));
|
|
1393
1414
|
}
|
|
1394
1415
|
|
|
1395
|
-
var styles$
|
|
1416
|
+
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"};
|
|
1396
1417
|
|
|
1397
1418
|
/**
|
|
1398
1419
|
* Small anchored confirmation for a destructive action.
|
|
@@ -1461,15 +1482,15 @@ function CwConfirmationPopup(props) {
|
|
|
1461
1482
|
onCancel();
|
|
1462
1483
|
}
|
|
1463
1484
|
};
|
|
1464
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderChildren(), isOpen && (jsxRuntime.jsx("div", { className: styles$
|
|
1485
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderChildren(), isOpen && (jsxRuntime.jsx("div", { className: styles$v.overlayPositioned, onClick: handleOverlayClick, children: jsxRuntime.jsxs("div", { ref: popupRef, className: styles$v.popup, style: {
|
|
1465
1486
|
position: 'absolute',
|
|
1466
1487
|
top: `${position.top}px`,
|
|
1467
1488
|
left: `${position.left}px`,
|
|
1468
1489
|
transform: 'none'
|
|
1469
|
-
}, children: [jsxRuntime.jsx("p", { className: styles$
|
|
1490
|
+
}, children: [jsxRuntime.jsx("p", { className: styles$v.message, children: message }), jsxRuntime.jsxs("div", { className: styles$v.buttons, children: [jsxRuntime.jsx("button", { className: `${styles$v.button} ${styles$v.confirmButton}`, onClick: onConfirm, children: confirmText }), jsxRuntime.jsx("button", { className: `${styles$v.button} ${styles$v.cancelButton}`, onClick: onCancel, children: cancelText })] })] }) }))] }));
|
|
1470
1491
|
}
|
|
1471
1492
|
|
|
1472
|
-
var styles$
|
|
1493
|
+
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"};
|
|
1473
1494
|
|
|
1474
1495
|
// Helper function to parse size values
|
|
1475
1496
|
const parseSize = (size) => {
|
|
@@ -1742,7 +1763,7 @@ const CwDialog = props => {
|
|
|
1742
1763
|
}
|
|
1743
1764
|
}
|
|
1744
1765
|
}, [open]);
|
|
1745
|
-
const header = React.useMemo(() => (jsxRuntime.jsxs("header", { onMouseDown: handleMouseDown, children: [jsxRuntime.jsx("span", { children: headline }), customHeader || (jsxRuntime.jsx("button", { className: styles$
|
|
1766
|
+
const header = React.useMemo(() => (jsxRuntime.jsxs("header", { onMouseDown: handleMouseDown, children: [jsxRuntime.jsx("span", { children: headline }), customHeader || (jsxRuntime.jsx("button", { className: styles$u["cw-dialog-button-close"], onClick: onClose }))] })), [handleMouseDown, headline, customHeader, onClose]);
|
|
1746
1767
|
const content = React.useMemo(() => (jsxRuntime.jsx("section", { children: children })), [children]);
|
|
1747
1768
|
const footer = React.useMemo(() => (jsxRuntime.jsx("footer", { children: customFooter || (jsxRuntime.jsx(CwButton, { variant: "icon", icon: "save", title: "Save", onClick: onSave, tooltipPosition: "top", disabled: disableSave, "data-testid": "cw-dialog-save" })) })), [customFooter, onSave, disableSave]);
|
|
1748
1769
|
const resizeHandles = React.useMemo(() => size.autoHeight
|
|
@@ -1769,7 +1790,7 @@ const CwDialog = props => {
|
|
|
1769
1790
|
: `${convertFromPx(size.height, size.heightUnit)}${size.heightUnit}`;
|
|
1770
1791
|
return { displayWidth, displayHeight };
|
|
1771
1792
|
}, [size.width, size.height, size.widthUnit, size.heightUnit, size.autoHeight]);
|
|
1772
|
-
const dialogContent = (jsxRuntime.jsx("div", { "data-has-scrim": hasScrim, className: styles$
|
|
1793
|
+
const dialogContent = (jsxRuntime.jsx("div", { "data-has-scrim": hasScrim, className: styles$u["cw-dialog-main"], onMouseDown: handleScrimMouseDown, onMouseUp: handleScrimMouseUpOrLeave, onMouseLeave: handleScrimMouseUpOrLeave, "data-pressing": isPressingScrim, children: jsxRuntime.jsxs("dialog", { ...domProps, ref: dialogRef, style: {
|
|
1773
1794
|
left: `${position.x}px`,
|
|
1774
1795
|
top: `${position.y}px`,
|
|
1775
1796
|
width: displayDimensions.displayWidth,
|
|
@@ -1931,7 +1952,7 @@ function CwAlign(props) {
|
|
|
1931
1952
|
}, children: props.children }));
|
|
1932
1953
|
}
|
|
1933
1954
|
|
|
1934
|
-
var styles$
|
|
1955
|
+
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"};
|
|
1935
1956
|
|
|
1936
1957
|
/**
|
|
1937
1958
|
* CwCard - A simple card component for displaying content in a contained format
|
|
@@ -1957,10 +1978,10 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1957
1978
|
// Construct class names using CSS modules
|
|
1958
1979
|
const cardClassNames = [
|
|
1959
1980
|
'cw-card',
|
|
1960
|
-
styles$
|
|
1981
|
+
styles$t.card,
|
|
1961
1982
|
className,
|
|
1962
|
-
clickable ? styles$
|
|
1963
|
-
disabled ? styles$
|
|
1983
|
+
clickable ? styles$t.clickable : '',
|
|
1984
|
+
disabled ? styles$t.disabled : '',
|
|
1964
1985
|
].filter(Boolean).join(' ');
|
|
1965
1986
|
// Handle click event when card is clickable
|
|
1966
1987
|
const handleClick = () => {
|
|
@@ -1978,15 +1999,15 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1978
1999
|
const hasFooter = hasChips || footer || (hasActions && resolvedDirection === "row");
|
|
1979
2000
|
// Actions component to reuse. While loading, each provided action renders a circular
|
|
1980
2001
|
// ghost sized to the CwButton icon footprint (2rem) - no interactive buttons.
|
|
1981
|
-
const ActionsComponent = hasActions && !disabled ? (jsxRuntime.jsx("div", { className: styles$
|
|
2002
|
+
const ActionsComponent = hasActions && !disabled ? (jsxRuntime.jsx("div", { className: styles$t.actions, children: isLoading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [extraActions && jsxRuntime.jsx(CwSkeleton, { variant: "circle", height: "2rem" }), onEdit && jsxRuntime.jsx(CwSkeleton, { variant: "circle", height: "2rem" }), onDelete && jsxRuntime.jsx(CwSkeleton, { variant: "circle", height: "2rem" })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [extraActions ?? null, onEdit && jsxRuntime.jsx(CwButton, { variant: "icon", icon: "edit", onClick: onEdit }), onDelete && jsxRuntime.jsx(CwButton, { variant: "icon", icon: "delete", color: "danger", onClick: onDelete })] })) })) : null;
|
|
1982
2003
|
return (jsxRuntime.jsxs("div", { ...(id && { id }), className: cardClassNames, ...(style && { style }), ...(clickable && !isLoading && {
|
|
1983
2004
|
role: 'button',
|
|
1984
2005
|
tabIndex: 0,
|
|
1985
2006
|
onClick: handleClick,
|
|
1986
|
-
}), "data-variant": variant, "data-direction": resolvedDirection, "aria-busy": isLoading || undefined, children: [isLoading ? (jsxRuntime.jsxs("header", { children: [jsxRuntime.jsx("div", { className: styles$
|
|
2007
|
+
}), "data-variant": variant, "data-direction": resolvedDirection, "aria-busy": isLoading || undefined, children: [isLoading ? (jsxRuntime.jsxs("header", { children: [jsxRuntime.jsx("div", { className: styles$t.headerContent, "data-align": resolvedAlign, children: jsxRuntime.jsx(CwSkeleton, { width: "8rem", height: "1.5em" }) }), resolvedDirection === "column" && ActionsComponent] })) : (hasHeader && (jsxRuntime.jsxs("header", { children: [(title || subtitle) && (jsxRuntime.jsxs("div", { className: styles$t.headerContent, "data-align": resolvedAlign, children: [title && jsxRuntime.jsx("h5", { children: title }), subtitle && jsxRuntime.jsx("strong", { children: subtitle })] })), resolvedDirection === "column" && ActionsComponent] }))), jsxRuntime.jsx("div", { className: styles$t.content, children: isLoading ? jsxRuntime.jsx(CwSkeleton, { count: normalizeSkeletonCount(skeletonLines, 3) }) : children }), hasFooter && (isLoading ? (jsxRuntime.jsx("footer", { children: jsxRuntime.jsx("div", { className: styles$t.footerTags, children: jsxRuntime.jsx(CwSkeleton, { variant: "rect", width: "4rem", height: "1.5em", radius: "1rem" }) }) })) : (jsxRuntime.jsxs("footer", { children: [hasChips && (jsxRuntime.jsx("div", { className: styles$t.footerTags, children: chips.map((chip, index) => (jsxRuntime.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 && (jsxRuntime.jsx("div", { className: styles$t.footerContent, children: footer }))] }))), resolvedDirection === "row" && ActionsComponent] }));
|
|
1987
2008
|
};
|
|
1988
2009
|
|
|
1989
|
-
var styles$
|
|
2010
|
+
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"};
|
|
1990
2011
|
|
|
1991
2012
|
/**
|
|
1992
2013
|
* Option to display in the CwSelect
|
|
@@ -2081,10 +2102,10 @@ function CwCardList({ items, renderCard, pageSize = 10, layout = 'grid', default
|
|
|
2081
2102
|
icon: sortDirection === 'asc' ? 'arrow-up' : 'arrow-down',
|
|
2082
2103
|
onClick: () => setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc'),
|
|
2083
2104
|
title: `Sort ${sortDirection === 'asc' ? 'descending' : 'ascending'}`,
|
|
2084
|
-
}, value: sortKey, onChange: (e) => handleSortChange(e.target.value), children: sortOptions.map(option => (jsxRuntime.jsx(CwOption, { value: option.key, children: option.label }, option.key))) }) })), isLoading ? (jsxRuntime.jsx("div", { className: `${styles$
|
|
2105
|
+
}, value: sortKey, onChange: (e) => handleSortChange(e.target.value), children: sortOptions.map(option => (jsxRuntime.jsx(CwOption, { value: option.key, children: option.label }, option.key))) }) })), isLoading ? (jsxRuntime.jsx("div", { className: `${styles$s.cardContainer}`, "data-layout": layout, style: gridStyle, "aria-busy": true, children: Array.from({ length: normalizeSkeletonCount(skeletonCards, 6) }, (_, index) => (jsxRuntime.jsx(CwCard, { isLoading: true, children: null }, `skeleton_${index}`))) })) : sortedItems.length === 0 ? (jsxRuntime.jsx("div", { className: styles$s.emptyState, children: emptyState || jsxRuntime.jsx("p", { children: "No items to display" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: `${styles$s.cardContainer}`, "data-layout": layout, style: gridStyle, children: visibleItems.map((item, index) => (jsxRuntime.jsx(React.Fragment, { children: renderCard(item, index) }, keyExtractor ? keyExtractor(item, index) : index))) }), totalPages > 1 && (jsxRuntime.jsxs("div", { className: styles$s.pagination, children: [jsxRuntime.jsx(CwButton, { variant: "icon", icon: "chevron-left", disabled: currentPage === 1, onClick: () => setCurrentPage(p => Math.max(1, p - 1)) }), jsxRuntime.jsxs("span", { className: styles$s.pageInfo, children: [currentPage, " / ", totalPages] }), jsxRuntime.jsx(CwButton, { variant: "icon", icon: "chevron-right", disabled: currentPage === totalPages, onClick: () => setCurrentPage(p => Math.min(totalPages, p + 1)) })] }))] }))] }));
|
|
2085
2106
|
}
|
|
2086
2107
|
|
|
2087
|
-
var styles$
|
|
2108
|
+
var styles$r = {"cw-accordion":"cw-accordion-module__cw-accordion__ErvlW","cw-accordion-body":"cw-accordion-module__cw-accordion-body__xlI8b"};
|
|
2088
2109
|
|
|
2089
2110
|
/**
|
|
2090
2111
|
* Legacy collapsible section with its own header markup.
|
|
@@ -2099,7 +2120,7 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
2099
2120
|
setVisible_accordionBody(!isVisible_accordionBody);
|
|
2100
2121
|
};
|
|
2101
2122
|
// #endregion
|
|
2102
|
-
return (jsxRuntime.jsxs("div", { className: styles$
|
|
2123
|
+
return (jsxRuntime.jsxs("div", { className: styles$r["cw-accordion"], style: CwelltAccordionContainerProps.style, "data-open": isVisible_accordionBody, children: [jsxRuntime.jsxs("header", { onClick: () => showAccordionBody(), children: [jsxRuntime.jsx("div", { children: CwelltAccordionContainerProps.desc_text }), jsxRuntime.jsx("button", { className: "cw-button-icon" })] }), jsxRuntime.jsx("div", { className: styles$r["cw-accordion-body"], children: CwelltAccordionContainerProps.children })] }));
|
|
2103
2124
|
}
|
|
2104
2125
|
|
|
2105
2126
|
/*
|
|
@@ -2374,7 +2395,7 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
2374
2395
|
}, min: 1, max: totalPages }), jsxRuntime.jsx("span", { children: "/" }), jsxRuntime.jsx("span", { children: totalPages }), jsxRuntime.jsx(CwButton, { onClick: () => handlePageChange(currentPage + 1), disabled: currentPage === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right" }), jsxRuntime.jsx(CwButton, { onClick: () => handlePageChange(totalPages), disabled: currentPage === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right-double" })] })] }))] }));
|
|
2375
2396
|
}
|
|
2376
2397
|
|
|
2377
|
-
var styles$
|
|
2398
|
+
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"};
|
|
2378
2399
|
|
|
2379
2400
|
/**
|
|
2380
2401
|
* Hook that provides state management for CwSortableTable.
|
|
@@ -2437,7 +2458,7 @@ function useSortableTable(initialItems) {
|
|
|
2437
2458
|
}
|
|
2438
2459
|
|
|
2439
2460
|
// ─── Drop indicator row ───────────────────────────────────────────────────────
|
|
2440
|
-
const DropIndicatorRow = ({ colSpan }) => (jsxRuntime.jsx("tr", { className: styles$
|
|
2461
|
+
const DropIndicatorRow = ({ colSpan }) => (jsxRuntime.jsx("tr", { className: styles$q.dropIndicator, "aria-hidden": true, children: jsxRuntime.jsx("td", { colSpan: colSpan, children: jsxRuntime.jsx("div", {}) }) }));
|
|
2441
2462
|
// ─── Loading skeleton ─────────────────────────────────────────────────────────
|
|
2442
2463
|
// Plain td cells (no local class): the ghost cells get the same global cw-table
|
|
2443
2464
|
// padding as real body cells, so row heights match the loaded rows exactly.
|
|
@@ -2540,11 +2561,11 @@ function CwSortableTable({ columns, data, rowKey = "key", onReorder, loading = f
|
|
|
2540
2561
|
return items.map((item, index) => {
|
|
2541
2562
|
const key = item[rowKey];
|
|
2542
2563
|
const isDragging = draggedItem?.[rowKey] === key;
|
|
2543
|
-
return (jsxRuntime.jsxs(React.Fragment, { children: [dropIndicatorIndex === index && (jsxRuntime.jsx(DropIndicatorRow, { colSpan: totalCols })), jsxRuntime.jsxs("tr", { draggable: true, onDragStart: (e) => handleDragStart(e, item), onDragOver: (e) => handleDragOver(e, index), onDragEnd: handleDragEnd, className: isDragging ? styles$
|
|
2564
|
+
return (jsxRuntime.jsxs(React.Fragment, { children: [dropIndicatorIndex === index && (jsxRuntime.jsx(DropIndicatorRow, { colSpan: totalCols })), jsxRuntime.jsxs("tr", { draggable: true, onDragStart: (e) => handleDragStart(e, item), onDragOver: (e) => handleDragOver(e, index), onDragEnd: handleDragEnd, className: isDragging ? styles$q.dragging : "", children: [showHandle && (jsxRuntime.jsx("td", { className: "cw-table-col-action", children: jsxRuntime.jsx(CwIcon, { iconId: "grip-dots", color: "neutral", style: { opacity: 0.75 } }) })), columns.map(col => (jsxRuntime.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 && (jsxRuntime.jsx(DropIndicatorRow, { colSpan: totalCols }))] }, String(key)));
|
|
2544
2565
|
});
|
|
2545
2566
|
};
|
|
2546
2567
|
// ── Render ──────────────────────────────────────────────────────────────
|
|
2547
|
-
return (jsxRuntime.jsxs("div", { className: `cw-table-container ${className ?? ""}`, style: containerStyle, "aria-busy": loading || undefined, children: [jsxRuntime.jsxs("table", { className: `cw-table cw-sortable-table ${tableClassName ?? ""}`, style: { width: "100%" }, children: [jsxRuntime.jsx("thead", { children: jsxRuntime.jsxs("tr", { children: [showHandle && jsxRuntime.jsx("th", { className: "cw-table-col-action" }), columns.map(col => (jsxRuntime.jsx("th", { className: col.className ?? "", style: col.width ? { width: col.width, minWidth: 50 } : undefined, children: col.title }, col.key)))] }) }), jsxRuntime.jsx("tbody", { children: renderBody() })] }), !loading && hasChanges && (jsxRuntime.jsxs("footer", { className: styles$
|
|
2568
|
+
return (jsxRuntime.jsxs("div", { className: `cw-table-container ${className ?? ""}`, style: containerStyle, "aria-busy": loading || undefined, children: [jsxRuntime.jsxs("table", { className: `cw-table cw-sortable-table ${tableClassName ?? ""}`, style: { width: "100%" }, children: [jsxRuntime.jsx("thead", { children: jsxRuntime.jsxs("tr", { children: [showHandle && jsxRuntime.jsx("th", { className: "cw-table-col-action" }), columns.map(col => (jsxRuntime.jsx("th", { className: col.className ?? "", style: col.width ? { width: col.width, minWidth: 50 } : undefined, children: col.title }, col.key)))] }) }), jsxRuntime.jsx("tbody", { children: renderBody() })] }), !loading && hasChanges && (jsxRuntime.jsxs("footer", { className: styles$q.saveBar, children: [jsxRuntime.jsx(CwButton, { variant: "outline", color: "neutral", icon: "undo", text: discardLabel, onClick: handleDiscard }), jsxRuntime.jsx(CwButton, { variant: "solid", color: "primary", icon: "save", text: saveLabel, onClick: () => handleSave(onReorder) })] }))] }));
|
|
2548
2569
|
}
|
|
2549
2570
|
|
|
2550
2571
|
/**
|
|
@@ -2745,7 +2766,7 @@ function CwTableServerSide({ columns, data, totalItems, pagination = false, page
|
|
|
2745
2766
|
}, min: 1, max: totalPages }), jsxRuntime.jsx("span", { children: "/" }), jsxRuntime.jsx("span", { children: totalPages }), jsxRuntime.jsx(CwButton, { onClick: () => handlePageChange(state.page + 1), disabled: state.page === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right" }), jsxRuntime.jsx(CwButton, { onClick: () => handlePageChange(totalPages), disabled: state.page === totalPages || totalPages <= 1, variant: "icon", icon: "chevron-right-double" })] })] }))] }));
|
|
2746
2767
|
}
|
|
2747
2768
|
|
|
2748
|
-
var styles$
|
|
2769
|
+
var styles$p = {"cw-tabs":"cw-tabs-module__cw-tabs__1pmji","cw-tabs-content":"cw-tabs-module__cw-tabs-content__HTp8d"};
|
|
2749
2770
|
|
|
2750
2771
|
const BADGE_COLOR_SCHEMES = ['primary', 'danger', 'warning', 'success', 'info', 'neutral'];
|
|
2751
2772
|
function isBadgeColorScheme(value) {
|
|
@@ -2799,11 +2820,11 @@ function CwTabs(CwTabsProps) {
|
|
|
2799
2820
|
const tabsListStyle = position === 'left' && CwTabsProps.tabsListWidth
|
|
2800
2821
|
? { minWidth: CwTabsProps.tabsListWidth }
|
|
2801
2822
|
: undefined;
|
|
2802
|
-
return (jsxRuntime.jsxs("div", { id: CwTabsProps.id, "data-testid": CwTabsProps.testId, className: styles$
|
|
2823
|
+
return (jsxRuntime.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: [jsxRuntime.jsx("ul", { style: tabsListStyle, children: CwTabsProps.tabs.map(tab => {
|
|
2803
2824
|
const badgeScheme = tab.badgeColor && isBadgeColorScheme(tab.badgeColor) ? tab.badgeColor : undefined;
|
|
2804
2825
|
const rawBadgeColor = tab.badgeColor && !badgeScheme ? tab.badgeColor : undefined;
|
|
2805
2826
|
return (jsxRuntime.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: [jsxRuntime.jsx(TabIcon, { icon: tab.icon }), tab.title, (tab.badge !== undefined || tab.badgeColor) && (jsxRuntime.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));
|
|
2806
|
-
}) }), jsxRuntime.jsx("div", { className: styles$
|
|
2827
|
+
}) }), jsxRuntime.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 })] }));
|
|
2807
2828
|
}
|
|
2808
2829
|
|
|
2809
2830
|
/**
|
|
@@ -2831,7 +2852,7 @@ const CwExpandable = ({ briefing, onToggle, onOpen, onClose, children, ...detail
|
|
|
2831
2852
|
return (jsxRuntime.jsxs("details", { ref: myRef, ...detailsProps, className: "cw-expandable", children: [jsxRuntime.jsx("summary", { children: briefing }), children && jsxRuntime.jsx("section", { children: children })] }));
|
|
2832
2853
|
};
|
|
2833
2854
|
|
|
2834
|
-
var styles$
|
|
2855
|
+
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"};
|
|
2835
2856
|
|
|
2836
2857
|
/*
|
|
2837
2858
|
* Fixed rem widths for the ghosts: the master rows and detail panel size their
|
|
@@ -2875,12 +2896,12 @@ const CwMasterDetail = ({ id, className, style, items, selectedKey, onSelect, de
|
|
|
2875
2896
|
document.body.style.userSelect = '';
|
|
2876
2897
|
};
|
|
2877
2898
|
}, [isResizing, minMasterWidth, maxMasterWidth]);
|
|
2878
|
-
const rootClassName = [styles$
|
|
2899
|
+
const rootClassName = [styles$o['cw-master-detail'], className].filter(Boolean).join(' ');
|
|
2879
2900
|
return (jsxRuntime.jsxs("div", { id: id, ref: containerRef, className: rootClassName, style: style, "aria-busy": loading || undefined, children: [jsxRuntime.jsxs("aside", { style: { width: masterWidth, minWidth: masterWidth }, children: [showSearch && (jsxRuntime.jsx("search", { children: jsxRuntime.jsx("input", { type: "text", placeholder: searchPlaceholder, onChange: (e) => onSearch?.(e.target.value) }) })), masterHeader && (jsxRuntime.jsx("header", { children: masterHeader })), jsxRuntime.jsx("ul", { children: loading
|
|
2880
|
-
? Array.from({ length: skeletonRows }, (_unused, rowIndex) => (jsxRuntime.jsxs("li", { "aria-hidden": "true", children: [jsxRuntime.jsx(CwSkeleton, { variant: "circle", height: "2rem" }), jsxRuntime.jsxs("div", { className: styles$
|
|
2881
|
-
: items.map((item) => (jsxRuntime.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 && (jsxRuntime.jsx("footer", { children: masterFooter }))] }), resizable && (jsxRuntime.jsx("div", { className: styles$
|
|
2901
|
+
? Array.from({ length: skeletonRows }, (_unused, rowIndex) => (jsxRuntime.jsxs("li", { "aria-hidden": "true", children: [jsxRuntime.jsx(CwSkeleton, { variant: "circle", height: "2rem" }), jsxRuntime.jsxs("div", { className: styles$o.skeletonRow, children: [jsxRuntime.jsx(CwSkeleton, { variant: "text", width: MASTER_TITLE_WIDTHS[rowIndex % MASTER_TITLE_WIDTHS.length] }), jsxRuntime.jsx(CwSkeleton, { variant: "text", width: MASTER_SUBTITLE_WIDTH })] })] }, `skeleton_${rowIndex}`)))
|
|
2902
|
+
: items.map((item) => (jsxRuntime.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 && (jsxRuntime.jsx("footer", { children: masterFooter }))] }), resizable && (jsxRuntime.jsx("div", { className: styles$o.resizer, "data-resizing": isResizing, onMouseDown: handleMouseDown })), jsxRuntime.jsx("section", { className: styles$o.detail, children: loading ? (jsxRuntime.jsxs("div", { className: styles$o.detailSkeleton, "aria-hidden": "true", children: [jsxRuntime.jsx(CwSkeleton, { variant: "text", width: "14rem", height: "1.5em" }), jsxRuntime.jsx(CwSkeleton, { variant: "text", width: "22rem" }), jsxRuntime.jsx(CwSkeleton, { variant: "text", width: "18rem" }), jsxRuntime.jsx(CwSkeleton, { variant: "text", width: "20rem" })] })) : selectedKey && detailContent
|
|
2882
2903
|
? detailContent
|
|
2883
|
-
: (jsxRuntime.jsx("div", { className: styles$
|
|
2904
|
+
: (jsxRuntime.jsx("div", { className: styles$o['detail-empty'], children: emptyDetail ?? 'Select an item to view details' })) })] }));
|
|
2884
2905
|
};
|
|
2885
2906
|
|
|
2886
2907
|
/*
|
|
@@ -2920,7 +2941,7 @@ const CwKeyValueList = ({ items, className = "", emptyValue = "-", direction = "
|
|
|
2920
2941
|
return (jsxRuntime.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() }));
|
|
2921
2942
|
};
|
|
2922
2943
|
|
|
2923
|
-
var styles$
|
|
2944
|
+
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"};
|
|
2924
2945
|
|
|
2925
2946
|
function CwSortableList({ items, onReorder, renderItem, className = '', movedItems = new Set(), emptyMessage = "No elements to show", readOnly = false, maxHeight = "300px", }) {
|
|
2926
2947
|
const [draggedItem, setDraggedItem] = React.useState(null);
|
|
@@ -2983,15 +3004,15 @@ function CwSortableList({ items, onReorder, renderItem, className = '', movedIte
|
|
|
2983
3004
|
}
|
|
2984
3005
|
};
|
|
2985
3006
|
if (items.length === 0) {
|
|
2986
|
-
return (jsxRuntime.jsx("div", { className: `${styles$
|
|
3007
|
+
return (jsxRuntime.jsx("div", { className: `${styles$n.sortableList} ${styles$n.emptyState} ${className}`, children: jsxRuntime.jsx("div", { className: styles$n.emptyMessage, children: emptyMessage }) }));
|
|
2987
3008
|
}
|
|
2988
|
-
return (jsxRuntime.jsx("div", { className: `${styles$
|
|
3009
|
+
return (jsxRuntime.jsx("div", { className: `${styles$n.sortableList} ${className}`, style: { maxHeight }, children: items.map((item, index) => {
|
|
2989
3010
|
const { title, extraContent, actions, showHandle = true, expandedContent } = renderItem(item);
|
|
2990
3011
|
const isDragging = draggedItem?.id === item.id;
|
|
2991
3012
|
const isMoved = movedItems.has(item.id);
|
|
2992
3013
|
const canExpand = Boolean(expandedContent);
|
|
2993
3014
|
const isExpanded = expandedItems.has(item.id);
|
|
2994
|
-
return (jsxRuntime.jsxs(React.Fragment, { children: [dropIndicatorIndex === index && jsxRuntime.jsx("div", { className: styles$
|
|
3015
|
+
return (jsxRuntime.jsxs(React.Fragment, { children: [dropIndicatorIndex === index && jsxRuntime.jsx("div", { className: styles$n.dropIndicator }), jsxRuntime.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: [jsxRuntime.jsxs("header", { children: [canExpand ? (jsxRuntime.jsx(CwButton, { variant: "icon", onClick: () => toggleExpanded(item.id), type: "button", title: isExpanded ? "Collapse" : "Expand", icon: isExpanded ? "chevron-up" : "chevron-down" })) : showHandle ? (jsxRuntime.jsx("div", { className: styles$n.sortableHandle, children: jsxRuntime.jsx(CwIcon, { iconId: "grip-dots" }) })) : null, jsxRuntime.jsxs("div", { className: styles$n.sortableContent, children: [jsxRuntime.jsx("div", { className: styles$n.sortableTitle, children: title }), extraContent && jsxRuntime.jsx("div", { className: styles$n.sortableExtraContent, children: extraContent })] }), jsxRuntime.jsx("div", { className: styles$n.sortableActions, children: actions })] }), isExpanded && expandedContent && (jsxRuntime.jsx("div", { className: styles$n.expandedContent, children: expandedContent }))] }), !readOnly && dropIndicatorIndex === items.length && index === items.length - 1 && (jsxRuntime.jsx("div", { className: styles$n.dropIndicator }))] }, item.id));
|
|
2995
3016
|
}) }));
|
|
2996
3017
|
}
|
|
2997
3018
|
|
|
@@ -3118,7 +3139,7 @@ const CwTableGrouped = props => {
|
|
|
3118
3139
|
group.rows.map((child, j) => (jsxRuntime.jsx("tr", { "data-row": true, "data-row-last-of-group": j == group.rows.length - 1, children: child.cells.map((cell, k) => (jsxRuntime.jsx("td", { children: cell.content }, k))) }, j)))] }, i))) }), jsxRuntime.jsx("tfoot", {})] }) }));
|
|
3119
3140
|
};
|
|
3120
3141
|
|
|
3121
|
-
var styles$
|
|
3142
|
+
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"};
|
|
3122
3143
|
|
|
3123
3144
|
const DEFAULT_LABELS$1 = {
|
|
3124
3145
|
uploadDisabled: 'Upload disabled',
|
|
@@ -3304,12 +3325,12 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
3304
3325
|
}
|
|
3305
3326
|
}
|
|
3306
3327
|
};
|
|
3307
|
-
return (jsxRuntime.jsxs("div", { className: `${styles$
|
|
3328
|
+
return (jsxRuntime.jsxs("div", { className: `${styles$m.fileUploadContainer} ${fileUploadProps.className}`, children: [jsxRuntime.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 ? (jsxRuntime.jsxs("div", { className: `${styles$m.uploadArea} ${fileUploadProps.disabled ? styles$m.uploadAreaDisabled : ''}`, onDragOver: handleDragOver, onDrop: handleDrop, onClick: !fileUploadProps.disabled ? handleButtonClick : undefined, children: [jsxRuntime.jsx(CwIcon, { iconId: "upload" }), jsxRuntime.jsx("p", { className: `${styles$m.uploadTitle}`, children: fileUploadProps.disabled ? labels.uploadDisabled : labels.clickToUpload }), jsxRuntime.jsxs("p", { className: `${styles$m.uploadSubtitle}`, children: [fileUploadProps.accept ? labels.acceptedFiles(fileUploadProps.accept) : labels.allTypesAccepted, !fileUploadProps.multiple && ` ${labels.singleFileOnly}`] })] })) : selectedFiles.length === 0 && existingFile ? (jsxRuntime.jsxs("div", { className: styles$m.filesContainer, children: [jsxRuntime.jsxs("div", { className: styles$m.fileItem, children: [jsxRuntime.jsxs("div", { className: styles$m.fileIcon, children: [jsxRuntime.jsx(CwIcon, { iconId: "page" }), jsxRuntime.jsx("span", { className: styles$m.fileExtension, children: getFileExtension(existingFile) })] }), jsxRuntime.jsx("div", { className: styles$m.fileInfo, children: jsxRuntime.jsx("p", { className: styles$m.fileName, children: existingFile }) }), jsxRuntime.jsx(CwButton, { variant: "icon", icon: "close", color: "neutral", onClick: () => {
|
|
3308
3329
|
setExistingFile(undefined);
|
|
3309
3330
|
if (fileUploadProps.onSelect) {
|
|
3310
3331
|
fileUploadProps.onSelect(null);
|
|
3311
3332
|
}
|
|
3312
|
-
}, disabled: fileUploadProps.disabled, className: styles$
|
|
3333
|
+
}, disabled: fileUploadProps.disabled, className: styles$m.smallButton })] }), jsxRuntime.jsx(CwButton, { text: labels.changeFile, icon: "refresh", onClick: handleButtonClick, disabled: fileUploadProps.disabled })] })) : (jsxRuntime.jsxs("div", { className: styles$m.filesContainer, children: [jsxRuntime.jsxs("header", { className: "cw-flex-row cw-align-between-center cw-flex-wrap", children: [jsxRuntime.jsx("small", { className: styles$m.filesCount, children: fileUploadProps.statusText ?? labels.filesSelected(selectedFiles.length) }), jsxRuntime.jsxs("div", { className: "cw-flex-row", children: [fileUploadProps.onConfirm && selectedFiles.length > 0 && (jsxRuntime.jsx(CwButton, { onClick: () => {
|
|
3313
3334
|
let files = fileInputRef.current?.files ?? null;
|
|
3314
3335
|
if (!files) {
|
|
3315
3336
|
const dataTransfer = new DataTransfer();
|
|
@@ -3317,7 +3338,7 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
3317
3338
|
files = dataTransfer.files;
|
|
3318
3339
|
}
|
|
3319
3340
|
fileUploadProps.onConfirm?.(files);
|
|
3320
|
-
}, disabled: fileUploadProps.disabled || fileUploadProps.confirmDisabled, icon: "upload", text: fileUploadProps.confirmLabel ?? labels.upload })), !fileUploadProps.hideClearAll && (jsxRuntime.jsx(CwButton, { onClick: removeAllFiles, disabled: fileUploadProps.disabled, color: "danger", variant: "outline", icon: "delete", text: labels.clearAll }))] })] }), selectedFiles.map((file, index) => (jsxRuntime.jsxs("div", { className: styles$
|
|
3341
|
+
}, disabled: fileUploadProps.disabled || fileUploadProps.confirmDisabled, icon: "upload", text: fileUploadProps.confirmLabel ?? labels.upload })), !fileUploadProps.hideClearAll && (jsxRuntime.jsx(CwButton, { onClick: removeAllFiles, disabled: fileUploadProps.disabled, color: "danger", variant: "outline", icon: "delete", text: labels.clearAll }))] })] }), selectedFiles.map((file, index) => (jsxRuntime.jsxs("div", { className: styles$m.fileItem, children: [jsxRuntime.jsxs("div", { className: styles$m.fileIcon, children: [jsxRuntime.jsx(CwIcon, { iconId: "page" }), jsxRuntime.jsx("span", { className: styles$m.fileExtension, children: getFileExtension(file.name) })] }), jsxRuntime.jsxs("div", { className: styles$m.fileInfo, children: [jsxRuntime.jsx("p", { className: styles$m.fileName, children: file.name }), jsxRuntime.jsxs("p", { className: styles$m.fileSize, children: [(file.size / 1024).toFixed(1), " KB"] })] }), jsxRuntime.jsx(CwButton, { variant: "icon", icon: "close", color: "neutral", onClick: () => removeFile(index), className: styles$m.smallButton })] }, `${file.name}-${file.size}`))), fileUploadProps.multiple && (jsxRuntime.jsx(CwButton, { text: labels.addMoreFiles, icon: "plus", variant: "outline", onClick: handleButtonClick, disabled: fileUploadProps.disabled })), !fileUploadProps.multiple && (jsxRuntime.jsx(CwButton, { text: labels.changeFile, icon: "refresh", onClick: handleButtonClick, disabled: fileUploadProps.disabled }))] }))] }));
|
|
3321
3342
|
}
|
|
3322
3343
|
|
|
3323
3344
|
/**
|
|
@@ -3370,7 +3391,7 @@ function CwDigit(props) {
|
|
|
3370
3391
|
return (jsxRuntime.jsxs("div", { className: "cw-input-text", "data-direction": labelProps ? flexDirection : "column", "data-feedback-position": feedbackPosition, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsxs("div", { className: "cw-input-button", children: [jsxRuntime.jsx("input", { type: "number", ...inputProps, "aria-describedby": describedBy }), buttonProps && jsxRuntime.jsx(CwButton, { ...buttonProps })] })] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-info", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
3371
3392
|
}
|
|
3372
3393
|
|
|
3373
|
-
var styles$
|
|
3394
|
+
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"};
|
|
3374
3395
|
|
|
3375
3396
|
const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }) => {
|
|
3376
3397
|
const [rgb, setRgb] = React.useState({ r: 255, g: 255, b: 255 });
|
|
@@ -3573,13 +3594,13 @@ const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }
|
|
|
3573
3594
|
// Calculate background color for the main area based on current hue
|
|
3574
3595
|
const hueColor = hsvToRgb(hsv.h, 100, 100);
|
|
3575
3596
|
const hueHex = rgbToHex(hueColor.r, hueColor.g, hueColor.b);
|
|
3576
|
-
return (jsxRuntime.jsxs("div", { className: "cw-flex-column cw-gap-small", children: [jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-between-center cw-gap-small", children: [jsxRuntime.jsx("div", { className: styles$
|
|
3597
|
+
return (jsxRuntime.jsxs("div", { className: "cw-flex-column cw-gap-small", children: [jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-between-center cw-gap-small", children: [jsxRuntime.jsx("div", { className: styles$l.colorPreview, style: { backgroundColor: hexColor, color: getContrastColor(hexColor) }, children: previewText }), jsxRuntime.jsx("button", { type: "button", className: "cw-button", onClick: toggleInputMode, style: { minWidth: "3ch" }, children: inputMode === 'hex' ? 'RGB' : 'HEX' })] }), jsxRuntime.jsx("div", { className: "color-inputs-row", children: inputMode === 'hex' ? (jsxRuntime.jsx("input", { type: "text", value: hexColor, onChange: handleHexChange })) : (jsxRuntime.jsxs("div", { className: "cw-grid-base-3 cw-gap-small", children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("label", { children: "R:" }), jsxRuntime.jsx("input", { type: "number", name: "r", min: "0", max: "255", value: rgb.r, onChange: handleRgbChange })] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("label", { children: "G:" }), jsxRuntime.jsx("input", { type: "number", name: "g", min: "0", max: "255", value: rgb.g, onChange: handleRgbChange })] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("label", { children: "B:" }), jsxRuntime.jsx("input", { type: "number", name: "b", min: "0", max: "255", value: rgb.b, onChange: handleRgbChange })] })] })) }), jsxRuntime.jsxs("div", { className: styles$l.colorPickerInteractiveArea, children: [jsxRuntime.jsx("div", { className: styles$l.hueBar, ref: hueBarRef, onClick: handleHueBarClick, children: jsxRuntime.jsx("div", { className: styles$l.hueBarSlider, style: { top: `${(360 - hsv.h) / 360 * 100}%` } }) }), jsxRuntime.jsxs("div", { className: styles$l.colorArea, ref: colorAreaRef, onClick: handleColorAreaClick, children: [jsxRuntime.jsxs("div", { className: styles$l.colorAreaOverlay, children: [jsxRuntime.jsx("div", { className: styles$l.hueBackground, style: { backgroundColor: hueHex } }), jsxRuntime.jsx("div", { className: styles$l.whiteGradient }), jsxRuntime.jsx("div", { className: styles$l.blackGradient })] }), jsxRuntime.jsx("div", { className: styles$l.colorAreaCursor, style: {
|
|
3577
3598
|
left: `${hsv.s}%`,
|
|
3578
3599
|
top: `${100 - hsv.v}%`
|
|
3579
3600
|
} })] })] })] }));
|
|
3580
3601
|
};
|
|
3581
3602
|
|
|
3582
|
-
var styles$
|
|
3603
|
+
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"};
|
|
3583
3604
|
|
|
3584
3605
|
const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, readOnly = false, width = '4rem', height = '2rem', labelProps, layoutProps, className, style, }) => {
|
|
3585
3606
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -3712,11 +3733,11 @@ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled
|
|
|
3712
3733
|
break;
|
|
3713
3734
|
}
|
|
3714
3735
|
};
|
|
3715
|
-
return (jsxRuntime.jsxs("div", { className: `cw-input-color ${styles$
|
|
3736
|
+
return (jsxRuntime.jsxs("div", { className: `cw-input-color ${styles$k.container}${className ? ` ${className}` : ''}`, style: style, "data-direction": layoutProps?.direction ?? "row", "data-align": layoutProps?.align, children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps })), jsxRuntime.jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$k.selectColor} ${disabled ? styles$k.disabled : ''} ${readOnly ? styles$k.readOnly : ''}`, style: {
|
|
3716
3737
|
width,
|
|
3717
3738
|
height,
|
|
3718
3739
|
backgroundColor: value,
|
|
3719
|
-
}, "aria-label": "Open color picker", "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-readonly": readOnly, role: "button", tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown }), isOpen && reactDom.createPortal(jsxRuntime.jsx("div", { ref: dropdownRef, className: styles$
|
|
3740
|
+
}, "aria-label": "Open color picker", "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-readonly": readOnly, role: "button", tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown }), isOpen && reactDom.createPortal(jsxRuntime.jsx("div", { ref: dropdownRef, className: styles$k.colorDropdown, style: dropdownStyle, role: "dialog", "aria-modal": "true", "aria-label": "Color picker", children: jsxRuntime.jsx(CwColorPicker, { initialColor: value, onChange: handleColorChange, previewText: previewText }) }), document.body)] }));
|
|
3720
3741
|
};
|
|
3721
3742
|
|
|
3722
3743
|
/**
|
|
@@ -3971,7 +3992,7 @@ function CwInputDateText(props) {
|
|
|
3971
3992
|
return (jsxRuntime.jsx("div", { className: "cw-input-date-text", children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsxs("div", { children: [jsxRuntime.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 }), jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(CwIcon, { iconId: "calendar" }), jsxRuntime.jsx("input", { type: "date", disabled: disabled, onChange: onChangeInputDate, readOnly: readOnly, ref: dateInputRef, tabIndex: -1, value: date, ...inputProps })] })] }), buttonProps && jsxRuntime.jsx(CwButton, { ...buttonProps })] }) }));
|
|
3972
3993
|
}
|
|
3973
3994
|
|
|
3974
|
-
var styles$
|
|
3995
|
+
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"};
|
|
3975
3996
|
|
|
3976
3997
|
const DEFAULT_LABELS = {
|
|
3977
3998
|
dropImageHere: "Drop image here",
|
|
@@ -4050,7 +4071,7 @@ function CwInputImage(props) {
|
|
|
4050
4071
|
const file = e.currentTarget.files?.[0];
|
|
4051
4072
|
void handleFile(file ?? null);
|
|
4052
4073
|
};
|
|
4053
|
-
return (jsxRuntime.jsxs("div", { className: `cw-input-image ${styles$
|
|
4074
|
+
return (jsxRuntime.jsxs("div", { className: `cw-input-image ${styles$j.container}`, "data-size": size, children: [jsxRuntime.jsxs("div", { onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, className: styles$j.dropZone, children: [jsxRuntime.jsx(CwIcon, { iconId: "upload" }), jsxRuntime.jsxs("div", { className: "cw-flex-column cw-gap-tiny", children: [jsxRuntime.jsx("p", { className: styles$j.title, children: labels.dropImageHere }), jsxRuntime.jsx("p", { className: styles$j.subtitle, children: labels.acceptedFormats(allowedFormats.join(", ").replace(/image\//g, "")) })] })] }), jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-center-center cw-gap-small", children: [jsxRuntime.jsx(CwButton, { onClick: onPasteButtonClick, icon: "paste", text: labels.paste, size: size }), jsxRuntime.jsx(CwButton, { onClick: () => inputRef.current?.click(), icon: "folder-open", text: labels.browse, size: size })] }), jsxRuntime.jsx("input", { ref: inputRef, type: "file", accept: allowedFormats.join(","), onChange: handleFileChange, className: styles$j.hiddenInput, ...inputProps })] }));
|
|
4054
4075
|
}
|
|
4055
4076
|
|
|
4056
4077
|
/**
|
|
@@ -4182,7 +4203,7 @@ const CwImageArea = React.forwardRef((props, ref) => {
|
|
|
4182
4203
|
});
|
|
4183
4204
|
CwImageArea.displayName = "CwImageArea";
|
|
4184
4205
|
|
|
4185
|
-
var styles$
|
|
4206
|
+
var styles$i = {"container":"cw-weekday-selector-module__container__pwcvx","days":"cw-weekday-selector-module__days__Dd3RH"};
|
|
4186
4207
|
|
|
4187
4208
|
/* 2024-01-01 was a Monday. Formatted in UTC so a negative browser offset cannot shift a day. */
|
|
4188
4209
|
const MONDAY_UTC = Date.UTC(2024, 0, 1);
|
|
@@ -4363,7 +4384,7 @@ class Weekdays {
|
|
|
4363
4384
|
}
|
|
4364
4385
|
}
|
|
4365
4386
|
|
|
4366
|
-
const CwWeekdaySelector = ({ value = "mtwrfsu", onChange, disabled = false, labelProps, layout, feedback, locale = "en-GB", className }) => {
|
|
4387
|
+
const CwWeekdaySelector = ({ value = "mtwrfsu", onChange, disabled = false, labelProps, layout, feedback, locale = "en-GB", className, ...dataAttributes }) => {
|
|
4367
4388
|
const selectedDays = Weekdays.tryFromString(value).toArray();
|
|
4368
4389
|
const dayNames = React.useMemo(() => getWeekdayNames(locale), [locale]);
|
|
4369
4390
|
const handleChange = (day, checked) => {
|
|
@@ -4380,16 +4401,16 @@ const CwWeekdaySelector = ({ value = "mtwrfsu", onChange, disabled = false, labe
|
|
|
4380
4401
|
// Points at the label element rather than copying its text, which also covers a labelProps that
|
|
4381
4402
|
// carries children instead of `text`.
|
|
4382
4403
|
const labelId = labelProps?.id ?? `${feedbackId}-label`;
|
|
4383
|
-
return (jsxRuntime.jsxs("div", { className: `cw-weekday-selector ${styles$
|
|
4404
|
+
return (jsxRuntime.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 && jsxRuntime.jsx(CwLabel, { id: labelId, ...labelProps }), jsxRuntime.jsx("div", { role: "group", className: styles$i.days, "aria-labelledby": labelProps ? labelId : undefined, "aria-describedby": describedBy, children: Weekdays.getFullWeek().map(day => (jsxRuntime.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) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
4384
4405
|
};
|
|
4385
4406
|
|
|
4386
|
-
var styles$
|
|
4407
|
+
var styles$h = {"check-container":"cw-check-module__check-container__4nscZ","group":"cw-check-module__group__6JCQo","options":"cw-check-module__options__-g9LF"};
|
|
4387
4408
|
|
|
4388
4409
|
function CwCheck(props) {
|
|
4389
4410
|
const { labelProps, labelText, direction, alignment, className, ...inputProps } = props;
|
|
4390
4411
|
const resolvedDirection = direction ?? alignment ?? "row";
|
|
4391
4412
|
const displayText = labelProps?.text ?? labelText;
|
|
4392
|
-
return (jsxRuntime.jsx("div", { className: `cw-check ${styles$
|
|
4413
|
+
return (jsxRuntime.jsx("div", { className: `cw-check ${styles$h["check-container"]}${className ? ` ${className}` : ''}`, children: jsxRuntime.jsxs("label", { "data-direction": resolvedDirection, children: [jsxRuntime.jsx("input", { type: "checkbox", ...inputProps }), displayText && (jsxRuntime.jsx("span", { className: "cw-icon-text", children: displayText }))] }) }));
|
|
4393
4414
|
}
|
|
4394
4415
|
|
|
4395
4416
|
function CwCheckbox(CwCheckboxProps) {
|
|
@@ -4443,14 +4464,14 @@ function CwCheckboxGroup({ options, value = [], onChange, labelProps, groupLayou
|
|
|
4443
4464
|
?? (optionsAlignment === "column" ? "row" : "column");
|
|
4444
4465
|
// Each checkbox's box-to-text layout is the opposite of the options flow, mirroring CwRadioGroup.
|
|
4445
4466
|
const checkDirection = itemDirection === "row" ? "column" : "row";
|
|
4446
|
-
return (jsxRuntime.jsxs("div", { className: `cw-checkbox-group ${styles$
|
|
4467
|
+
return (jsxRuntime.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 && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.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) => (jsxRuntime.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) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
4447
4468
|
}
|
|
4448
4469
|
|
|
4449
|
-
var styles$
|
|
4470
|
+
var styles$g = {"radio":"cw-radio-module__radio__5sh7a","group":"cw-radio-module__group__br-HM","options":"cw-radio-module__options__LSw7M"};
|
|
4450
4471
|
|
|
4451
4472
|
/** Single native radio input. Building block for CwRadioGroup. */
|
|
4452
4473
|
function CwRadio({ label, direction = "row", className, ...inputProps }) {
|
|
4453
|
-
return (jsxRuntime.jsxs("label", { className: `cw-radio ${styles$
|
|
4474
|
+
return (jsxRuntime.jsxs("label", { className: `cw-radio ${styles$g.radio}${className ? ` ${className}` : ""}`, "data-direction": direction, children: [jsxRuntime.jsx("input", { type: "radio", ...inputProps }), label && jsxRuntime.jsx("span", { children: label })] }));
|
|
4454
4475
|
}
|
|
4455
4476
|
|
|
4456
4477
|
/**
|
|
@@ -4477,7 +4498,7 @@ function CwRadioGroup({ options, value, onChange, labelProps, groupLayout, itemL
|
|
|
4477
4498
|
// (itemLayout column) reads best with the circle beside the text; a side-by-side row reads
|
|
4478
4499
|
// best with the circle above the text.
|
|
4479
4500
|
const radioDirection = itemLayout?.direction === "row" ? "column" : "row";
|
|
4480
|
-
return (jsxRuntime.jsxs("div", { className: `cw-radio-group ${styles$
|
|
4501
|
+
return (jsxRuntime.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 && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.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) => (jsxRuntime.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) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
|
|
4481
4502
|
}
|
|
4482
4503
|
|
|
4483
4504
|
function CwToggle(props) {
|
|
@@ -4618,7 +4639,7 @@ function useDropdownPortal({ anchorRef, isOpen, onClose, positionStrategy = defa
|
|
|
4618
4639
|
return { panelRef, panelStyle: style, renderPanel };
|
|
4619
4640
|
}
|
|
4620
4641
|
|
|
4621
|
-
var styles$
|
|
4642
|
+
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"};
|
|
4622
4643
|
|
|
4623
4644
|
/**
|
|
4624
4645
|
* Custom dropdown component with colour-coded options, optional search filter, and full
|
|
@@ -4732,12 +4753,12 @@ function CwDropdown({ options, value, onChange, labelProps, alignProps, placehol
|
|
|
4732
4753
|
}
|
|
4733
4754
|
}, [isOpen, highlightedIndex, filteredOptions, handleOptionSelect]);
|
|
4734
4755
|
const flexDirection = alignProps?.flexDirection ?? "row";
|
|
4735
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-dropdown${className ? ` ${className}` : ""}`, "data-direction": flexDirection, style: style, ...otherProps, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && jsxRuntime.jsx(CwLabel, { id: labelId, ...labelProps }), jsxRuntime.jsxs("div", { className: styles$
|
|
4736
|
-
styles$
|
|
4737
|
-
value === option.value ? styles$
|
|
4738
|
-
highlightedIndex === index ? styles$
|
|
4739
|
-
option.disabled ? styles$
|
|
4740
|
-
].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 && (jsxRuntime.jsx("span", { className: styles$
|
|
4756
|
+
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-dropdown${className ? ` ${className}` : ""}`, "data-direction": flexDirection, style: style, ...otherProps, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && jsxRuntime.jsx(CwLabel, { id: labelId, ...labelProps }), jsxRuntime.jsxs("div", { className: styles$f.value, children: [jsxRuntime.jsxs("div", { className: "cw-dropdown-wrapper", ref: wrapperRef, children: [jsxRuntime.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: [jsxRuntime.jsx("div", { className: "cw-dropdown-trigger-content", id: valueId, children: selectedOption ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [selectedOption.color && (jsxRuntime.jsx("span", { className: styles$f.colorCircle, style: { backgroundColor: selectedOption.color } })), jsxRuntime.jsx("span", { children: selectedOption.label })] })) : (jsxRuntime.jsx("span", { className: "cw-dropdown-placeholder", children: placeholder })) }), jsxRuntime.jsx(CwIcon, { iconId: "chevron-down", size: "small" })] }), renderPanel(jsxRuntime.jsxs("div", { ref: panelRef, className: styles$f.dropdown, style: panelStyle, role: "listbox", onKeyDown: handleKeyDown, children: [allowSearch && (jsxRuntime.jsx("div", { className: styles$f.searchBox, children: jsxRuntime.jsx("input", { ref: inputRef, type: "text", placeholder: "Search...", value: searchText, onChange: handleSearchChange, onKeyDown: handleKeyDown, className: styles$f.searchInput, autoComplete: "off" }) })), jsxRuntime.jsx("ul", { children: filteredOptions.length > 0 ? (filteredOptions.map((option, index) => (jsxRuntime.jsxs("li", { ref: highlightedIndex === index ? highlightedItemRef : null, className: [
|
|
4757
|
+
styles$f.option,
|
|
4758
|
+
value === option.value ? styles$f.optionSelected : "",
|
|
4759
|
+
highlightedIndex === index ? styles$f.optionFocused : "",
|
|
4760
|
+
option.disabled ? styles$f.optionDisabled : "",
|
|
4761
|
+
].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 && (jsxRuntime.jsx("span", { className: styles$f.colorCircle, style: { backgroundColor: option.color } })), jsxRuntime.jsx("span", { children: option.label })] }, option.value)))) : (jsxRuntime.jsx("li", { className: styles$f.emptyState, children: "No options available" })) })] }))] }), feedbackMessages.map((item, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": item.type, "aria-live": "polite", children: item.message }, index)))] })] }) }));
|
|
4741
4762
|
}
|
|
4742
4763
|
|
|
4743
4764
|
/**
|
|
@@ -4754,7 +4775,7 @@ function CwDropdownFilter(props) {
|
|
|
4754
4775
|
return (jsxRuntime.jsxs("div", { id: props.IdContent, className: containerClassName, children: [props.children, isVisible && (jsxRuntime.jsx("nav", { className: "cw-dropdown-menu", style: inlineStyles, onMouseLeave: props.onMouseLeave, id: props.idDropDownFilter, role: "menu", children: jsxRuntime.jsx("ul", { role: "none", children: props.DataSourceDropDownItem?.map((item) => (jsxRuntime.jsx("li", { id: item.IdDropDown_filter, role: "menuitem", children: item.dropDownFilter_desc }, item.IdDropDown_filter))) }) }))] }));
|
|
4755
4776
|
}
|
|
4756
4777
|
|
|
4757
|
-
var styles$
|
|
4778
|
+
var styles$e = {"container":"cw-popover-button-module__container__YSWQU","panel":"cw-popover-button-module__panel__C-BTn"};
|
|
4758
4779
|
|
|
4759
4780
|
/**
|
|
4760
4781
|
* Button that toggles a floating panel with arbitrary children.
|
|
@@ -4833,7 +4854,7 @@ function CwPopoverButton({ children, panelWidth = "auto", placement = "bottom-st
|
|
|
4833
4854
|
}
|
|
4834
4855
|
panel.showPopover();
|
|
4835
4856
|
}, [placement]);
|
|
4836
|
-
return (jsxRuntime.jsxs("div", { ref: containerRef, className: styles$
|
|
4857
|
+
return (jsxRuntime.jsxs("div", { ref: containerRef, className: styles$e.container, children: [jsxRuntime.jsx(CwButton, { ...buttonProps, onClick: handleClick }), jsxRuntime.jsx("div", { ref: panelCallbackRef, className: `${styles$e.panel}${panelClassName ? ` ${panelClassName}` : ""}`, style: { width: panelWidth }, children: children })] }));
|
|
4837
4858
|
}
|
|
4838
4859
|
|
|
4839
4860
|
function itemsToMultiFilterTags(items, nameKey, valueKey, category, primaryColor, onPrimaryColor) {
|
|
@@ -4851,13 +4872,13 @@ function itemsToMultiFilterTags(items, nameKey, valueKey, category, primaryColor
|
|
|
4851
4872
|
return result;
|
|
4852
4873
|
}
|
|
4853
4874
|
|
|
4854
|
-
var styles$
|
|
4875
|
+
var styles$d = {"cw-multifilter-tag":"cw-multi-filter-tag-module__cw-multifilter-tag__Epda-"};
|
|
4855
4876
|
|
|
4856
4877
|
const CwMultiFilterTag = props => {
|
|
4857
4878
|
const { ID, Name, Value, Category, Removable, PrimaryColor, Selectable, Selected } = props;
|
|
4858
4879
|
const backgroundColor = `rgb(${PrimaryColor.r},${PrimaryColor.g},${PrimaryColor.b})`;
|
|
4859
4880
|
const isOutlineMode = Selected && !Removable;
|
|
4860
|
-
return (jsxRuntime.jsx("li", { className: styles$
|
|
4881
|
+
return (jsxRuntime.jsx("li", { className: styles$d["cw-multifilter-tag"], id: ID, "data-value": Value, "data-category": Category, "data-selected": !!Selected, title: props.tooltip ?? Name, onClick: () => {
|
|
4861
4882
|
if (Selectable)
|
|
4862
4883
|
props.OnSelect?.(props);
|
|
4863
4884
|
}, children: jsxRuntime.jsx(CwChip, { label: Name, colorScheme: "custom", customColor: backgroundColor, variant: isOutlineMode ? "outline" : "soft", closable: Removable, onClose: () => props.OnRemove?.(props),
|
|
@@ -4867,7 +4888,7 @@ const CwMultiFilterTag = props => {
|
|
|
4867
4888
|
} : undefined }) }));
|
|
4868
4889
|
};
|
|
4869
4890
|
|
|
4870
|
-
var styles$
|
|
4891
|
+
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"};
|
|
4871
4892
|
|
|
4872
4893
|
/**
|
|
4873
4894
|
* A multiple filter selector, a MULTI-SELECT even. Allows users to select and filter items based on tags.
|
|
@@ -5108,9 +5129,9 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
5108
5129
|
inputRef.current?.focus();
|
|
5109
5130
|
}
|
|
5110
5131
|
};
|
|
5111
|
-
return (jsxRuntime.jsxs("form", { ref: componentRef, id: id, "data-testid": testId, className: `${styles$
|
|
5132
|
+
return (jsxRuntime.jsxs("form", { ref: componentRef, id: id, "data-testid": testId, className: `${styles$c["cw-multi-filter"]}${className ? ` ${className}` : ""}`, style: style, onSubmit: (e) => {
|
|
5112
5133
|
e.preventDefault();
|
|
5113
|
-
}, children: [jsxRuntime.jsxs("div", { onClick: handleDivClick, ref: wrapperRef, className: styles$
|
|
5134
|
+
}, children: [jsxRuntime.jsxs("div", { onClick: handleDivClick, ref: wrapperRef, className: styles$c["cw-multi-filter-search"], style: isPanelOpen ? { outline: "1px solid var(--cw-outline-variant)" } : {}, children: [jsxRuntime.jsxs("ul", { id: id + "_selected_filters", children: [Array.from(selectedTags).map(tag => (React.createElement(CwMultiFilterTag, { ...tag, key: tag.ID, Selectable: false, Removable: true, OnRemove: () => removeTag(tag.ID) }))), jsxRuntime.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 => {
|
|
5114
5135
|
switch (e.key) {
|
|
5115
5136
|
case "Enter":
|
|
5116
5137
|
case "Tab": {
|
|
@@ -5137,7 +5158,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
5137
5158
|
break;
|
|
5138
5159
|
}
|
|
5139
5160
|
}
|
|
5140
|
-
} })] }), selectedTags.size > 0 && (jsxRuntime.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(jsxRuntime.jsxs("section", { ref: panelRef, className: styles$
|
|
5161
|
+
} })] }), selectedTags.size > 0 && (jsxRuntime.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(jsxRuntime.jsxs("section", { ref: panelRef, className: styles$c["cw-multi-filter-catalog-container"], style: panelStyle, children: [jsxRuntime.jsxs("nav", { children: [jsxRuntime.jsx("button", { className: selectedCategory === "All" ? styles$c["category-selected"] : undefined, onClick: () => handleClickCategory("All"), children: allCategoriesLabel }), Array.from(categoriesMappedToTags().keys()).map(category => (jsxRuntime.jsx("button", { className: selectedCategory === category ? styles$c["category-selected"] : undefined, style: {
|
|
5141
5162
|
backgroundColor: getColor(category).primary,
|
|
5142
5163
|
color: getColor(category).onPrimary,
|
|
5143
5164
|
}, onClick: () => handleClickCategory(category), children: category }, category)))] }), jsxRuntime.jsx("ul", { children: displayTags
|
|
@@ -5163,7 +5184,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
5163
5184
|
} }, props.ID))) })] }))] }));
|
|
5164
5185
|
};
|
|
5165
5186
|
|
|
5166
|
-
var styles$
|
|
5187
|
+
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"};
|
|
5167
5188
|
|
|
5168
5189
|
/**
|
|
5169
5190
|
* Multi-select input with chip tags and searchable dropdown.
|
|
@@ -5301,13 +5322,13 @@ function CwTagSelector({ id, options, value, onChange, labelProps, iconProps, al
|
|
|
5301
5322
|
const feedbackId = React.useId();
|
|
5302
5323
|
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
5303
5324
|
const describedBy = feedbackIds.join(" ") || undefined;
|
|
5304
|
-
return (jsxRuntime.jsxs("div", { ref: containerRef, className: `${styles$
|
|
5305
|
-
inputRef.current?.focus(); }, children: [selectedOptions.map(opt => (jsxRuntime.jsx(CwChip, { label: opt.label, colorScheme: opt.color ? "custom" : "info", customColor: opt.color, closable: !disabled, onClose: () => handleRemove(opt.value) }, opt.value))), jsxRuntime.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 && (jsxRuntime.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) => (jsxRuntime.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) ? (jsxRuntime.jsxs("div", { ref: panelRef, className: styles$
|
|
5325
|
+
return (jsxRuntime.jsxs("div", { ref: containerRef, className: `${styles$b.container}${className ? ` ${className}` : ""}`, style: style, id: id, "data-direction": direction, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsxs("div", { className: styles$b.value, children: [jsxRuntime.jsxs("div", { className: `${styles$b.inputBox}${disabled ? ` ${styles$b.disabled}` : ""}`, ref: inputBoxRef, onClick: () => { if (!disabled)
|
|
5326
|
+
inputRef.current?.focus(); }, children: [selectedOptions.map(opt => (jsxRuntime.jsx(CwChip, { label: opt.label, colorScheme: opt.color ? "custom" : "info", customColor: opt.color, closable: !disabled, onClose: () => handleRemove(opt.value) }, opt.value))), jsxRuntime.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 && (jsxRuntime.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) => (jsxRuntime.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) ? (jsxRuntime.jsxs("div", { ref: panelRef, className: styles$b.dropdown, style: panelStyle, children: [showSelectAll && !search && (jsxRuntime.jsxs("div", { className: styles$b.selectAll, onMouseDown: (e) => e.preventDefault(), onClick: handleToggleAll, children: [jsxRuntime.jsx("input", { type: "checkbox", checked: allSelected, readOnly: true, tabIndex: -1 }), allSelected ? "Deselect all" : "Select all"] })), jsxRuntime.jsx("ul", { ref: listRef, children: filtered.map((opt, idx) => (jsxRuntime.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 && jsxRuntime.jsx("span", { className: styles$b.optionDot, style: { backgroundColor: opt.color } }), opt.label] }, opt.value))) })] })) : null)] }));
|
|
5306
5327
|
}
|
|
5307
5328
|
|
|
5308
|
-
var styles$
|
|
5329
|
+
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"};
|
|
5309
5330
|
|
|
5310
|
-
function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId: initialSelectedId = null }) {
|
|
5331
|
+
function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId: initialSelectedId = null, ...dataAttributes }) {
|
|
5311
5332
|
const [expanded, setExpanded] = React.useState(new Set());
|
|
5312
5333
|
// const [selectedId, setSelectedId] = useState<string | number | null>(initialSelectedId);
|
|
5313
5334
|
const [selectedId, setSelectedId] = React.useState(null);
|
|
@@ -5372,10 +5393,10 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
5372
5393
|
const isLeaf = !hasChildren;
|
|
5373
5394
|
const isSelected = selectedId?.toString().toLowerCase() === node.id.toString().toLowerCase();
|
|
5374
5395
|
const selectable = allowParentSelection || isLeaf;
|
|
5375
|
-
return (jsxRuntime.jsxs("div", { className: styles$
|
|
5376
|
-
styles$
|
|
5377
|
-
isSelected && styles$
|
|
5378
|
-
!selectable && styles$
|
|
5396
|
+
return (jsxRuntime.jsxs("div", { className: styles$a["tree-item"], children: [jsxRuntime.jsxs("div", { className: [
|
|
5397
|
+
styles$a["tree-node"],
|
|
5398
|
+
isSelected && styles$a["selected"],
|
|
5399
|
+
!selectable && styles$a["non-selectable"]
|
|
5379
5400
|
].filter(Boolean).join(' '), style: { paddingLeft: `${depth * 24 + 8}px` }, onClick: () => {
|
|
5380
5401
|
if (selectable) {
|
|
5381
5402
|
setSelectedId(node.id);
|
|
@@ -5384,7 +5405,10 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
5384
5405
|
else {
|
|
5385
5406
|
toggleExpand(node.id);
|
|
5386
5407
|
}
|
|
5387
|
-
}, children: [hasChildren && (jsxRuntime.jsx(
|
|
5408
|
+
}, children: [hasChildren && (jsxRuntime.jsx(CwButton, { variant: "icon", color: "neutral", icon: isExpanded ? "chevron-down" : "chevron-right", "aria-expanded": isExpanded, "aria-label": `${isExpanded ? "Collapse" : "Expand"} ${node.label}`, onClick: (event) => {
|
|
5409
|
+
event.stopPropagation();
|
|
5410
|
+
toggleExpand(node.id);
|
|
5411
|
+
} })), jsxRuntime.jsx("div", { className: `${styles$a["tree-label"]} ${!hasChildren ? styles$a["tree-spacer"] : ''}`, children: node.label })] }), hasChildren && isExpanded && (jsxRuntime.jsx("div", { className: styles$a["tree-children"], children: node.children.map((child) => renderNode(child, depth + 1)) }))] }, node.id));
|
|
5388
5412
|
};
|
|
5389
5413
|
// Function to search for nodes that match the search term
|
|
5390
5414
|
const searchInTree = (nodes, searchTerm) => {
|
|
@@ -5408,7 +5432,7 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
5408
5432
|
return results;
|
|
5409
5433
|
};
|
|
5410
5434
|
const filteredData = searchInTree(data, search);
|
|
5411
|
-
return (jsxRuntime.jsxs("div", { className: `cw-tree-view ${styles$
|
|
5435
|
+
return (jsxRuntime.jsxs("div", { ...dataAttributes, className: `cw-tree-view ${styles$a["tree-container"]}`, children: [jsxRuntime.jsxs("header", { children: [jsxRuntime.jsx("input", { type: "text", placeholder: "Search in tree...", value: search, onChange: (e) => setSearch(e.target.value) }), search && (jsxRuntime.jsx(CwButton, { onClick: () => setSearch(""), type: "button", icon: "close", variant: "icon", color: "neutral" }))] }), jsxRuntime.jsx("div", { className: styles$a["tree-wrapper"], children: filteredData.length > 0 ? (filteredData.map((node) => renderNode(node))) : (jsxRuntime.jsxs("div", { className: styles$a["empty-state"], children: [jsxRuntime.jsx(CwIcon, { iconId: "comment" }), search ? "No results found" : "There are no items"] })) })] }));
|
|
5412
5436
|
}
|
|
5413
5437
|
|
|
5414
5438
|
const EXACT_PHRASE = /"([^"]+)"/g;
|
|
@@ -5476,7 +5500,7 @@ function sortNavItems(items, alphabetically) {
|
|
|
5476
5500
|
return [...items].sort((first, second) => first.label.localeCompare(second.label));
|
|
5477
5501
|
}
|
|
5478
5502
|
|
|
5479
|
-
var styles$
|
|
5503
|
+
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"};
|
|
5480
5504
|
|
|
5481
5505
|
const SKELETON_ROW_COUNT = 5;
|
|
5482
5506
|
const defaultRenderLink = (item, children) => (jsxRuntime.jsx("a", { href: item.href, children: children }));
|
|
@@ -5488,13 +5512,13 @@ function CwNavMenu({ items, loading = false, isActive, renderLink = defaultRende
|
|
|
5488
5512
|
const renderItem = (item, level) => {
|
|
5489
5513
|
const children = item.children;
|
|
5490
5514
|
if (children && children.length > 0) {
|
|
5491
|
-
return (jsxRuntime.jsx("li", { children: jsxRuntime.jsxs("details", { "data-level": level, open: hasActiveDescendant(item) || undefined, children: [jsxRuntime.jsxs("summary", { children: [item.icon && jsxRuntime.jsx(CwIcon, { iconId: item.icon, size: level >= 2 ? "small" : "medium" }), item.label, (showExpandIndicator || level >= 2) && (jsxRuntime.jsx(CwIcon, { iconId: "chevron-down", size: "small", className: styles$
|
|
5515
|
+
return (jsxRuntime.jsx("li", { children: jsxRuntime.jsxs("details", { "data-level": level, open: hasActiveDescendant(item) || undefined, children: [jsxRuntime.jsxs("summary", { children: [item.icon && jsxRuntime.jsx(CwIcon, { iconId: item.icon, size: level >= 2 ? "small" : "medium" }), item.label, (showExpandIndicator || level >= 2) && (jsxRuntime.jsx(CwIcon, { iconId: "chevron-down", size: "small", className: styles$9.expandIndicator }))] }), jsxRuntime.jsx("ul", { children: children.map(child => renderItem(child, level + 1)) })] }) }, item.id));
|
|
5492
5516
|
}
|
|
5493
|
-
return (jsxRuntime.jsx("li", { "data-active": isActive?.(item) ? "true" : undefined, children: renderLink(item, jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon && jsxRuntime.jsx(CwIcon, { iconId: item.icon, size: "medium" }), item.label, isFavorite?.(item) && jsxRuntime.jsx(CwIcon, { iconId: "star", size: "small", className: styles$
|
|
5517
|
+
return (jsxRuntime.jsx("li", { "data-active": isActive?.(item) ? "true" : undefined, children: renderLink(item, jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon && jsxRuntime.jsx(CwIcon, { iconId: item.icon, size: "medium" }), item.label, isFavorite?.(item) && jsxRuntime.jsx(CwIcon, { iconId: "star", size: "small", className: styles$9.favoriteStar })] })) }, item.id));
|
|
5494
5518
|
};
|
|
5495
|
-
return (jsxRuntime.jsxs("nav", { ...navProps, className: [styles$
|
|
5496
|
-
? Array.from({ length: SKELETON_ROW_COUNT }, (_unused, index) => (jsxRuntime.jsx("li", { className: styles$
|
|
5497
|
-
: visibleItems.map(item => renderItem(item, 1)) }), showEmptyMessage && jsxRuntime.jsx("p", { className: styles$
|
|
5519
|
+
return (jsxRuntime.jsxs("nav", { ...navProps, className: [styles$9.menu, className].filter(Boolean).join(" "), "aria-busy": loading || undefined, children: [favoritesSlot && (jsxRuntime.jsxs("details", { open: true, ...favoritesProps, className: [styles$9.favorites, favoritesProps?.className].filter(Boolean).join(" "), children: [jsxRuntime.jsxs("summary", { children: [jsxRuntime.jsx(CwIcon, { iconId: "star", size: "medium" }), favoritesLabel] }), jsxRuntime.jsx("div", { className: styles$9.favoritesContent, children: favoritesSlot })] })), beforeTreeSlot, jsxRuntime.jsx("ul", { children: loading
|
|
5520
|
+
? Array.from({ length: SKELETON_ROW_COUNT }, (_unused, index) => (jsxRuntime.jsx("li", { className: styles$9.skeleton, children: jsxRuntime.jsx(CwSkeleton, { height: "var(--cw-size-small)", radius: "var(--cw-border-radius-small)" }) }, index)))
|
|
5521
|
+
: visibleItems.map(item => renderItem(item, 1)) }), showEmptyMessage && jsxRuntime.jsx("p", { className: styles$9.emptyMessage, children: emptyMessage })] }));
|
|
5498
5522
|
}
|
|
5499
5523
|
|
|
5500
5524
|
var dropdownStyles = {"dropdown":"cw-choice-dropdown-module__dropdown__P0b4j","option":"cw-choice-dropdown-module__option__uR-ro","optionFocused":"cw-choice-dropdown-module__optionFocused__BYMxj"};
|
|
@@ -5660,6 +5684,8 @@ function CwSearchInput(optionsProps) {
|
|
|
5660
5684
|
return (jsxRuntime.jsxs("div", { className: `cw-search-input ${className || ""}`, style: style, ...otherProps, "data-direction": direction, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsxRuntime.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 && (jsxRuntime.jsx("div", { className: "cw-search-input-loading", children: jsxRuntime.jsx(CwIcon, { iconId: "spinner" }) })), jsxRuntime.jsx("div", { className: "cw-search-input-icons", children: searchText && !disabled && !isLoading ? (jsxRuntime.jsx(CwButton, { type: "button", onClick: handleClearClick, "aria-label": "Clear search", variant: "icon", icon: "close", color: "neutral" })) : (iconProps ? jsxRuntime.jsx(CwIcon, { ...iconProps }) : jsxRuntime.jsx(CwIcon, { iconId: "search" })) })] })] }), renderPanel(jsxRuntime.jsx("div", { ref: panelRef, id: listboxId, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsxRuntime.jsx("ul", { children: filteredOptions.map((option, index) => (jsxRuntime.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))) }) }))] }));
|
|
5661
5685
|
}
|
|
5662
5686
|
|
|
5687
|
+
var styles$8 = {"value":"cw-search-async-module__value__z53xT"};
|
|
5688
|
+
|
|
5663
5689
|
/**
|
|
5664
5690
|
* Generic API-backed search input. Fetches matching options from a caller-supplied `onSearch`
|
|
5665
5691
|
* callback as the user types (debounced), renders them in a portal-based dropdown with keyboard
|
|
@@ -5681,7 +5707,7 @@ function CwSearchInput(optionsProps) {
|
|
|
5681
5707
|
* icon={{ iconId: 'control-tower' }}
|
|
5682
5708
|
* />
|
|
5683
5709
|
*/
|
|
5684
|
-
const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveSelection, icon, placeholder = "Search…", minChars = 2, debounceMs = 300, disabled = false, required = false, initialDisplayText, searchTrigger, labelProps, alignProps, width, className = "", }) => {
|
|
5710
|
+
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 }) => {
|
|
5685
5711
|
// State
|
|
5686
5712
|
const [inputValue, setInputValue] = React.useState("");
|
|
5687
5713
|
const [options, setOptions] = React.useState([]);
|
|
@@ -5702,6 +5728,12 @@ const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveS
|
|
|
5702
5728
|
// Stable ids wiring the combobox input to its listbox popup for assistive tech.
|
|
5703
5729
|
const listboxId = React.useId();
|
|
5704
5730
|
const optionId = (index) => `${listboxId}-opt-${index}`;
|
|
5731
|
+
const feedbackMessages = feedback
|
|
5732
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
5733
|
+
: [];
|
|
5734
|
+
const feedbackId = React.useId();
|
|
5735
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
5736
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
5705
5737
|
// Cancel a pending initial-value resolve when the user takes over (typing / clearing / reset),
|
|
5706
5738
|
// so a slow resolve can't overwrite newer input and the loading flag never sticks.
|
|
5707
5739
|
const cancelInitialResolve = React.useCallback(() => {
|
|
@@ -5913,10 +5945,10 @@ const CwSearchAsync = ({ onSearch, onChange, value, onResolveInitial, onResolveS
|
|
|
5913
5945
|
abortRef.current?.abort();
|
|
5914
5946
|
}, []);
|
|
5915
5947
|
const direction = alignProps?.flexDirection || "row";
|
|
5916
|
-
return (jsxRuntime.jsxs("div", { className: `cw-search-input ${className}`, style: {
|
|
5948
|
+
return (jsxRuntime.jsxs("div", { ...dataAttributes, className: `cw-search-input ${className}`, style: {
|
|
5917
5949
|
...(width ? { width } : {}),
|
|
5918
5950
|
...(labelProps?.labelWidth ? { "--label-width": labelProps.labelWidth } : {}),
|
|
5919
|
-
}, "data-direction": direction, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsxRuntime.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) && (jsxRuntime.jsx("div", { className: "cw-search-input-loading", children: jsxRuntime.jsx(CwIcon, { iconId: "spinner" }) })), jsxRuntime.jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsxRuntime.jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selection", variant: "icon", icon: "close", color: "neutral" })) : (icon ? jsxRuntime.jsx(CwIcon, { ...icon }) : jsxRuntime.jsx(CwIcon, { iconId: "search" })) })] })] }), renderPanel(jsxRuntime.jsx("div", { ref: panelRef, id: listboxId, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsxRuntime.jsx("ul", { children: options.map((option, index) => (jsxRuntime.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 ? (jsxRuntime.jsxs("span", { className: "cw-search-async-option-lines", children: [jsxRuntime.jsx("span", { children: option.label }), jsxRuntime.jsx("span", { className: "cw-search-async-option-sub", children: option.subLabel })] })) : (option.label) }, option.id))) }) }))] }));
|
|
5951
|
+
}, "data-direction": direction, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$8.value, children: [jsxRuntime.jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsxRuntime.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) && (jsxRuntime.jsx("div", { className: "cw-search-input-loading", children: jsxRuntime.jsx(CwIcon, { iconId: "spinner" }) })), jsxRuntime.jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsxRuntime.jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selection", variant: "icon", icon: "close", color: "neutral" })) : (icon ? jsxRuntime.jsx(CwIcon, { ...icon }) : jsxRuntime.jsx(CwIcon, { iconId: "search" })) })] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }), renderPanel(jsxRuntime.jsx("div", { ref: panelRef, id: listboxId, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsxRuntime.jsx("ul", { children: options.map((option, index) => (jsxRuntime.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 ? (jsxRuntime.jsxs("span", { className: "cw-search-async-option-lines", children: [jsxRuntime.jsx("span", { children: option.label }), jsxRuntime.jsx("span", { className: "cw-search-async-option-sub", children: option.subLabel })] })) : (option.label) }, option.id))) }) }))] }));
|
|
5920
5952
|
};
|
|
5921
5953
|
|
|
5922
5954
|
var styles$7 = {"menu":"cw-context-menu-module__menu__tXmun","item":"cw-context-menu-module__item__-ko8L","arrow":"cw-context-menu-module__arrow__LHZmQ"};
|
|
@@ -6268,9 +6300,9 @@ var styles$5 = {"switch":"cw-button-switch-module__switch__vdWV-","segment":"cw-
|
|
|
6268
6300
|
* onChange={setView}
|
|
6269
6301
|
* />
|
|
6270
6302
|
*/
|
|
6271
|
-
function CwButtonSwitch({ options, value, onChange, size = "medium", color = "primary", iconOnly = false, direction = "row", disabled = false, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby,
|
|
6303
|
+
function CwButtonSwitch({ options, value, onChange, size = "medium", color = "primary", iconOnly = false, direction = "row", disabled = false, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...dataAttributes }) {
|
|
6272
6304
|
const { getSegmentProps } = useRovingSingleSelect(options, value, onChange);
|
|
6273
|
-
return (jsxRuntime.jsx("div", { className: `cw-button-switch ${styles$5.switch}`, role: "radiogroup", "aria-labelledby": ariaLabelledby, "aria-label": ariaLabelledby ? undefined : ariaLabel, "data-direction": direction,
|
|
6305
|
+
return (jsxRuntime.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) => {
|
|
6274
6306
|
const selected = option.value === value;
|
|
6275
6307
|
const segmentProps = getSegmentProps(index);
|
|
6276
6308
|
return (jsxRuntime.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));
|
|
@@ -6365,7 +6397,7 @@ function usePickerPopup({ anchorRef, isOpen, onClose, position = "left-bottom" }
|
|
|
6365
6397
|
return { popupRef: panelRef, popupStyle: panelStyle, renderPopup: renderPanel };
|
|
6366
6398
|
}
|
|
6367
6399
|
|
|
6368
|
-
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: locale$1 = locale.enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, }) {
|
|
6400
|
+
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: locale$1 = locale.enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, ...dataAttributes }) {
|
|
6369
6401
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
6370
6402
|
const [inputValue, setInputValue] = React.useState("");
|
|
6371
6403
|
const containerRef = React.useRef(null);
|
|
@@ -6555,7 +6587,7 @@ function CwDatePicker({ value, onChange, minDate, maxDate, disabledDates, disabl
|
|
|
6555
6587
|
...(maxDate ? [{ after: maxDate }] : []),
|
|
6556
6588
|
...(disabledMatcher ? [disabledMatcher] : []),
|
|
6557
6589
|
], [disabledDates, minDate, maxDate, disabledMatcher]);
|
|
6558
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsxRuntime.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 }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "single", selected: value || undefined, defaultMonth: defaultMonth || value || undefined, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
6590
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsxRuntime.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 }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "single", selected: value || undefined, defaultMonth: defaultMonth || value || undefined, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
6559
6591
|
today: new Date(),
|
|
6560
6592
|
}, modifiersClassNames: {
|
|
6561
6593
|
today: "rdp-day-today",
|
|
@@ -6833,8 +6865,14 @@ const getPresetsByKeys = (keys) => {
|
|
|
6833
6865
|
.filter(preset => preset !== undefined);
|
|
6834
6866
|
};
|
|
6835
6867
|
|
|
6836
|
-
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, }) {
|
|
6868
|
+
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 }) {
|
|
6837
6869
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
6870
|
+
const feedbackMessages = feedback
|
|
6871
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
6872
|
+
: [];
|
|
6873
|
+
const feedbackId = React.useId();
|
|
6874
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
6875
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
6838
6876
|
const [inputFromValue, setInputFromValue] = React.useState("");
|
|
6839
6877
|
const [inputToValue, setInputToValue] = React.useState("");
|
|
6840
6878
|
const [rangeErrorMessage, setRangeErrorMessage] = React.useState(null);
|
|
@@ -7198,11 +7236,11 @@ function CwDateRangePicker({ value, onChange, minDate, maxDate, disabledDates, d
|
|
|
7198
7236
|
}
|
|
7199
7237
|
return undefined;
|
|
7200
7238
|
}, [value]);
|
|
7201
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), jsxRuntime.jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxRuntime.jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsxRuntime.jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsxRuntime.jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonth || value?.from || undefined, modifiers: {
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7239
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), jsxRuntime.jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxRuntime.jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsxRuntime.jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsxRuntime.jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonth || value?.from || undefined, modifiers: {
|
|
7240
|
+
today: new Date(),
|
|
7241
|
+
}, modifiersClassNames: {
|
|
7242
|
+
today: "rdp-day-today",
|
|
7243
|
+
} })] }), jsxRuntime.jsx("div", { role: "alert", "aria-live": "polite", className: rangeStyles.rangeError, children: rangeErrorMessage })] }))] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) }));
|
|
7206
7244
|
}
|
|
7207
7245
|
|
|
7208
7246
|
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"};
|
|
@@ -7210,9 +7248,16 @@ var timeStyles = {"timePickerPopup":"cw-time-picker-module__timePickerPopup__BN6
|
|
|
7210
7248
|
const isMobileDevice = () => {
|
|
7211
7249
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
7212
7250
|
};
|
|
7213
|
-
function CwTimePicker({ value, onChange, interval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", useNative = isMobileDevice(), }) {
|
|
7251
|
+
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 }) {
|
|
7214
7252
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
7215
7253
|
const [inputValue, setInputValue] = React.useState("");
|
|
7254
|
+
const feedbackMessages = feedback
|
|
7255
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
7256
|
+
: [];
|
|
7257
|
+
const feedbackId = React.useId();
|
|
7258
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
7259
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
7260
|
+
const feedbackElements = feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)));
|
|
7216
7261
|
const containerRef = React.useRef(null);
|
|
7217
7262
|
const wrapperRef = React.useRef(null);
|
|
7218
7263
|
const inputRef = React.useRef(null);
|
|
@@ -7364,13 +7409,13 @@ function CwTimePicker({ value, onChange, interval = 15, minTime, maxTime, labelP
|
|
|
7364
7409
|
const displayValue = inputValue;
|
|
7365
7410
|
// If using native time input
|
|
7366
7411
|
if (useNative) {
|
|
7367
|
-
return (jsxRuntime.jsx("div", { className: `cw-timepicker cw-timepicker-native ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsx("div", { className: styles$4.pickerWrapper, children: jsxRuntime.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" }) })] }) }));
|
|
7412
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, className: `cw-timepicker cw-timepicker-native ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsx("div", { className: styles$4.pickerWrapper, children: jsxRuntime.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] })] }) }));
|
|
7368
7413
|
}
|
|
7369
7414
|
// Custom time picker
|
|
7370
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-timepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { ref: wrapperRef, className: `${styles$4.pickerWrapper} ${timeStyles.field}${showClear ? "" : ` ${timeStyles.narrow}`}`, children: [jsxRuntime.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 && (jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", icon: "close", color: "neutral", onClick: handleClear, tabIndex: -1, "aria-label": "Clear time" })) : (jsxRuntime.jsx(CwIcon, { iconId: "clock" })) })), renderPopup(jsxRuntime.jsx("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${timeStyles.timePickerPopup}`, style: popupStyle, children: jsxRuntime.jsx("div", { className: timeStyles.timePickerList, children: timeOptions.map((time) => {
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7415
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-timepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: `${styles$4.pickerWrapper} ${timeStyles.field}${showClear ? "" : ` ${timeStyles.narrow}`}`, children: [jsxRuntime.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 && (jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", icon: "close", color: "neutral", onClick: handleClear, tabIndex: -1, "aria-label": "Clear time" })) : (jsxRuntime.jsx(CwIcon, { iconId: "clock" })) })), renderPopup(jsxRuntime.jsx("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${timeStyles.timePickerPopup}`, style: popupStyle, children: jsxRuntime.jsx("div", { className: timeStyles.timePickerList, children: timeOptions.map((time) => {
|
|
7416
|
+
const isSelected = time === value;
|
|
7417
|
+
return (jsxRuntime.jsx("button", { ref: isSelected ? selectedItemRef : null, type: "button", className: isSelected ? timeStyles.selected : "", onClick: () => handleTimeSelect(time), children: time }, time));
|
|
7418
|
+
}) }) }))] }), feedbackElements] })] }) }));
|
|
7374
7419
|
}
|
|
7375
7420
|
|
|
7376
7421
|
/**
|
|
@@ -7430,7 +7475,12 @@ function combineDateTimeInOffset(date, hours, minutes, timezoneOffset) {
|
|
|
7430
7475
|
return new Date(zdt.epochMilliseconds);
|
|
7431
7476
|
}
|
|
7432
7477
|
|
|
7433
|
-
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: locale$1 = locale.enGB, timezoneOffset, }) {
|
|
7478
|
+
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: locale$1 = locale.enGB, timezoneOffset, feedback, ...dataAttributes }) {
|
|
7479
|
+
const feedbackMessages = feedback
|
|
7480
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
7481
|
+
: [];
|
|
7482
|
+
const feedbackId = React.useId();
|
|
7483
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
7434
7484
|
// ========================================
|
|
7435
7485
|
// PROPS NORMALIZATION
|
|
7436
7486
|
// ========================================
|
|
@@ -7670,13 +7720,19 @@ function CwDateTimePicker({ value, onChange, minDateTime, maxDateTime, disabledD
|
|
|
7670
7720
|
const displayMaxDate = React.useMemo(() => normalizedMaxDateTime && timezoneOffset !== undefined
|
|
7671
7721
|
? getDateInOffset(normalizedMaxDateTime, timezoneOffset)
|
|
7672
7722
|
: normalizedMaxDateTime, [normalizedMaxDateTime, timezoneOffset]);
|
|
7673
|
-
return jsxRuntime.jsx("div", { className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsxRuntime.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$1 }), jsxRuntime.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 && (jsxRuntime.jsx(CwButton, { type: "button", variant: "outline", onClick: handleNowClick, disabled: disabled, text: nowLabel }))] })] }) });
|
|
7723
|
+
return jsxRuntime.jsx("div", { ...dataAttributes, className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsxRuntime.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$1 }), jsxRuntime.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 && (jsxRuntime.jsx(CwButton, { type: "button", variant: "outline", onClick: handleNowClick, disabled: disabled, text: nowLabel }))] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) });
|
|
7674
7724
|
}
|
|
7675
7725
|
|
|
7676
7726
|
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"};
|
|
7677
7727
|
|
|
7678
|
-
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: locale$1 = locale.enGB, yearRangeStart, yearRangeEnd, }) {
|
|
7728
|
+
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: locale$1 = locale.enGB, yearRangeStart, yearRangeEnd, feedback, ...dataAttributes }) {
|
|
7679
7729
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
7730
|
+
const feedbackMessages = feedback
|
|
7731
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
7732
|
+
: [];
|
|
7733
|
+
const feedbackId = React.useId();
|
|
7734
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
7735
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
7680
7736
|
const [inputValue, setInputValue] = React.useState("");
|
|
7681
7737
|
const [selectedDate, setSelectedDate] = React.useState(value);
|
|
7682
7738
|
const [selectedTime, setSelectedTime] = React.useState("");
|
|
@@ -7920,14 +7976,14 @@ function CwDateTimePickerCompact({ value, onChange, minDateTime, maxDateTime, di
|
|
|
7920
7976
|
...(maxDateTime ? [{ after: maxDateTime }] : []),
|
|
7921
7977
|
...(disabledMatcher ? [disabledMatcher] : []),
|
|
7922
7978
|
], [disabledDates, minDateTime, maxDateTime, disabledMatcher]);
|
|
7923
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-datetimepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsxRuntime.jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, required: required, maxLength: 16 }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear datetime" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar-time" })) }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${compactStyles.compactPopup}`, style: popupStyle, children: [jsxRuntime.jsxs("div", { className: compactStyles.calendarWrapper, children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "single", selected: selectedDate, onSelect: handleDaySelect, defaultMonth: selectedDate, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7979
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-datetimepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsxRuntime.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 }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear datetime" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar-time" })) }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${compactStyles.compactPopup}`, style: popupStyle, children: [jsxRuntime.jsxs("div", { className: compactStyles.calendarWrapper, children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "single", selected: selectedDate, onSelect: handleDaySelect, defaultMonth: selectedDate, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
7980
|
+
today: new Date(),
|
|
7981
|
+
}, modifiersClassNames: {
|
|
7982
|
+
today: "rdp-day-today",
|
|
7983
|
+
} }), showTodayButton && (jsxRuntime.jsx("footer", { className: "cw-flex-row cw-align-center-center", children: jsxRuntime.jsx(CwButton, { type: "button", variant: "outline", icon: "check-big", onClick: handleNowClick, text: nowLabel }) }))] }), jsxRuntime.jsxs("div", { className: compactStyles.timeWrapper, children: [jsxRuntime.jsxs("header", { children: [jsxRuntime.jsx(CwIcon, { iconId: "clock", size: "medium" }), jsxRuntime.jsx("span", { children: timeLabel })] }), jsxRuntime.jsx("div", { ref: timeListRef, className: `${timeStyles.timePickerList} ${compactStyles.compactTimeList}`, children: timeOptions.map((time) => {
|
|
7984
|
+
const isSelected = time === selectedTime;
|
|
7985
|
+
return (jsxRuntime.jsx("button", { type: "button", className: isSelected ? timeStyles.selected : "", onClick: () => handleTimeSelect(time), children: time }, time));
|
|
7986
|
+
}) })] })] }))] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) }));
|
|
7931
7987
|
}
|
|
7932
7988
|
|
|
7933
7989
|
/**
|
|
@@ -7952,14 +8008,11 @@ function resolveTwoDigitYear(twoDigitYear, currentYear) {
|
|
|
7952
8008
|
}
|
|
7953
8009
|
const parseDate = (dateString, formatStr) => {
|
|
7954
8010
|
try {
|
|
7955
|
-
if (dateString.length < 10) {
|
|
7956
|
-
return undefined;
|
|
7957
|
-
}
|
|
7958
8011
|
const cleanString = dateString.trim();
|
|
7959
8012
|
if (!cleanString)
|
|
7960
8013
|
return undefined;
|
|
7961
8014
|
const parts = cleanString.split(/[\/\-.]/);
|
|
7962
|
-
if (parts.length !== 3)
|
|
8015
|
+
if (parts.length !== 3 || parts.some(part => !/^\d{1,4}$/.test(part)))
|
|
7963
8016
|
return undefined;
|
|
7964
8017
|
let day;
|
|
7965
8018
|
let month;
|
|
@@ -7991,7 +8044,7 @@ const parseDate = (dateString, formatStr) => {
|
|
|
7991
8044
|
if (year < 100) {
|
|
7992
8045
|
year = resolveTwoDigitYear(year);
|
|
7993
8046
|
}
|
|
7994
|
-
return Temporal.PlainDate.from({ year, month, day });
|
|
8047
|
+
return Temporal.PlainDate.from({ year, month, day }, { overflow: "reject" });
|
|
7995
8048
|
}
|
|
7996
8049
|
catch {
|
|
7997
8050
|
return undefined;
|
|
@@ -8004,6 +8057,17 @@ const validate = (parsed, minDate, maxDate) => {
|
|
|
8004
8057
|
&& (!maxDate || Temporal.PlainDate.compare(parsed, maxDate) <= 0);
|
|
8005
8058
|
return parsed && isValid;
|
|
8006
8059
|
};
|
|
8060
|
+
/** Same keystroke rule as the Date-valued pickers: shorter text (5.5.2000) only commits on blur. */
|
|
8061
|
+
const TYPED_DATE_MIN_LENGTH = 10;
|
|
8062
|
+
/** What a keystroke in the date input emits: a valid in-range date, a clear on empty text, or nothing while typing. */
|
|
8063
|
+
function resolveTypedDate(text, displayFormat, minDate, maxDate) {
|
|
8064
|
+
if (text === "")
|
|
8065
|
+
return { emit: true, date: undefined };
|
|
8066
|
+
if (text.length < TYPED_DATE_MIN_LENGTH)
|
|
8067
|
+
return { emit: false };
|
|
8068
|
+
const parsed = parseDate(text, displayFormat);
|
|
8069
|
+
return parsed && validate(parsed, minDate, maxDate) ? { emit: true, date: parsed } : { emit: false };
|
|
8070
|
+
}
|
|
8007
8071
|
/** Temporal.PlainDate -> JS Date (for DayPicker interop) */
|
|
8008
8072
|
function plainDateToJsDate(pd) {
|
|
8009
8073
|
return new Date(pd.year, pd.month - 1, pd.day);
|
|
@@ -8025,7 +8089,7 @@ function formatPlainDate(pd, fmt) {
|
|
|
8025
8089
|
.replace("dd", String(pd.day).padStart(2, "0"));
|
|
8026
8090
|
}
|
|
8027
8091
|
|
|
8028
|
-
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: locale$1 = locale.enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, }) {
|
|
8092
|
+
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: locale$1 = locale.enGB, todayLabel = "Today", yearRangeStart, yearRangeEnd, feedback, ...dataAttributes }) {
|
|
8029
8093
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
8030
8094
|
// Initialize with the formatted value so the input is controlled from the first render
|
|
8031
8095
|
const [inputValue, setInputValue] = React.useState(() => value ? formatPlainDate(value, displayFormat) : "");
|
|
@@ -8050,14 +8114,17 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8050
8114
|
onClose: handleClose,
|
|
8051
8115
|
position: popupPosition,
|
|
8052
8116
|
});
|
|
8053
|
-
// Sync input value with prop value
|
|
8117
|
+
// Sync input value with prop value; not while focused, so text is never rewritten under the cursor (blur reformats)
|
|
8054
8118
|
React.useEffect(() => {
|
|
8055
8119
|
const currentStr = value?.toString();
|
|
8056
8120
|
const prevStr = prevValueRef.current?.toString();
|
|
8057
8121
|
if (currentStr !== prevStr || prevDisplayFormatRef.current !== displayFormat) {
|
|
8058
8122
|
prevValueRef.current = value;
|
|
8059
8123
|
prevDisplayFormatRef.current = displayFormat;
|
|
8060
|
-
|
|
8124
|
+
const isTyping = inputRef.current !== null && inputRef.current === document.activeElement;
|
|
8125
|
+
if (!isTyping) {
|
|
8126
|
+
setInputValue(formatInputValue(value));
|
|
8127
|
+
}
|
|
8061
8128
|
}
|
|
8062
8129
|
}, [value, displayFormat, formatInputValue]);
|
|
8063
8130
|
const handleDaySelect = React.useCallback((date) => {
|
|
@@ -8081,11 +8148,12 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8081
8148
|
}
|
|
8082
8149
|
}, [disabled]);
|
|
8083
8150
|
const handleInputChange = React.useCallback((e) => {
|
|
8084
|
-
const newValue = e.
|
|
8151
|
+
const newValue = e.currentTarget.value;
|
|
8085
8152
|
setInputValue(newValue);
|
|
8086
|
-
const
|
|
8087
|
-
|
|
8088
|
-
|
|
8153
|
+
const change = resolveTypedDate(newValue, displayFormat, minDate, maxDate);
|
|
8154
|
+
if (change.emit) {
|
|
8155
|
+
onChange(change.date);
|
|
8156
|
+
}
|
|
8089
8157
|
}, [displayFormat, minDate, maxDate, onChange]);
|
|
8090
8158
|
const handleInputBlur = React.useCallback(() => {
|
|
8091
8159
|
const trimmedValue = inputValue?.trim();
|
|
@@ -8115,9 +8183,10 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8115
8183
|
const isTodayValid = validate(today, minDate, maxDate);
|
|
8116
8184
|
if (isTodayValid) {
|
|
8117
8185
|
onChange(today);
|
|
8186
|
+
setInputValue(formatInputValue(today));
|
|
8118
8187
|
setIsOpen(false);
|
|
8119
8188
|
}
|
|
8120
|
-
}, [minDate, maxDate, onChange]);
|
|
8189
|
+
}, [formatInputValue, minDate, maxDate, onChange]);
|
|
8121
8190
|
// Derive start/end months for the year dropdown range, guarding against inverted yearRange props
|
|
8122
8191
|
const dropdownStartMonth = React.useMemo(() => {
|
|
8123
8192
|
const inferredStart = minDate ? minDate.year : Temporal.Now.plainDateISO().year - 10;
|
|
@@ -8142,7 +8211,7 @@ function CwDatePickerTemporal({ value, onChange, minDate, maxDate, disabledDates
|
|
|
8142
8211
|
const defaultMonthJsDate = defaultMonth
|
|
8143
8212
|
? new Date(defaultMonth.year, defaultMonth.month - 1, 1)
|
|
8144
8213
|
: selectedJsDate;
|
|
8145
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsxRuntime.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 }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "single", selected: selectedJsDate, defaultMonth: defaultMonthJsDate, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8214
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: styles$4.pickerWrapper, children: [jsxRuntime.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 }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: styles$4.pickerPopup, style: popupStyle, children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "single", selected: selectedJsDate, defaultMonth: defaultMonthJsDate, onSelect: handleDaySelect, disabled: disabledDays, numberOfMonths: numberOfMonths, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8146
8215
|
today: new Date(),
|
|
8147
8216
|
}, modifiersClassNames: {
|
|
8148
8217
|
today: "rdp-day-today",
|
|
@@ -8429,7 +8498,12 @@ function useCwDateTimePickerTemporal({ value, onChange, minDateTime, maxDateTime
|
|
|
8429
8498
|
};
|
|
8430
8499
|
}
|
|
8431
8500
|
|
|
8432
|
-
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: locale$1 = locale.enGB, }) {
|
|
8501
|
+
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: locale$1 = locale.enGB, feedback, ...dataAttributes }) {
|
|
8502
|
+
const feedbackMessages = feedback
|
|
8503
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
8504
|
+
: [];
|
|
8505
|
+
const feedbackId = React.useId();
|
|
8506
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
8433
8507
|
const picker = useCwDateTimePickerTemporal({
|
|
8434
8508
|
value,
|
|
8435
8509
|
onChange,
|
|
@@ -8438,7 +8512,7 @@ function CwDateTimePickerTemporal({ value, onChange, minDateTime, maxDateTime, d
|
|
|
8438
8512
|
minTime,
|
|
8439
8513
|
maxTime,
|
|
8440
8514
|
});
|
|
8441
|
-
return jsxRuntime.jsx("div", { className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsxRuntime.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$1 }), jsxRuntime.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 && (jsxRuntime.jsx(CwButton, { type: "button", variant: "outline", onClick: picker.selectNow, disabled: disabled, text: nowLabel }))] })] }) });
|
|
8515
|
+
return jsxRuntime.jsx("div", { ...dataAttributes, className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsxRuntime.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$1 }), jsxRuntime.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 && (jsxRuntime.jsx(CwButton, { type: "button", variant: "outline", onClick: picker.selectNow, disabled: disabled, text: nowLabel }))] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) });
|
|
8442
8516
|
}
|
|
8443
8517
|
|
|
8444
8518
|
// dateRangePresetsTemporal.ts
|
|
@@ -8581,8 +8655,14 @@ const PRESET_LIBRARY_TEMPORAL = {
|
|
|
8581
8655
|
*/
|
|
8582
8656
|
const getPresetsByKeysTemporal = (keys) => keys.map((key) => PRESET_LIBRARY_TEMPORAL[key]).filter((preset) => preset !== undefined);
|
|
8583
8657
|
|
|
8584
|
-
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: locale$1 = locale.enGB, yearRangeStart, yearRangeEnd, showPresets = false, presetKeys, customPresets, }) {
|
|
8658
|
+
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: locale$1 = locale.enGB, yearRangeStart, yearRangeEnd, showPresets = false, presetKeys, customPresets, feedback, ...dataAttributes }) {
|
|
8585
8659
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
8660
|
+
const feedbackMessages = feedback
|
|
8661
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
8662
|
+
: [];
|
|
8663
|
+
const feedbackId = React.useId();
|
|
8664
|
+
const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
|
|
8665
|
+
const describedBy = feedbackIds.join(" ") || undefined;
|
|
8586
8666
|
const [inputFromValue, setInputFromValue] = React.useState("");
|
|
8587
8667
|
const [inputToValue, setInputToValue] = React.useState("");
|
|
8588
8668
|
const [rangeErrorMessage, setRangeErrorMessage] = React.useState(null);
|
|
@@ -8742,7 +8822,7 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
|
|
|
8742
8822
|
const handleInputFromChange = React.useCallback((e) => {
|
|
8743
8823
|
const newValue = e.currentTarget.value;
|
|
8744
8824
|
setInputFromValue(newValue);
|
|
8745
|
-
const parsed = parseDate(newValue, displayFormat);
|
|
8825
|
+
const parsed = newValue.length >= TYPED_DATE_MIN_LENGTH ? parseDate(newValue, displayFormat) : undefined;
|
|
8746
8826
|
if (parsed) {
|
|
8747
8827
|
if (validate(parsed, minDate, maxDate) && validateRange(parsed, value?.to)) {
|
|
8748
8828
|
onChange({ from: parsed, to: value?.to });
|
|
@@ -8755,7 +8835,7 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
|
|
|
8755
8835
|
const handleInputToChange = React.useCallback((e) => {
|
|
8756
8836
|
const newValue = e.currentTarget.value;
|
|
8757
8837
|
setInputToValue(newValue);
|
|
8758
|
-
const parsed = parseDate(newValue, displayFormat);
|
|
8838
|
+
const parsed = newValue.length >= TYPED_DATE_MIN_LENGTH ? parseDate(newValue, displayFormat) : undefined;
|
|
8759
8839
|
if (parsed) {
|
|
8760
8840
|
if (validate(parsed, minDate, maxDate) && validateRange(value?.from, parsed)) {
|
|
8761
8841
|
onChange({ from: value?.from, to: parsed });
|
|
@@ -8884,11 +8964,11 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
|
|
|
8884
8964
|
const defaultMonthJsDate = defaultMonth
|
|
8885
8965
|
? new Date(defaultMonth.year, defaultMonth.month - 1, 1)
|
|
8886
8966
|
: (value?.from ? plainDateToJsDate(value.from) : undefined);
|
|
8887
|
-
return (jsxRuntime.jsx("div", { ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), jsxRuntime.jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxRuntime.jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsxRuntime.jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsxRuntime.jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonthJsDate, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8967
|
+
return (jsxRuntime.jsx("div", { ...dataAttributes, ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: styles$4.value, children: [jsxRuntime.jsxs("div", { ref: wrapperRef, className: rangeStyles.rangeWrapper, children: [jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), jsxRuntime.jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxRuntime.jsxs("div", { className: styles$4.pickerWrapper, children: [jsxRuntime.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' }), jsxRuntime.jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsxRuntime.jsx(CwIcon, { iconId: "calendar" })) })] }), renderPopup(jsxRuntime.jsxs("div", { ref: popupRef, className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, style: popupStyle, children: [jsxRuntime.jsxs("div", { className: rangeStyles.rangeCalendarRow, children: [showPresets && presetsToRender.length > 0 && (jsxRuntime.jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsxRuntime.jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, numberOfMonths: numberOfMonths, defaultMonth: defaultMonthJsDate, locale: locale$1, captionLayout: "dropdown", startMonth: dropdownStartMonth, endMonth: dropdownEndMonth, modifiers: {
|
|
8968
|
+
today: new Date(),
|
|
8969
|
+
}, modifiersClassNames: {
|
|
8970
|
+
today: "rdp-day-today",
|
|
8971
|
+
} })] }), jsxRuntime.jsx("div", { role: "alert", "aria-live": "polite", className: rangeStyles.rangeError, children: rangeErrorMessage })] }))] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-feedback", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] })] }) }));
|
|
8892
8972
|
}
|
|
8893
8973
|
|
|
8894
8974
|
function dateFromPercentage(startDate, visibleDays, percentage) {
|
|
@@ -9031,7 +9111,7 @@ class OnClickContextMenu {
|
|
|
9031
9111
|
}
|
|
9032
9112
|
}
|
|
9033
9113
|
|
|
9034
|
-
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"};
|
|
9114
|
+
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"};
|
|
9035
9115
|
|
|
9036
9116
|
const getNow$1 = (isUtc) => {
|
|
9037
9117
|
let now = new Date();
|
|
@@ -9041,18 +9121,16 @@ const getNow$1 = (isUtc) => {
|
|
|
9041
9121
|
return now;
|
|
9042
9122
|
};
|
|
9043
9123
|
const TimeLine = ({ left, top = "0px", height, color, width = "2px", zIndexNumber = 0, isHeader, isUtc = false }) => {
|
|
9044
|
-
const [currentTime, setCurrentTime] = React.useState(getNow$1(isUtc));
|
|
9124
|
+
const [currentTime, setCurrentTime] = React.useState(() => getNow$1(isUtc));
|
|
9045
9125
|
React.useEffect(() => {
|
|
9126
|
+
if (!isHeader) {
|
|
9127
|
+
return;
|
|
9128
|
+
}
|
|
9046
9129
|
const interval = setInterval(() => {
|
|
9047
9130
|
setCurrentTime(getNow$1(isUtc));
|
|
9048
|
-
}, 60000);
|
|
9131
|
+
}, 60000);
|
|
9049
9132
|
return () => clearInterval(interval);
|
|
9050
|
-
}, [isUtc]);
|
|
9051
|
-
const timeString = currentTime.toLocaleTimeString([], {
|
|
9052
|
-
hour: '2-digit',
|
|
9053
|
-
minute: '2-digit',
|
|
9054
|
-
hour12: false
|
|
9055
|
-
});
|
|
9133
|
+
}, [isUtc, isHeader]);
|
|
9056
9134
|
return (jsxRuntime.jsx("div", { style: {
|
|
9057
9135
|
position: "absolute",
|
|
9058
9136
|
top: top,
|
|
@@ -9064,7 +9142,11 @@ const TimeLine = ({ left, top = "0px", height, color, width = "2px", zIndexNumbe
|
|
|
9064
9142
|
zIndex: zIndexNumber,
|
|
9065
9143
|
}, className: styles$3["scheduler-timeline-now"], children: isHeader && (jsxRuntime.jsx("span", { style: {
|
|
9066
9144
|
color: color,
|
|
9067
|
-
}, className: styles$3["scheduler-timeline-label"], children:
|
|
9145
|
+
}, className: styles$3["scheduler-timeline-label"], children: currentTime.toLocaleTimeString([], {
|
|
9146
|
+
hour: '2-digit',
|
|
9147
|
+
minute: '2-digit',
|
|
9148
|
+
hour12: false
|
|
9149
|
+
}) })) }));
|
|
9068
9150
|
};
|
|
9069
9151
|
|
|
9070
9152
|
function isToday(startDate, endDate) {
|
|
@@ -9091,7 +9173,7 @@ const SchedulerHeaderDivision = ({ topDivisions, bottomDivisions, classification
|
|
|
9091
9173
|
};
|
|
9092
9174
|
|
|
9093
9175
|
const HeaderTitle = ({ title, dividerText, width }) => {
|
|
9094
|
-
return (jsxRuntime.jsxs("div", { className: styles$3["scheduler-header-title"], style: { width: width }, children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx("
|
|
9176
|
+
return (jsxRuntime.jsxs("div", { className: styles$3["scheduler-header-title"], style: { width: width }, children: [jsxRuntime.jsx("div", { className: styles$3["title-cell"], children: jsxRuntime.jsx("span", { className: styles$3.title, children: title }) }), jsxRuntime.jsx("div", { children: jsxRuntime.jsx("span", { children: dividerText }) })] }));
|
|
9095
9177
|
};
|
|
9096
9178
|
|
|
9097
9179
|
const SchedulerHeader = ({ content, divisions, visibleDays, selectedDate, width, onEvent, timeLinePercentage, isUtc }) => {
|
|
@@ -9129,7 +9211,7 @@ function getStartEnd(day) {
|
|
|
9129
9211
|
};
|
|
9130
9212
|
}
|
|
9131
9213
|
|
|
9132
|
-
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"};
|
|
9214
|
+
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"};
|
|
9133
9215
|
|
|
9134
9216
|
const BackgroundEvent = ({ value, heightRem }) => {
|
|
9135
9217
|
const backColor = getHSLColor(value.color, value.alpha ?? 0.5);
|
|
@@ -9259,7 +9341,7 @@ const eventsCollide = (event1, event2) => {
|
|
|
9259
9341
|
return eventInsideOther || eventCollideStart || eventCollideEnd;
|
|
9260
9342
|
};
|
|
9261
9343
|
// Function to separate events into non-colliding rows
|
|
9262
|
-
const
|
|
9344
|
+
const computeInnerRows = (events) => {
|
|
9263
9345
|
const sortedEvents = [...events].sort((a, b) => {
|
|
9264
9346
|
const aOrder = a.order ?? Number.MAX_SAFE_INTEGER;
|
|
9265
9347
|
const bOrder = b.order ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -9284,15 +9366,44 @@ const separateEventsToInnerRows = (events) => {
|
|
|
9284
9366
|
}
|
|
9285
9367
|
return rows;
|
|
9286
9368
|
};
|
|
9369
|
+
// The scheduler asks for the same row's lanes several times per repaint (total height, virtual-list
|
|
9370
|
+
// item size, row render). Row event arrays keep their identity until their events change, so the
|
|
9371
|
+
// array itself is the cache key.
|
|
9372
|
+
const innerRowsCache = new WeakMap();
|
|
9373
|
+
const separateEventsToInnerRows = (events) => {
|
|
9374
|
+
const cached = innerRowsCache.get(events);
|
|
9375
|
+
if (cached) {
|
|
9376
|
+
return cached;
|
|
9377
|
+
}
|
|
9378
|
+
const rows = computeInnerRows(events);
|
|
9379
|
+
innerRowsCache.set(events, rows);
|
|
9380
|
+
return rows;
|
|
9381
|
+
};
|
|
9287
9382
|
|
|
9288
9383
|
const DivisionLine = ({ left, top = "0px", height, isDayBoundary }) => {
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9384
|
+
return (jsxRuntime.jsx("div", { style: {
|
|
9385
|
+
position: "absolute",
|
|
9386
|
+
top: top,
|
|
9387
|
+
height: height,
|
|
9388
|
+
left: left + "%",
|
|
9389
|
+
width: isDayBoundary ? "2px" : "1px",
|
|
9390
|
+
background: isDayBoundary ? "rgba(255,255,255,1)" : "rgba(255,255,255,0.8)",
|
|
9391
|
+
pointerEvents: "none",
|
|
9392
|
+
zIndex: 0,
|
|
9393
|
+
} }));
|
|
9292
9394
|
};
|
|
9293
9395
|
|
|
9294
9396
|
const WeekEndLine = ({ left, top = "0px", height, widthPercentage }) => {
|
|
9295
|
-
return (jsxRuntime.jsx(
|
|
9397
|
+
return (jsxRuntime.jsx("div", { style: {
|
|
9398
|
+
position: "absolute",
|
|
9399
|
+
top: top,
|
|
9400
|
+
height: height,
|
|
9401
|
+
left: left + "%",
|
|
9402
|
+
width: widthPercentage + "%",
|
|
9403
|
+
background: "rgba(0,0,0,0.05)",
|
|
9404
|
+
pointerEvents: "none",
|
|
9405
|
+
zIndex: 0,
|
|
9406
|
+
} }));
|
|
9296
9407
|
};
|
|
9297
9408
|
|
|
9298
9409
|
var styles$1 = {"scheduler-row-header":"scheduler-row-module__scheduler-row-header__S-iv4"};
|
|
@@ -9418,16 +9529,7 @@ const SchedulerEvent = ({ value, heightRem, onEvent, maxEventHeightRem }) => {
|
|
|
9418
9529
|
flex: 1,
|
|
9419
9530
|
alignItems: "center",
|
|
9420
9531
|
width: "100%",
|
|
9421
|
-
}, children: value.rectangleColors && value.rectangleColors.length > 0 ? (jsxRuntime.jsx("div", { style: {
|
|
9422
|
-
display: "flex",
|
|
9423
|
-
width: "100%",
|
|
9424
|
-
}, children: value.rectangleColors.map((item, i) => (jsxRuntime.jsx("div", { className: "cwellt_rectangle_indicator", style: {
|
|
9425
|
-
backgroundColor: item,
|
|
9426
|
-
flex: 1,
|
|
9427
|
-
height: "8px",
|
|
9428
|
-
margin: 0,
|
|
9429
|
-
padding: 0,
|
|
9430
|
-
} }, value.id + "_" + i))) })) : (value.name) })] }), value.isResizable && (jsxRuntime.jsx(EventSideDrag, { heightRem: effectiveHeight * 0.7, onStartEvent: () => {
|
|
9532
|
+
}, children: value.rectangleColors && value.rectangleColors.length > 0 ? (jsxRuntime.jsx("div", { className: styles$2["color-bars"], children: value.rectangleColors.map((item, i) => (jsxRuntime.jsx("div", { style: { backgroundColor: item } }, value.id + "_" + i))) })) : (value.name) })] }), value.isResizable && (jsxRuntime.jsx(EventSideDrag, { heightRem: effectiveHeight * 0.7, onStartEvent: () => {
|
|
9431
9533
|
onEvent(new OnRightDragStart(value.id));
|
|
9432
9534
|
} }))] }), value.primaryTimeMarkerColor && (jsxRuntime.jsx("div", { className: styles$2["time-marker"], style: {
|
|
9433
9535
|
backgroundColor: value.primaryTimeMarkerColor,
|
|
@@ -9825,6 +9927,8 @@ const groupByRowIdStable = (items, prev) => {
|
|
|
9825
9927
|
const Scheduler = (props) => {
|
|
9826
9928
|
const { header: headerContent, id, events: eventsState, backgroundEvents, indicatorRows: allIndicatorRows = [], contextMenuItems, EventComp, RowTitleComp, orderCategories = ["title"], useOrderCategory, onEvent, groupRowColors, rowHeaderWidth = 180, rowHeightRem = 1.75, maxEventHeightRem, } = props;
|
|
9827
9929
|
const BackgroundEventComp = props.BackgroundEventComp ?? BackgroundEvent;
|
|
9930
|
+
// Picked by prefix: a rest spread would also put every non-destructured prop on the DOM.
|
|
9931
|
+
const dataAttributes = Object.fromEntries(Object.entries(props).filter(([key]) => key.startsWith("data-")));
|
|
9828
9932
|
const [constraintElement, setConstraintElement] = React.useState(null);
|
|
9829
9933
|
const rows = useOrderCategory === false
|
|
9830
9934
|
? props.rows
|
|
@@ -9833,9 +9937,10 @@ const Scheduler = (props) => {
|
|
|
9833
9937
|
// const rowHeaderWidth = "180px";
|
|
9834
9938
|
const { selectedDate, visibleDays, isUtc, isHeaderVisible, visibleRows: stateVisibleRows } = props.state;
|
|
9835
9939
|
const events = React.useMemo(() => filterVisibleEvents(eventsState, selectedDate, visibleDays), [eventsState, selectedDate, visibleDays]);
|
|
9940
|
+
// The virtual list caches row sizes: anything getItemSize depends on must reset them.
|
|
9836
9941
|
React.useEffect(() => {
|
|
9837
9942
|
instanceRef.current?.resetAfterIndex(0);
|
|
9838
|
-
}, [orderCategories, props.rows.length, events, allIndicatorRows]);
|
|
9943
|
+
}, [orderCategories, props.rows.length, events, allIndicatorRows, rowHeightRem]);
|
|
9839
9944
|
// Bucket events / backgroundEvents / indicatorRows by rowId once per render
|
|
9840
9945
|
// instead of running events.filter() per row inside the row renderer.
|
|
9841
9946
|
// Reuse previous bucket arrays when their contents are unchanged so the
|
|
@@ -9950,7 +10055,7 @@ const Scheduler = (props) => {
|
|
|
9950
10055
|
return rowsNumber * effectiveRowHeight * pixelsInRem + indicatorPixels;
|
|
9951
10056
|
}, [rows, eventsByRow, indicatorRowsByRow, rowHeightRem]);
|
|
9952
10057
|
// Render
|
|
9953
|
-
return (jsxRuntime.jsx(TooltipConstraintContext.Provider, { value: constraintElement, children: jsxRuntime.jsxs("div", { ref: setConstraintElement, id: id, style: {
|
|
10058
|
+
return (jsxRuntime.jsx(TooltipConstraintContext.Provider, { value: constraintElement, children: jsxRuntime.jsxs("div", { ...dataAttributes, ref: setConstraintElement, id: id, style: {
|
|
9954
10059
|
position: "relative",
|
|
9955
10060
|
height: `${schedulerContentHeight + 4}rem`,
|
|
9956
10061
|
overflowY: "auto",
|