@donotdev/components 0.1.1 → 0.1.43
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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/dist/CodeContent-JLL6BLG2.js +2 -0
- package/dist/advanced/Code/CodeContent.d.ts.map +1 -1
- package/dist/advanced/Code/CodeContent.js +2 -3
- package/dist/advanced/ImageGallery/ImageGallery.d.ts +7 -1
- package/dist/advanced/ImageGallery/ImageGallery.d.ts.map +1 -1
- package/dist/advanced/ImageGallery/ImageGallery.js +52 -3
- package/dist/advanced/JsonViewer/JsonViewer.js +11 -11
- package/dist/advanced/Reveal/Reveal.d.ts.map +1 -1
- package/dist/advanced/Reveal/Reveal.js +4 -4
- package/dist/advanced/Roadmap/RoadmapContent.d.ts.map +1 -1
- package/dist/advanced/Roadmap/RoadmapContent.js +2 -2
- package/dist/atomic/Alert/index.d.ts.map +1 -1
- package/dist/atomic/Alert/index.js +1 -1
- package/dist/atomic/Button/index.d.ts +2 -2
- package/dist/atomic/Button/index.js +1 -1
- package/dist/atomic/CallToAction/index.d.ts +2 -0
- package/dist/atomic/CallToAction/index.d.ts.map +1 -1
- package/dist/atomic/CallToAction/index.js +2 -2
- package/dist/atomic/Card/index.d.ts +113 -2
- package/dist/atomic/Card/index.d.ts.map +1 -1
- package/dist/atomic/Card/index.js +88 -9
- package/dist/atomic/Checkbox/index.d.ts +2 -2
- package/dist/atomic/Checkbox/index.d.ts.map +1 -1
- package/dist/atomic/Checkbox/index.js +6 -4
- package/dist/atomic/ColorPicker/index.d.ts.map +1 -1
- package/dist/atomic/ColorPicker/index.js +7 -7
- package/dist/atomic/Combobox/index.d.ts +2 -0
- package/dist/atomic/Combobox/index.d.ts.map +1 -1
- package/dist/atomic/Combobox/index.js +36 -21
- package/dist/atomic/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/atomic/CopyToClipboard/index.js +3 -3
- package/dist/atomic/DatePicker/index.d.ts +54 -0
- package/dist/atomic/DatePicker/index.d.ts.map +1 -0
- package/dist/atomic/DatePicker/index.js +377 -0
- package/dist/atomic/DateTimePicker/index.d.ts +54 -0
- package/dist/atomic/DateTimePicker/index.d.ts.map +1 -0
- package/dist/atomic/DateTimePicker/index.js +460 -0
- package/dist/atomic/FileButton/index.d.ts.map +1 -1
- package/dist/atomic/FileButton/index.js +3 -3
- package/dist/atomic/HeroSection/index.d.ts.map +1 -1
- package/dist/atomic/HeroSection/index.js +5 -1
- package/dist/atomic/Icons/Icon.d.ts.map +1 -1
- package/dist/atomic/Icons/Icon.js +3 -11
- package/dist/atomic/Icons/Partner/SupabaseIcon.d.ts.map +1 -1
- package/dist/atomic/Label/FloatingLabel.d.ts.map +1 -1
- package/dist/atomic/Label/FloatingLabel.js +2 -5
- package/dist/atomic/Label/index.d.ts.map +1 -1
- package/dist/atomic/Label/index.js +1 -5
- package/dist/atomic/Pagination/index.js +3 -3
- package/dist/atomic/PinInput/index.d.ts +92 -0
- package/dist/atomic/PinInput/index.d.ts.map +1 -0
- package/dist/atomic/PinInput/index.js +156 -0
- package/dist/atomic/RangeInput/index.d.ts.map +1 -1
- package/dist/atomic/RangeInput/index.js +1 -2
- package/dist/atomic/Rating/index.d.ts.map +1 -1
- package/dist/atomic/Rating/index.js +5 -5
- package/dist/atomic/Stepper/index.d.ts +1 -1
- package/dist/atomic/Table/index.d.ts +35 -1
- package/dist/atomic/Table/index.d.ts.map +1 -1
- package/dist/atomic/Table/index.js +27 -0
- package/dist/atomic/Tooltip/index.js +5 -5
- package/dist/atomic/TreeView/index.js +1 -1
- package/dist/atomic/index.d.ts +6 -0
- package/dist/atomic/index.d.ts.map +1 -1
- package/dist/atomic/index.js +3 -0
- package/dist/chunk-6UB4NXNR.js +3 -0
- package/dist/index.js +5 -5
- package/dist/styles/index.css +763 -104
- package/dist/symbol-index.json +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/date.d.ts +46 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +130 -0
- package/dist/utils/imageRetry.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/guidelines/API_REFERENCE.md +0 -0
- package/guidelines/COMPONENTS.md +0 -0
- package/package.json +1 -1
- package/dist/CodeContent-JP5FNGFV.js +0 -2
- package/dist/chunk-ZCLMEZ46.js +0 -3
|
@@ -72,6 +72,33 @@ export function renderCardHeader(icon, title, subtitle) {
|
|
|
72
72
|
return null;
|
|
73
73
|
return (_jsxs("div", { className: "dndev-card-header", children: [icon && title ? (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx(Icon, { icon: icon, ariaHidden: true }), _jsx(Text, { as: "div", level: "h3", className: "dndev-card-title", children: title })] })) : title ? (_jsx(Text, { as: "div", level: "h3", className: "dndev-card-title", children: title })) : icon ? (_jsx(Icon, { icon: icon, ariaHidden: true })) : null, subtitle && (_jsx(Text, { as: "div", level: "h4", className: "dndev-card-subtitle", children: subtitle }))] }));
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Renders the card cover region with optional overlay.
|
|
77
|
+
*
|
|
78
|
+
* Architecture: cover is a relative-positioned header region that sits flush
|
|
79
|
+
* to the card's rounded corners (no negative-margin hack). When the card has
|
|
80
|
+
* body content, the cover's height comes from `coverAspect`. When the card is
|
|
81
|
+
* cover-only (no body), the cover stretches to fill the card — the card
|
|
82
|
+
* itself picks up `coverAspect` via its container.
|
|
83
|
+
*
|
|
84
|
+
* - `string` cover → renders a safe `<img>` with `loading="lazy"`,
|
|
85
|
+
* `decoding="async"`, `referrerpolicy="no-referrer"`, `alt=""` (decorative).
|
|
86
|
+
* - `ReactNode` cover → passthrough; child `<img>`/`<video>` auto-fill via CSS.
|
|
87
|
+
*
|
|
88
|
+
* Overlay is absolutely positioned over the cover AND over the body slot,
|
|
89
|
+
* anchored by `overlayPosition` with a theme-token inset.
|
|
90
|
+
*/
|
|
91
|
+
export function renderCardCover(cover, coverAspect, hasBody) {
|
|
92
|
+
if (!cover)
|
|
93
|
+
return null;
|
|
94
|
+
const isStringCover = typeof cover === 'string';
|
|
95
|
+
// When body is present the cover owns the top region sized by coverAspect.
|
|
96
|
+
// When body is absent the cover fills the card (card owns the aspect-ratio).
|
|
97
|
+
const coverStyle = hasBody
|
|
98
|
+
? { aspectRatio: coverAspect ?? '4 / 5' }
|
|
99
|
+
: {};
|
|
100
|
+
return (_jsx("div", { className: "dndev-card-cover", "data-has-body": hasBody ? 'true' : undefined, style: coverStyle, children: isStringCover ? (_jsx("img", { src: cover, alt: "", loading: "lazy", decoding: "async", referrerPolicy: "no-referrer" })) : (_jsx("div", { className: "dndev-card-cover-media", children: cover })) }));
|
|
101
|
+
}
|
|
75
102
|
/**
|
|
76
103
|
* Card variant constants - re-exported from shared SURFACE_VARIANT
|
|
77
104
|
* Matches .dndev-surface CSS class
|
|
@@ -84,6 +111,7 @@ export const CARD_VARIANT = SURFACE_VARIANT;
|
|
|
84
111
|
* @component
|
|
85
112
|
* @example
|
|
86
113
|
* ```tsx
|
|
114
|
+
* // Classic card: icon + title + subtitle + body
|
|
87
115
|
* <Card
|
|
88
116
|
* title="Notifications"
|
|
89
117
|
* subtitle="Manage your preferences"
|
|
@@ -93,13 +121,52 @@ export const CARD_VARIANT = SURFACE_VARIANT;
|
|
|
93
121
|
* <p>Content goes here</p>
|
|
94
122
|
* </Card>
|
|
95
123
|
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* // Editorial tile: full-bleed cover + bottom-left overlay, no body.
|
|
128
|
+
* // Body slot collapses — card is pure photo with layered text.
|
|
129
|
+
* <Card
|
|
130
|
+
* cover="/villa.jpg"
|
|
131
|
+
* coverAspect="4 / 5"
|
|
132
|
+
* overlay={
|
|
133
|
+
* <Stack gap="none">
|
|
134
|
+
* <Text variant="accent">Settle In</Text>
|
|
135
|
+
* <Text level="h2">Villa Arrival</Text>
|
|
136
|
+
* </Stack>
|
|
137
|
+
* }
|
|
138
|
+
* overlayPosition="bottom-left"
|
|
139
|
+
* clickable
|
|
140
|
+
* onClick={() => navigate('/services?occasion=villa-arrival')}
|
|
141
|
+
* />
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* // Product card: cover as header, body below with solid surface.
|
|
147
|
+
* <Card
|
|
148
|
+
* cover="/product.jpg"
|
|
149
|
+
* coverAspect="16 / 9"
|
|
150
|
+
* title="Sunset Cruise"
|
|
151
|
+
* subtitle="From €450 / person"
|
|
152
|
+
* bodyBackground="solid"
|
|
153
|
+
* clickable
|
|
154
|
+
* onClick={() => navigate('/services/sunset-cruise')}
|
|
155
|
+
* />
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
96
158
|
* @param {CardProps} props - The props for the card
|
|
97
159
|
* @returns {JSX.Element} The rendered card
|
|
98
160
|
*/
|
|
99
|
-
const Card = ({ className, variant, asChild = false, icon, title, subtitle, content, footer, children, tooltip, onClick, clickable, elevated, style, ref, ...props }) => {
|
|
161
|
+
const Card = ({ className, variant, asChild = false, icon, title, subtitle, content, footer, children, tooltip, onClick, clickable, elevated, cover, coverAspect, overlay, overlayPosition = 'top-left', fullOverlay, bodyBackground = 'transparent', style, ref, ...props }) => {
|
|
100
162
|
const Comp = asChild ? Slot : 'div';
|
|
101
163
|
const variantAttrs = getVariantDataAttrs({ variant });
|
|
102
164
|
const isClickable = clickable !== undefined ? clickable : !!onClick;
|
|
165
|
+
const header = renderCardHeader(icon, title, subtitle);
|
|
166
|
+
const contentNode = renderCardContent(content);
|
|
167
|
+
const hasContent = Boolean(contentNode || children);
|
|
168
|
+
const hasBody = Boolean(header || hasContent || footer);
|
|
169
|
+
const coverNode = renderCardCover(cover, coverAspect, hasBody);
|
|
103
170
|
const cardAttrs = {
|
|
104
171
|
...variantAttrs,
|
|
105
172
|
'data-role': 'card',
|
|
@@ -107,14 +174,26 @@ const Card = ({ className, variant, asChild = false, icon, title, subtitle, cont
|
|
|
107
174
|
'data-elevated': elevated ? 'true' : 'false',
|
|
108
175
|
}),
|
|
109
176
|
...(isClickable && { 'data-clickable': 'true' }),
|
|
177
|
+
...(cover !== undefined && { 'data-has-cover': 'true' }),
|
|
178
|
+
...(cover !== undefined && !hasBody && { 'data-cover-only': 'true' }),
|
|
179
|
+
...(overlay !== undefined && { 'data-overlay-position': overlayPosition }),
|
|
180
|
+
...(fullOverlay !== undefined && { 'data-has-full-overlay': 'true' }),
|
|
110
181
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
182
|
+
// When cover-only, the card itself owns the aspectRatio so the cover fills it.
|
|
183
|
+
// Drop `height: 100%` in cover-only mode so aspectRatio drives height from width.
|
|
184
|
+
const isCoverOnly = Boolean(cover) && !hasBody;
|
|
185
|
+
const rootStyle = {
|
|
186
|
+
width: '100%',
|
|
187
|
+
...(isCoverOnly
|
|
188
|
+
? { aspectRatio: coverAspect ?? '4 / 5' }
|
|
189
|
+
: { height: '100%' }),
|
|
190
|
+
...style,
|
|
191
|
+
};
|
|
192
|
+
// asChild: Slot requires exactly one child (React.Children.only).
|
|
193
|
+
// Skip internal structure — just merge Card props onto the single child.
|
|
194
|
+
if (asChild) {
|
|
195
|
+
return (_jsx(Comp, { ref: ref, className: cn('dndev-card', surfaceVariants({ variant }), className), style: rootStyle, ...cardAttrs, onClick: onClick, title: tooltip, ...props, children: children }));
|
|
196
|
+
}
|
|
197
|
+
return (_jsxs(Comp, { ref: ref, className: cn('dndev-card', surfaceVariants({ variant }), className), style: rootStyle, ...cardAttrs, onClick: onClick, title: tooltip, ...props, children: [coverNode, fullOverlay && (_jsx("div", { className: "dndev-card-full-overlay", children: fullOverlay })), overlay && _jsx("div", { className: "dndev-card-overlay", children: overlay }), hasBody && (_jsxs("div", { className: "dndev-card-body", "data-body-background": bodyBackground, children: [header, hasContent && (_jsxs("div", { className: "dndev-card-content", children: [contentNode, children] })), footer && _jsx("div", { className: "dndev-card-footer", children: footer })] }))] }));
|
|
119
198
|
};
|
|
120
199
|
export default Card;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CheckboxPrimitive, type CheckboxProps as CheckboxPrimitiveProps } from './CheckboxPrimitive';
|
|
2
2
|
import { CONTROL_VARIANT, type ControlVariant } from '../../utils/constants';
|
|
3
|
-
import type
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
4
4
|
import './Checkbox.css';
|
|
5
5
|
/** Props for the Checkbox component. */
|
|
6
6
|
export interface CheckboxProps extends CheckboxPrimitiveProps {
|
|
@@ -33,7 +33,7 @@ export interface CheckboxProps extends CheckboxPrimitiveProps {
|
|
|
33
33
|
* @param {CheckboxProps} props - The props for the checkbox
|
|
34
34
|
* @returns {JSX.Element} The rendered checkbox
|
|
35
35
|
*/
|
|
36
|
-
declare const Checkbox: ({ className, variant, label, required, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
declare const Checkbox: ({ className, variant, label, required, id, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
export default Checkbox;
|
|
38
38
|
export { CheckboxPrimitive, CONTROL_VARIANT as CHECKBOX_VARIANT };
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Checkbox/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EACjB,KAAK,aAAa,IAAI,sBAAsB,EAC7C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK7E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Checkbox/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EACjB,KAAK,aAAa,IAAI,sBAAsB,EAC7C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK7E,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,gBAAgB,CAAC;AAExB,wCAAwC;AACxC,MAAM,WAAW,aAAc,SAAQ,sBAAsB;IAC3D,6BAA6B;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,wEAAwE;IACxE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAoBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,QAAQ,GAAI,uDAOf,aAAa,4CA0Bf,CAAC;AAEF,eAAe,QAAQ,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -14,6 +14,7 @@ import { CONTROL_VARIANT } from '../../utils/constants';
|
|
|
14
14
|
import { cn, getVariantDataAttrs } from '../../utils/helpers';
|
|
15
15
|
import Label from '../Label';
|
|
16
16
|
import Stack from '../Stack';
|
|
17
|
+
import { useId } from 'react';
|
|
17
18
|
import './Checkbox.css';
|
|
18
19
|
const checkboxVariants = cva('dndev-control', {
|
|
19
20
|
variants: {
|
|
@@ -54,12 +55,13 @@ const checkboxVariants = cva('dndev-control', {
|
|
|
54
55
|
* @param {CheckboxProps} props - The props for the checkbox
|
|
55
56
|
* @returns {JSX.Element} The rendered checkbox
|
|
56
57
|
*/
|
|
57
|
-
const Checkbox = ({ className, variant, label, required, ...props }) => {
|
|
58
|
+
const Checkbox = ({ className, variant, label, required, id, ...props }) => {
|
|
59
|
+
const generatedId = useId();
|
|
60
|
+
const checkboxId = id ?? generatedId;
|
|
58
61
|
const variantAttrs = getVariantDataAttrs({ variant });
|
|
59
|
-
const checkboxElement = (_jsx(CheckboxPrimitive, { className: cn(checkboxVariants({ variant }), className), ...variantAttrs, ...props }));
|
|
60
|
-
// If label is provided, compose with Label and Stack
|
|
62
|
+
const checkboxElement = (_jsx(CheckboxPrimitive, { className: cn(checkboxVariants({ variant }), className), id: checkboxId, ...variantAttrs, ...props }));
|
|
61
63
|
if (label) {
|
|
62
|
-
return (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [checkboxElement, _jsx(Label, { required: required, children: label })] }));
|
|
64
|
+
return (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [checkboxElement, _jsx(Label, { htmlFor: checkboxId, required: required, children: label })] }));
|
|
63
65
|
}
|
|
64
66
|
return checkboxElement;
|
|
65
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/ColorPicker/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,OAAO,CAAC;AAE3D,OAAO,mBAAmB,CAAC;AAE3B,4BAA4B;AAC5B,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAyE7E,2CAA2C;AAC3C,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,GAAG,cAAc,CAC5B;IACC,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,CAAC,EA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AK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,QAAA,MAAM,WAAW,6GAyJhB,CAAC;AAIF,eAAe,WAAW,CAAC"}
|
|
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
* @since 0.0.1
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
|
-
import { forwardRef,
|
|
12
|
+
import { forwardRef, useRef, useState } from 'react';
|
|
13
13
|
import { cn } from '../../utils/helpers';
|
|
14
14
|
import './ColorPicker.css';
|
|
15
15
|
export const COLOR_PRESETS = {
|
|
@@ -134,15 +134,15 @@ const ColorPicker = forwardRef(function ColorPicker({ value, defaultValue = '#00
|
|
|
134
134
|
const currentValue = isControlled ? value : internalValue;
|
|
135
135
|
const swatchesRef = useRef(null);
|
|
136
136
|
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
137
|
-
const resolvedSwatches =
|
|
137
|
+
const resolvedSwatches = typeof swatches === 'string'
|
|
138
138
|
? (PRESET_MAP[swatches] ?? BASIC_SWATCHES)
|
|
139
|
-
: swatches
|
|
140
|
-
const selectColor =
|
|
139
|
+
: swatches;
|
|
140
|
+
const selectColor = (hex) => {
|
|
141
141
|
if (!isControlled)
|
|
142
142
|
setInternalValue(hex);
|
|
143
143
|
onChange?.(hex);
|
|
144
|
-
}
|
|
145
|
-
const handleSwatchKeyDown =
|
|
144
|
+
};
|
|
145
|
+
const handleSwatchKeyDown = (e) => {
|
|
146
146
|
const total = resolvedSwatches.length;
|
|
147
147
|
if (total === 0)
|
|
148
148
|
return;
|
|
@@ -182,7 +182,7 @@ const ColorPicker = forwardRef(function ColorPicker({ value, defaultValue = '#00
|
|
|
182
182
|
// Focus the swatch button
|
|
183
183
|
const buttons = swatchesRef.current?.querySelectorAll('[role="radio"]');
|
|
184
184
|
buttons?.[nextIndex]?.focus();
|
|
185
|
-
}
|
|
185
|
+
};
|
|
186
186
|
// Determine which swatch is "active" for roving tabindex
|
|
187
187
|
const activeIndex = resolvedSwatches.findIndex((s) => s.value.toLowerCase() === currentValue?.toLowerCase());
|
|
188
188
|
const tabbableIndex = focusedIndex >= 0 ? focusedIndex : Math.max(activeIndex, 0);
|
|
@@ -7,6 +7,8 @@ export interface ComboboxOption {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
description?: string;
|
|
9
9
|
content?: React.ReactNode;
|
|
10
|
+
/** Faceted count displayed as muted text after the label */
|
|
11
|
+
count?: number;
|
|
10
12
|
}
|
|
11
13
|
/** Props for the Combobox component -- searchable select with single/multi selection support. */
|
|
12
14
|
export interface ComboboxProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Combobox/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAO7E,OAAO,gBAAgB,CAAC;AAExB,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EA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Q,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iFAAiF;IACjF,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AAkBD,QAAA,MAAM,QAAQ,GAAI,kOAoBf,aAAa,4CAmef,CAAC;AAEF,eAAe,QAAQ,CAAC;AACxB,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC;AAC/C,YAAY,EAAE,cAAc,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -11,18 +11,20 @@ import Spinner from '../Spinner';
|
|
|
11
11
|
import './Combobox.css';
|
|
12
12
|
/**
|
|
13
13
|
* Compute trailing padding for the input based on the number of trailing items.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* All inline controls (clear, create, chevron) are full touch targets
|
|
15
|
+
* (`--touch-target`, 48px) via `.dndev-inline-action-btn`. Spinner matches
|
|
16
|
+
* the chevron width so there's no layout shift on loading.
|
|
17
|
+
* Gaps between items = `--gap-tight`. Outer inset on both sides = `--gap-sm`.
|
|
16
18
|
*/
|
|
17
19
|
function computeTrailingPad(actionCount) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return `calc(
|
|
20
|
+
const parts = ['var(--gap-sm)'];
|
|
21
|
+
if (actionCount > 0)
|
|
22
|
+
parts.push(`${actionCount} * var(--touch-target)`);
|
|
23
|
+
parts.push('var(--touch-target)'); // chevron / spinner slot
|
|
24
|
+
if (actionCount > 0)
|
|
25
|
+
parts.push(`${actionCount} * var(--gap-tight, 4px)`);
|
|
26
|
+
parts.push('var(--gap-sm)');
|
|
27
|
+
return `calc(${parts.join(' + ')})`;
|
|
26
28
|
}
|
|
27
29
|
const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessage = 'No results found', options = [], disabled, isLoading, variant, multiple = false, label, creatable = false, createLabel = 'Create', clearable = false, onOpenChange, onSearchChange, required, onCreateClick, createActionLabel, chips, }) => {
|
|
28
30
|
const id = useId();
|
|
@@ -34,11 +36,7 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
34
36
|
const containerRef = useRef(null);
|
|
35
37
|
const inputRef = useRef(null);
|
|
36
38
|
const listRef = useRef(null);
|
|
37
|
-
const selectedValues =
|
|
38
|
-
if (!value)
|
|
39
|
-
return [];
|
|
40
|
-
return Array.isArray(value) ? value : [value];
|
|
41
|
-
}, [value]);
|
|
39
|
+
const selectedValues = !value ? [] : Array.isArray(value) ? value : [value];
|
|
42
40
|
const filteredOptions = useMemo(() => {
|
|
43
41
|
if (!search)
|
|
44
42
|
return options;
|
|
@@ -164,7 +162,24 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
164
162
|
};
|
|
165
163
|
const handleClear = (e) => {
|
|
166
164
|
e.stopPropagation();
|
|
167
|
-
|
|
165
|
+
if (hasSelection)
|
|
166
|
+
onValueChange?.(multiple ? [] : '');
|
|
167
|
+
if (search)
|
|
168
|
+
setSearch('');
|
|
169
|
+
isSearchingRef.current = false;
|
|
170
|
+
inputRef.current?.focus();
|
|
171
|
+
};
|
|
172
|
+
const handleChevronClick = (e) => {
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
if (disabled)
|
|
175
|
+
return;
|
|
176
|
+
handleOpenChange(!open);
|
|
177
|
+
if (open) {
|
|
178
|
+
inputRef.current?.blur();
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
inputRef.current?.focus();
|
|
182
|
+
}
|
|
168
183
|
};
|
|
169
184
|
const getDisplayValue = () => {
|
|
170
185
|
// User is actively typing/backspacing — always show the search text (even if empty)
|
|
@@ -213,16 +228,16 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
213
228
|
// Count trailing action buttons to compute input padding.
|
|
214
229
|
// Always reserve space for the clear button when clearable (avoids layout shift on select/clear).
|
|
215
230
|
const showCreate = !!onCreateClick && !disabled;
|
|
216
|
-
const showClear = clearable &&
|
|
231
|
+
const showClear = clearable && !disabled && (hasSelection || search.length > 0);
|
|
217
232
|
const reservedCount = (showCreate ? 1 : 0) + (clearable ? 1 : 0);
|
|
218
233
|
const trailingPad = computeTrailingPad(reservedCount);
|
|
219
|
-
return (_jsxs("div", { ref: containerRef, className: cn('dndev-relative', open && 'dndev-combobox-open'), style: { width: '100%' }, children: [chips && label ? (_jsx(FloatingLabel, { htmlFor: id, label: label, disabled: disabled, required: required, children: _jsxs("div", { className: cn('dndev-relative dndev-combobox-wrapper', 'dndev-combobox-wrapper--chips'), style: { '--combobox-pad-end': trailingPad }, onClick: handleInputClick, children: [chips, _jsx(Input, { ref: inputRef, id: id, bare: true, value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onKeyDown: handleKeyDown, placeholder: hasSelection ? '' : placeholder, disabled: disabled, role: "combobox", "aria-expanded": open, "aria-controls": `${id}-listbox`, autoComplete: "one-time-code", "aria-autocomplete": "list", "data-variant": variant }), _jsxs("div", { className: "dndev-combobox-trailing", children: [showCreate && (_jsx("button", { type: "button", className: "dndev-combobox-action-btn dndev-combobox-action-btn--create", onClick: (e) => {
|
|
234
|
+
return (_jsxs("div", { ref: containerRef, className: cn('dndev-relative', open && 'dndev-combobox-open'), style: { width: '100%' }, children: [chips && label ? (_jsx(FloatingLabel, { htmlFor: id, label: label, disabled: disabled, required: required, children: _jsxs("div", { className: cn('dndev-relative dndev-combobox-wrapper', 'dndev-combobox-wrapper--chips'), style: { '--combobox-pad-end': trailingPad }, onClick: handleInputClick, children: [chips, _jsx(Input, { ref: inputRef, id: id, bare: true, value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onKeyDown: handleKeyDown, placeholder: hasSelection ? '' : placeholder, disabled: disabled, role: "combobox", "aria-expanded": open, "aria-controls": `${id}-listbox`, autoComplete: "one-time-code", "aria-autocomplete": "list", "data-variant": variant }), _jsxs("div", { className: "dndev-combobox-trailing", children: [showCreate && (_jsx("button", { type: "button", className: "dndev-inline-action-btn dndev-combobox-action-btn dndev-combobox-action-btn--create", onClick: (e) => {
|
|
220
235
|
e.stopPropagation();
|
|
221
236
|
onCreateClick();
|
|
222
|
-
}, "aria-label": createActionLabel || createLabel || 'Create new', children: _jsx(Plus, {}) })), showClear && (_jsx("button", { type: "button", className: "dndev-combobox-action-btn dndev-combobox-action-btn--clear", onClick: handleClear, "aria-label": "Clear", children: _jsx(X, {}) })), isLoading ? (_jsx("span", { className: "dndev-combobox-spinner", children: _jsx(Spinner, {}) })) : (_jsx("
|
|
237
|
+
}, "aria-label": createActionLabel || createLabel || 'Create new', children: _jsx(Plus, {}) })), showClear && (_jsx("button", { type: "button", className: "dndev-inline-action-btn dndev-combobox-action-btn dndev-combobox-action-btn--clear", onClick: handleClear, "aria-label": "Clear", children: _jsx(X, {}) })), isLoading ? (_jsx("span", { className: "dndev-combobox-spinner", children: _jsx(Spinner, {}) })) : (_jsx("button", { type: "button", className: "dndev-inline-action-btn dndev-combobox-chevron", onClick: handleChevronClick, onMouseDown: (e) => e.preventDefault(), tabIndex: -1, "aria-label": open ? 'Close' : 'Open', "aria-expanded": open, disabled: disabled, children: _jsx(ChevronDown, {}) }))] })] }) })) : (_jsxs("div", { className: cn('dndev-relative dndev-combobox-wrapper', chips && 'dndev-combobox-wrapper--chips'), style: { '--combobox-pad-end': trailingPad }, onClick: chips ? handleInputClick : undefined, children: [chips, _jsx(Input, { ref: inputRef, id: id, label: chips ? undefined : label, value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onClick: chips ? undefined : handleInputClick, onKeyDown: handleKeyDown, placeholder: hasSelection && chips ? '' : placeholder, disabled: disabled, required: required, bare: !!chips, role: "combobox", "aria-expanded": open, "aria-controls": `${id}-listbox`, autoComplete: "one-time-code", "aria-autocomplete": "list", "data-variant": variant }), _jsxs("div", { className: "dndev-combobox-trailing", children: [showCreate && (_jsx("button", { type: "button", className: "dndev-inline-action-btn dndev-combobox-action-btn dndev-combobox-action-btn--create", onClick: (e) => {
|
|
223
238
|
e.stopPropagation();
|
|
224
239
|
onCreateClick();
|
|
225
|
-
}, "aria-label": createActionLabel || createLabel || 'Create new', children: _jsx(Plus, {}) })), showClear && (_jsx("button", { type: "button", className: "dndev-combobox-action-btn dndev-combobox-action-btn--clear", onClick: handleClear, "aria-label": "Clear", children: _jsx(X, {}) })), isLoading ? (_jsx("span", { className: "dndev-combobox-spinner", children: _jsx(Spinner, {}) })) : (_jsx("span", { className: "dndev-combobox-chevron", children: _jsx(ChevronDown, {}) }))] })] })), open && (_jsx("div", { className: "dndev-floating dndev-menu-content dndev-z-tooltip dndev-combobox-content", style: {
|
|
240
|
+
}, "aria-label": createActionLabel || createLabel || 'Create new', children: _jsx(Plus, {}) })), showClear && (_jsx("button", { type: "button", className: "dndev-inline-action-btn dndev-combobox-action-btn dndev-combobox-action-btn--clear", onClick: handleClear, "aria-label": "Clear", children: _jsx(X, {}) })), isLoading ? (_jsx("span", { className: "dndev-combobox-spinner", children: _jsx(Spinner, {}) })) : (_jsx("span", { className: "dndev-combobox-chevron", children: _jsx(ChevronDown, {}) }))] })] })), open && (_jsx("div", { className: "dndev-floating dndev-menu-content dndev-z-tooltip dndev-combobox-content", style: {
|
|
226
241
|
position: 'absolute',
|
|
227
242
|
top: '100%',
|
|
228
243
|
insetInlineStart: 0,
|
|
@@ -239,7 +254,7 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
239
254
|
const isSelected = selectedValues.includes(option.value);
|
|
240
255
|
const isHighlighted = index === highlightedIndex;
|
|
241
256
|
const isCreateOption = option.isCreateOption;
|
|
242
|
-
return (_jsx("button", { type: "button", role: "option", "aria-selected": isSelected, onClick: () => !option.disabled && handleSelect(option.value), disabled: option.disabled, className: cn('dndev-interactive dndev-combobox-option', isHighlighted && 'dndev-combobox-option-highlighted', isSelected && 'dndev-combobox-option-selected', isCreateOption && 'dndev-combobox-option-create'), onMouseEnter: () => setHighlightedIndex(index), children: option.content ? (option.content) : (_jsxs(_Fragment, { children: [isCreateOption && (_jsx(Plus, { className: "dndev-combobox-option-create-icon" })), _jsxs("div", { className: "dndev-combobox-option-content", children: [
|
|
257
|
+
return (_jsx("button", { type: "button", role: "option", "aria-selected": isSelected, onClick: () => !option.disabled && handleSelect(option.value), disabled: option.disabled, className: cn('dndev-interactive dndev-combobox-option', isHighlighted && 'dndev-combobox-option-highlighted', isSelected && 'dndev-combobox-option-selected', isCreateOption && 'dndev-combobox-option-create'), onMouseEnter: () => setHighlightedIndex(index), children: option.content ? (option.content) : (_jsxs(_Fragment, { children: [isCreateOption && (_jsx(Plus, { className: "dndev-combobox-option-create-icon" })), _jsxs("div", { className: "dndev-combobox-option-content", children: [_jsxs("span", { className: "dndev-combobox-option-label", children: [option.label, option.count !== undefined && (_jsxs("span", { className: "dndev-combobox-option-count", children: ["(", option.count, ")"] }))] }), option.description && (_jsx("span", { className: "dndev-combobox-option-description", children: option.description }))] }), isSelected && !isCreateOption && (_jsx(Check, { className: "dndev-combobox-option-check" }))] })) }, isCreateOption ? `create-${option.value}` : option.value));
|
|
243
258
|
})) }) }) }))] }));
|
|
244
259
|
};
|
|
245
260
|
export default Combobox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/CopyToClipboard/index.tsx"],"names":[],"mappings":"AAgBA,OAAe,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,uBAAuB,CAAC;AAE/B,4GAA4G;AAC5G,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,WAAW,EACX,UAAU,GAAG,MAAM,GAAG,QAAQ,CAC/B;IACC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAA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O,CAAC;IACtB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CA2ErE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -9,7 +9,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
import { Copy, Check } from 'lucide-react';
|
|
12
|
-
import { useState,
|
|
12
|
+
import { useState, useEffect, useRef } from 'react';
|
|
13
13
|
import { DISPLAY } from '../../styles/componentConstants';
|
|
14
14
|
import { cn } from '../../utils/helpers';
|
|
15
15
|
import Button, {} from '../Button';
|
|
@@ -30,7 +30,7 @@ export const CopyToClipboard = ({ text, children, variant = 'ghost', className,
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}, []);
|
|
33
|
-
const handleCopy =
|
|
33
|
+
const handleCopy = async (e) => {
|
|
34
34
|
e.stopPropagation();
|
|
35
35
|
e.preventDefault();
|
|
36
36
|
try {
|
|
@@ -55,7 +55,7 @@ export const CopyToClipboard = ({ text, children, variant = 'ghost', className,
|
|
|
55
55
|
}
|
|
56
56
|
// No fallback - modern browsers should support clipboard API
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
59
|
return (_jsx(Button, { type: "button", variant: variant, display: children ? DISPLAY.FULL : DISPLAY.COMPACT, icon: copied ? Check : Copy, onClick: handleCopy, tooltip: showTooltip ? (copied ? copiedTooltipText : tooltipText) : undefined, tooltipForceOpen: copied, className: cn('dndev-copy-button-transition', copied && 'dndev-copy-button-scaled', className), "aria-label": ariaLabel || (copied ? 'Copied to clipboard' : 'Copy to clipboard'), ...buttonProps, children: children }));
|
|
60
60
|
};
|
|
61
61
|
export default CopyToClipboard;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import './DatePicker.css';
|
|
3
|
+
/** Props for the DatePicker component. */
|
|
4
|
+
export interface DatePickerProps {
|
|
5
|
+
/** ISO 8601 date string (YYYY-MM-DD) or null */
|
|
6
|
+
value?: string | null;
|
|
7
|
+
/** Emits ISO string (YYYY-MM-DD) or null */
|
|
8
|
+
onChange?: (date: string | null) => void;
|
|
9
|
+
/** FloatingLabel text */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** Minimum selectable date (ISO string or Date) */
|
|
12
|
+
min?: string | Date;
|
|
13
|
+
/** Maximum selectable date (ISO string or Date) */
|
|
14
|
+
max?: string | Date;
|
|
15
|
+
/** Whether the field is required */
|
|
16
|
+
required?: boolean;
|
|
17
|
+
/** Whether the field is disabled */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** BCP 47 locale for segment order. Default: navigator.language or 'fr-FR' */
|
|
20
|
+
locale?: string;
|
|
21
|
+
/** Additional CSS classes */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Element id */
|
|
24
|
+
id?: string;
|
|
25
|
+
/** HTML name attribute for form submission */
|
|
26
|
+
name?: string;
|
|
27
|
+
/** React 19 native ref */
|
|
28
|
+
ref?: Ref<HTMLDivElement>;
|
|
29
|
+
/** ARIA describedby for error/helper association */
|
|
30
|
+
'aria-describedby'?: string;
|
|
31
|
+
/** ARIA invalid for error state */
|
|
32
|
+
'aria-invalid'?: boolean;
|
|
33
|
+
/** data-variant for styling (e.g., 'destructive') */
|
|
34
|
+
'data-variant'?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Accessible date picker with segmented keyboard input, calendar popover,
|
|
38
|
+
* and automatic mobile native fallback.
|
|
39
|
+
*
|
|
40
|
+
* - Desktop: segmented DD/MM/YYYY input with up/down increment, auto-advance
|
|
41
|
+
* - Mobile: native `<input type="date">` (OS picker is better on touch)
|
|
42
|
+
* - Keyboard: Arrow keys between segments, Up/Down to change values, paste-aware
|
|
43
|
+
* - ARIA: spinbutton pattern per segment, full screen reader support
|
|
44
|
+
*
|
|
45
|
+
* @component
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <DatePicker label="Date de naissance" value={date} onChange={setDate} />
|
|
49
|
+
* <DatePicker label="Début" min="2024-01-01" required />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function DatePicker({ value, onChange, label, min, max, required, disabled, locale, className, id: idProp, name, ref, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'data-variant': dataVariant, }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export default DatePicker;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/DatePicker/index.tsx"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAiC,GAAG,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,kBAAkB,CAAC;AAE1B,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,EAAE,CAAC,EAAE,MA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