@donotdev/components 0.0.11 → 0.0.12
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/atomic/Button/index.d.ts.map +1 -1
- package/dist/atomic/Button/index.js +5 -2
- package/dist/atomic/Calendar/index.js +1 -1
- package/dist/atomic/Collapsible/index.d.ts.map +1 -1
- package/dist/atomic/Collapsible/index.js +1 -5
- package/dist/atomic/Combobox/index.d.ts +9 -47
- package/dist/atomic/Combobox/index.d.ts.map +1 -1
- package/dist/atomic/Combobox/index.js +135 -87
- package/dist/atomic/Dialog/index.d.ts.map +1 -1
- package/dist/atomic/Dialog/index.js +1 -1
- package/dist/atomic/DropdownMenu/index.js +1 -1
- package/dist/atomic/Input/index.d.ts +1 -1
- package/dist/atomic/Input/index.d.ts.map +1 -1
- package/dist/atomic/Input/index.js +6 -22
- package/dist/atomic/Label/FloatingLabel.d.ts +31 -0
- package/dist/atomic/Label/FloatingLabel.d.ts.map +1 -0
- package/dist/atomic/Label/FloatingLabel.js +34 -0
- package/dist/atomic/Label/index.d.ts +5 -1
- package/dist/atomic/Label/index.d.ts.map +1 -1
- package/dist/atomic/Label/index.js +8 -2
- package/dist/atomic/PasswordInput/index.d.ts +9 -10
- package/dist/atomic/PasswordInput/index.d.ts.map +1 -1
- package/dist/atomic/PasswordInput/index.js +10 -30
- package/dist/atomic/Section/index.d.ts.map +1 -1
- package/dist/atomic/Section/index.js +3 -4
- package/dist/atomic/Select/index.d.ts +3 -1
- package/dist/atomic/Select/index.d.ts.map +1 -1
- package/dist/atomic/Select/index.js +13 -24
- package/dist/atomic/Skeleton/index.d.ts.map +1 -1
- package/dist/atomic/Skeleton/index.js +6 -3
- package/dist/atomic/Switch/index.d.ts +18 -4
- package/dist/atomic/Switch/index.d.ts.map +1 -1
- package/dist/atomic/Switch/index.js +25 -6
- package/dist/atomic/Table/index.d.ts +17 -7
- package/dist/atomic/Table/index.d.ts.map +1 -1
- package/dist/atomic/Table/index.js +13 -3
- package/dist/atomic/index.d.ts +2 -3
- package/dist/atomic/index.d.ts.map +1 -1
- package/dist/atomic/index.js +1 -2
- package/dist/index.js +4 -4
- package/dist/styles/index.css +335 -56
- package/package.json +1 -1
- package/dist/atomic/Combobox/ComboboxPrimitive.d.ts +0 -18
- package/dist/atomic/Combobox/ComboboxPrimitive.d.ts.map +0 -1
- package/dist/atomic/Combobox/ComboboxPrimitive.js +0 -14
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// packages/components/src/atomic/Label/FloatingLabel.tsx
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview FloatingLabel component
|
|
5
|
+
* @description Shared floating label component for Input, PasswordInput, Select, and Combobox
|
|
6
|
+
*
|
|
7
|
+
* @version 0.0.1
|
|
8
|
+
* @since 0.0.1
|
|
9
|
+
* @author AMBROISE PARK Consulting
|
|
10
|
+
*/
|
|
11
|
+
import LabelPrimitive from './LabelPrimitive';
|
|
12
|
+
import { cn } from '../../utils/helpers';
|
|
13
|
+
import './Label.css';
|
|
14
|
+
/**
|
|
15
|
+
* FloatingLabel - Shared floating label component
|
|
16
|
+
*
|
|
17
|
+
* Positioned absolutely at the top of input fields.
|
|
18
|
+
* Uses transparent background to adapt to any parent container (dropdowns, cards, etc.)
|
|
19
|
+
*
|
|
20
|
+
* @component
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <FloatingLabel htmlFor="email" disabled={false} truncate>
|
|
24
|
+
* Email Address
|
|
25
|
+
* </FloatingLabel>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function FloatingLabel({ htmlFor, children, disabled = false, truncate = false, required = false, }) {
|
|
29
|
+
return (_jsxs(LabelPrimitive, { htmlFor: htmlFor, className: "dndev-floating-label", "data-disabled": disabled ? 'true' : undefined, "data-truncate": truncate ? 'true' : undefined, children: [children, required && (_jsx("span", { style: {
|
|
30
|
+
color: 'var(--destructive-foreground)',
|
|
31
|
+
marginInlineStart: 'var(--gap-tight)',
|
|
32
|
+
}, "aria-hidden": "true", children: "*" }))] }));
|
|
33
|
+
}
|
|
34
|
+
export default FloatingLabel;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
9
|
import { type LabelPrimitiveProps } from './LabelPrimitive';
|
|
10
|
+
import { FloatingLabel, type FloatingLabelProps } from './FloatingLabel';
|
|
10
11
|
import type { ComponentType, ReactNode } from 'react';
|
|
11
12
|
export interface LabelProps extends LabelPrimitiveProps {
|
|
12
13
|
/** Optional icon to display with the label */
|
|
@@ -24,6 +25,8 @@ export interface LabelProps extends LabelPrimitiveProps {
|
|
|
24
25
|
* @default false
|
|
25
26
|
*/
|
|
26
27
|
plain?: boolean;
|
|
28
|
+
/** Whether the field is required - shows asterisk indicator */
|
|
29
|
+
required?: boolean;
|
|
27
30
|
children?: ReactNode;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
@@ -38,6 +41,7 @@ export interface LabelProps extends LabelPrimitiveProps {
|
|
|
38
41
|
* @param {LabelProps} props - The props for the label
|
|
39
42
|
* @returns {JSX.Element} The rendered label
|
|
40
43
|
*/
|
|
41
|
-
declare const Label: ({ className, icon: Icon, iconEnd, plain, children, ...props }: LabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
declare const Label: ({ className, icon: Icon, iconEnd, plain, required, children, ...props }: LabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
45
|
export default Label;
|
|
46
|
+
export { FloatingLabel, type FloatingLabelProps };
|
|
43
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Label/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAuB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Label/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAuB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,UAAW,SAAQ,mBAAmB;IACrD,8CAA8C;IAC9C,IAAI,CAAC,EAAE,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,KAAK,GAAI,yEAQZ,UAAU,4CAgCZ,CAAC;AAEF,eAAe,KAAK,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
*/
|
|
11
11
|
import LabelPrimitive, {} from './LabelPrimitive';
|
|
12
12
|
import { cn } from '../../utils/helpers';
|
|
13
|
+
import { FloatingLabel } from './FloatingLabel';
|
|
13
14
|
/**
|
|
14
15
|
* Accessible label component built on Radix UI Label.
|
|
15
16
|
* Supports icons and various label positions.
|
|
@@ -22,8 +23,13 @@ import { cn } from '../../utils/helpers';
|
|
|
22
23
|
* @param {LabelProps} props - The props for the label
|
|
23
24
|
* @returns {JSX.Element} The rendered label
|
|
24
25
|
*/
|
|
25
|
-
const Label = ({ className, icon: Icon, iconEnd = false, plain = false, children, ...props }) => {
|
|
26
|
+
const Label = ({ className, icon: Icon, iconEnd = false, plain = false, required = false, children, ...props }) => {
|
|
26
27
|
const iconElement = Icon ? (_jsx(Icon, { className: "dndev-label-icon", "data-position": iconEnd ? 'trailing' : 'leading' })) : null;
|
|
27
|
-
|
|
28
|
+
const requiredIndicator = required ? (_jsx("span", { style: {
|
|
29
|
+
color: 'var(--destructive-foreground)',
|
|
30
|
+
marginInlineStart: 'var(--gap-tight)',
|
|
31
|
+
}, "aria-hidden": "true", children: "*" })) : null;
|
|
32
|
+
return (_jsxs(LabelPrimitive, { className: cn('dndev-text-base dndev-label-base', className), "data-plain": plain ? 'true' : undefined, ...props, children: [!iconEnd && iconElement, children, requiredIndicator, iconEnd && iconElement] }));
|
|
28
33
|
};
|
|
29
34
|
export default Label;
|
|
35
|
+
export { FloatingLabel };
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { type InputHTMLAttributes
|
|
1
|
+
import { type InputHTMLAttributes } from 'react';
|
|
2
2
|
import './PasswordInput.css';
|
|
3
3
|
export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
4
|
-
/** Whether to show the password toggle button */
|
|
5
|
-
showToggle?: boolean;
|
|
6
|
-
/** Custom toggle button content */
|
|
7
|
-
toggleButton?: ReactNode;
|
|
8
4
|
/** Whether the password is currently visible */
|
|
9
5
|
visible?: boolean;
|
|
10
6
|
/** Callback when visibility changes */
|
|
11
7
|
onVisibilityChange?: (visible: boolean) => void;
|
|
12
8
|
/** Label for floating label - always shown small at top-left when provided */
|
|
13
9
|
label?: string;
|
|
10
|
+
/** Whether the field is required - shows asterisk indicator */
|
|
11
|
+
required?: boolean;
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* PasswordInput Component
|
|
17
15
|
*
|
|
18
16
|
* A password input field with show/hide toggle functionality.
|
|
19
17
|
* Features industry-standard UX patterns:
|
|
20
|
-
* - Eye icon toggle (show/hide password)
|
|
21
|
-
* - Keyboard accessibility (Enter to toggle)
|
|
18
|
+
* - Eye icon toggle (show/hide password) - ALWAYS at end, cannot be overridden
|
|
22
19
|
* - Smooth icon transitions
|
|
23
20
|
* - Mobile-friendly touch targets
|
|
24
21
|
* - Screen reader support
|
|
25
22
|
* - ARIA labels and descriptions
|
|
26
23
|
*
|
|
24
|
+
* Opinionated: Eye icon is ALWAYS positioned at end with inline styles.
|
|
25
|
+
* If you need different behavior, create your own component.
|
|
26
|
+
*
|
|
27
27
|
* @component
|
|
28
|
-
* @version 0.0.
|
|
28
|
+
* @version 0.0.2
|
|
29
29
|
* @since 0.0.1
|
|
30
30
|
* @author AMBROISE PARK Consulting
|
|
31
31
|
* @example
|
|
@@ -34,12 +34,11 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
|
|
|
34
34
|
* value={password}
|
|
35
35
|
* onChange={setPassword}
|
|
36
36
|
* placeholder="Enter password"
|
|
37
|
-
* showToggle={true}
|
|
38
37
|
* />
|
|
39
38
|
* ```
|
|
40
39
|
* @param {PasswordInputProps} props - The props for the password input
|
|
41
40
|
* @returns {JSX.Element} The rendered password input
|
|
42
41
|
*/
|
|
43
|
-
declare const PasswordInput: ({ className,
|
|
42
|
+
declare const PasswordInput: ({ className, visible: controlledVisible, onVisibilityChange, label, value, onFocus, onBlur, required, ...props }: PasswordInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
44
43
|
export default PasswordInput;
|
|
45
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/PasswordInput/index.tsx"],"names":[],"mappings":"AAYA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/PasswordInput/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIlE,OAAO,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,CACP;IACC,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,aAAa,GAAI,kHAUpB,kBAAkB,4CA+DpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// packages/components/src/atomic/PasswordInput/index.tsx
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview PasswordInput component
|
|
@@ -9,25 +9,26 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
import { Eye, EyeOff } from 'lucide-react';
|
|
12
|
-
import { useState, useId
|
|
12
|
+
import { useState, useId } from 'react';
|
|
13
13
|
import { cn } from '../../utils/helpers';
|
|
14
|
-
import
|
|
15
|
-
import Label from '../Label';
|
|
14
|
+
import { FloatingLabel } from '../Label';
|
|
16
15
|
import './PasswordInput.css';
|
|
17
16
|
/**
|
|
18
17
|
* PasswordInput Component
|
|
19
18
|
*
|
|
20
19
|
* A password input field with show/hide toggle functionality.
|
|
21
20
|
* Features industry-standard UX patterns:
|
|
22
|
-
* - Eye icon toggle (show/hide password)
|
|
23
|
-
* - Keyboard accessibility (Enter to toggle)
|
|
21
|
+
* - Eye icon toggle (show/hide password) - ALWAYS at end, cannot be overridden
|
|
24
22
|
* - Smooth icon transitions
|
|
25
23
|
* - Mobile-friendly touch targets
|
|
26
24
|
* - Screen reader support
|
|
27
25
|
* - ARIA labels and descriptions
|
|
28
26
|
*
|
|
27
|
+
* Opinionated: Eye icon is ALWAYS positioned at end with inline styles.
|
|
28
|
+
* If you need different behavior, create your own component.
|
|
29
|
+
*
|
|
29
30
|
* @component
|
|
30
|
-
* @version 0.0.
|
|
31
|
+
* @version 0.0.2
|
|
31
32
|
* @since 0.0.1
|
|
32
33
|
* @author AMBROISE PARK Consulting
|
|
33
34
|
* @example
|
|
@@ -36,13 +37,12 @@ import './PasswordInput.css';
|
|
|
36
37
|
* value={password}
|
|
37
38
|
* onChange={setPassword}
|
|
38
39
|
* placeholder="Enter password"
|
|
39
|
-
* showToggle={true}
|
|
40
40
|
* />
|
|
41
41
|
* ```
|
|
42
42
|
* @param {PasswordInputProps} props - The props for the password input
|
|
43
43
|
* @returns {JSX.Element} The rendered password input
|
|
44
44
|
*/
|
|
45
|
-
const PasswordInput = ({ className,
|
|
45
|
+
const PasswordInput = ({ className, visible: controlledVisible, onVisibilityChange, label, value, onFocus, onBlur, required, ...props }) => {
|
|
46
46
|
const id = useId();
|
|
47
47
|
const [internalVisible, setInternalVisible] = useState(false);
|
|
48
48
|
// Use controlled or internal state
|
|
@@ -55,26 +55,6 @@ const PasswordInput = ({ className, showToggle = true, toggleButton, visible: co
|
|
|
55
55
|
}
|
|
56
56
|
onVisibilityChange?.(newVisible);
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
if (e.key === 'Enter' && showToggle) {
|
|
60
|
-
e.preventDefault();
|
|
61
|
-
toggleVisibility();
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
return (_jsxs("div", { className: "dndev-relative", children: [hasLabel && (_jsx(Label, { htmlFor: id, style: {
|
|
65
|
-
position: 'absolute',
|
|
66
|
-
left: 'var(--gap-md)',
|
|
67
|
-
top: 'calc(-1 * var(--font-size-xs) / 2 - 1px)',
|
|
68
|
-
fontSize: 'var(--font-size-xs)',
|
|
69
|
-
fontWeight: 500,
|
|
70
|
-
color: props.disabled
|
|
71
|
-
? 'var(--muted-foreground)'
|
|
72
|
-
: 'var(--foreground)',
|
|
73
|
-
pointerEvents: 'none',
|
|
74
|
-
zIndex: 1,
|
|
75
|
-
backgroundColor: 'var(--background)',
|
|
76
|
-
padding: '0 var(--gap-xs)',
|
|
77
|
-
lineHeight: 1,
|
|
78
|
-
}, children: label })), _jsx("input", { id: id, type: isVisible ? 'text' : 'password', value: value, className: cn('dndev-input', showToggle && 'dndev-password-input-with-toggle', className), onKeyDown: handleKeyDown, onFocus: onFocus, onBlur: onBlur, ...props }), showToggle && (_jsx(Button, { type: "button", variant: BUTTON_VARIANT.GHOST, className: "dndev-password-toggle-button", onClick: toggleVisibility, "aria-label": isVisible ? 'Hide password' : 'Show password', "aria-describedby": props['aria-describedby'], tabIndex: -1, children: toggleButton || (_jsx(_Fragment, { children: isVisible ? (_jsx(EyeOff, { className: "dndev-size-md dndev-password-toggle-icon" })) : (_jsx(Eye, { className: "dndev-size-md dndev-password-toggle-icon" })) })) }))] }));
|
|
58
|
+
return (_jsxs("div", { className: "dndev-relative", children: [hasLabel && (_jsx(FloatingLabel, { htmlFor: id, disabled: props.disabled, required: required, children: label })), _jsx("input", { id: id, type: isVisible ? 'text' : 'password', value: value, className: cn('dndev-input', 'dndev-password-input-with-toggle', className), onFocus: onFocus, onBlur: onBlur, required: required, ...props }), _jsx("button", { type: "button", className: "dndev-password-toggle-button", onClick: toggleVisibility, "aria-label": isVisible ? 'Hide password' : 'Show password', "aria-describedby": props['aria-describedby'], tabIndex: -1, children: isVisible ? (_jsx(EyeOff, { className: "dndev-size-md dndev-password-toggle-icon" })) : (_jsx(Eye, { className: "dndev-size-md dndev-password-toggle-icon" })) })] }));
|
|
79
59
|
};
|
|
80
60
|
export default PasswordInput;
|
|
@@ -1 +1 @@
|
|
|
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AAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,SAAS,IAAI,eAAe,GAC3E,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,MAAM,eAAe,CAAC,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,OAAO,8HAmGZ,CAAC;AAIF,eAAe,OAAO,CAAC"}
|
|
@@ -60,11 +60,10 @@ const Section = forwardRef(function Section({ as = 'section', children, title, s
|
|
|
60
60
|
const [internalOpen, setInternalOpen] = useState(() => collapsible ? defaultOpen : false);
|
|
61
61
|
const isControlled = collapsible && open !== undefined;
|
|
62
62
|
const isOpen = isControlled ? open : internalOpen;
|
|
63
|
-
const handleOpenChange = isControlled
|
|
64
|
-
? onOpenChange
|
|
65
|
-
: setInternalOpen;
|
|
63
|
+
const handleOpenChange = isControlled ? onOpenChange : setInternalOpen;
|
|
66
64
|
const content = gridCols ? (_jsx(Grid, { cols: gridCols, gap: gridGap || GAP_VARIANT.MEDIUM, children: children })) : (children);
|
|
67
|
-
const titleElement = title &&
|
|
65
|
+
const titleElement = title &&
|
|
66
|
+
(collapsible ? (_jsx(CollapsibleTrigger, { asChild: true, children: _jsxs(Stack, { as: "div", direction: "row", align: "center", justify: "between", className: "dndev-section-title-trigger", children: [_jsx(Text, { as: "div", level: "h2", className: "dndev-section-title", children: title }), isOpen ? (_jsx(Minus, { className: "dndev-section-icon", "aria-hidden": "true" })) : (_jsx(Plus, { className: "dndev-section-icon", "aria-hidden": "true" }))] }) })) : (_jsx(Text, { as: "div", level: "h2", className: "dndev-section-title", children: title })));
|
|
68
67
|
const sectionContent = collapsible ? (_jsxs(CollapsiblePrimitive, { ...(isControlled
|
|
69
68
|
? { open: isOpen, onOpenChange: handleOpenChange }
|
|
70
69
|
: { defaultOpen: defaultOpen, onOpenChange: handleOpenChange }), children: [titleElement, _jsx(CollapsibleContent, { className: "dndev-collapsible-content", children: content })] })) : (_jsxs(_Fragment, { children: [titleElement, content] }));
|
|
@@ -25,6 +25,8 @@ export interface SelectProps extends Omit<ComponentProps<typeof SelectRootPrimit
|
|
|
25
25
|
isLoading?: boolean;
|
|
26
26
|
/** Label for floating label - automatically floats when both label and placeholder are provided */
|
|
27
27
|
label?: string;
|
|
28
|
+
/** Whether the field is required - shows asterisk indicator */
|
|
29
|
+
required?: boolean;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Accessible select component built on Radix UI primitives.
|
|
@@ -46,6 +48,6 @@ export interface SelectProps extends Omit<ComponentProps<typeof SelectRootPrimit
|
|
|
46
48
|
* @param {SelectProps} props - The props for the select
|
|
47
49
|
* @returns {JSX.Element} The rendered select
|
|
48
50
|
*/
|
|
49
|
-
declare const Select: ({ value, onValueChange, placeholder, options, trigger, disabled, isLoading, defaultValue, label, ...props }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
declare const Select: ({ value, onValueChange, placeholder, options, trigger, disabled, isLoading, defaultValue, label, required, ...props }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
52
|
export default Select;
|
|
51
53
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Select/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Select/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,mBAON,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,cAAc,CAAC,OAAO,mBAAmB,CAAC,EAC1C,UAAU,CACX;IACC,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mGAAmG;IACnG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,MAAM,GAAI,uHAYb,WAAW,4CAoHb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -12,7 +12,8 @@ import * as SelectRadix from '@radix-ui/react-select';
|
|
|
12
12
|
import { Check, ChevronDown } from 'lucide-react';
|
|
13
13
|
import { useState, useId } from 'react';
|
|
14
14
|
import { cn } from '../../utils/helpers';
|
|
15
|
-
import
|
|
15
|
+
import { FloatingLabel } from '../Label';
|
|
16
|
+
import ScrollArea from '../ScrollArea';
|
|
16
17
|
import SelectRootPrimitive, { SelectTriggerPrimitive, SelectValuePrimitive, SelectContentPrimitive, SelectItemPrimitive, SelectLabelPrimitive, SelectSeparatorPrimitive, } from './SelectPrimitive';
|
|
17
18
|
import './Select.css';
|
|
18
19
|
/**
|
|
@@ -35,31 +36,19 @@ import './Select.css';
|
|
|
35
36
|
* @param {SelectProps} props - The props for the select
|
|
36
37
|
* @returns {JSX.Element} The rendered select
|
|
37
38
|
*/
|
|
38
|
-
const Select = ({ value, onValueChange, placeholder = 'Select an option...', options = [], trigger, disabled, isLoading, defaultValue, label, ...props }) => {
|
|
39
|
+
const Select = ({ value, onValueChange, placeholder = 'Select an option...', options = [], trigger, disabled, isLoading, defaultValue, label, required, ...props }) => {
|
|
39
40
|
const id = useId();
|
|
40
41
|
const [isOpen, setIsOpen] = useState(false);
|
|
41
42
|
const hasLabel = !!label;
|
|
42
|
-
const customTrigger = trigger ? (_jsx(SelectTriggerPrimitive, { asChild: true, disabled: disabled, className: "dndev-input dndev-select-trigger", children: trigger })) : (_jsxs("div", { className: "dndev-relative", children: [hasLabel && (_jsx(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
padding: '0 var(--gap-xs)',
|
|
53
|
-
lineHeight: 1,
|
|
54
|
-
}, children: label })), _jsxs(SelectTriggerPrimitive, { id: id, className: "dndev-input dndev-select-trigger", disabled: disabled, children: [isLoading ? (_jsxs("div", { className: "dndev-select-loading-container", children: [_jsx("div", { className: "dndev-animate-spin dndev-select-loading-spinner" }), _jsx("span", { children: "Loading..." })] })) : (_jsx(SelectValuePrimitive, { placeholder: placeholder })), _jsx(SelectRadix.Icon, { asChild: true, children: _jsx(ChevronDown, {}) })] })] }));
|
|
55
|
-
return (_jsxs(SelectRootPrimitive, { value: value, onValueChange: onValueChange, defaultValue: defaultValue, disabled: disabled, onOpenChange: setIsOpen, ...props, children: [customTrigger, _jsx(SelectRadix.Portal, { children: _jsx(SelectContentPrimitive, { className: "dndev-floating dndev-menu-content dndev-z-tooltip dndev-select-content", position: "popper", side: "bottom", sideOffset: 4, align: "start", "data-glow": "blank", children: _jsx(SelectRadix.Viewport, { children: options.map((option) => {
|
|
56
|
-
if (option.value === '__label__') {
|
|
57
|
-
return (_jsx(SelectLabelPrimitive, { className: "dndev-menu-label", children: option.label }, option.label));
|
|
58
|
-
}
|
|
59
|
-
if (option.value === '__separator__') {
|
|
60
|
-
return (_jsx(SelectSeparatorPrimitive, { className: "dndev-menu-separator" }, "separator"));
|
|
61
|
-
}
|
|
62
|
-
return (_jsxs(SelectItemPrimitive, { value: option.value, disabled: option.disabled, className: "dndev-interactive", "data-role": "menu-item", children: [option.content ? (option.content) : (_jsx(_Fragment, { children: _jsxs(SelectRadix.ItemText, { children: [_jsx("span", { children: option.label }), option.description && (_jsx("span", { className: "dndev-select-item-description", children: option.description }))] }) })), _jsx(SelectRadix.ItemIndicator, { className: "dndev-dropdown-menu-checkmark dndev-dropdown-menu-trailing", children: _jsx(Check, {}) })] }, option.value));
|
|
63
|
-
}) }) }) })] }));
|
|
43
|
+
const customTrigger = trigger ? (_jsx(SelectTriggerPrimitive, { asChild: true, disabled: disabled, className: "dndev-input dndev-select-trigger", children: trigger })) : (_jsxs("div", { className: "dndev-relative", children: [hasLabel && (_jsx(FloatingLabel, { htmlFor: id, disabled: disabled, required: required, children: label })), _jsxs(SelectTriggerPrimitive, { id: id, className: "dndev-input dndev-select-trigger", disabled: disabled, children: [isLoading ? (_jsxs("div", { className: "dndev-select-loading-container", children: [_jsx("div", { className: "dndev-animate-spin dndev-select-loading-spinner" }), _jsx("span", { children: "Loading..." })] })) : (_jsx(SelectValuePrimitive, { placeholder: placeholder })), _jsx(SelectRadix.Icon, { asChild: true, children: _jsx(ChevronDown, {}) })] })] }));
|
|
44
|
+
return (_jsxs(SelectRootPrimitive, { value: value, onValueChange: onValueChange, defaultValue: defaultValue, disabled: disabled, onOpenChange: setIsOpen, ...props, children: [customTrigger, _jsx(SelectRadix.Portal, { children: _jsx(SelectContentPrimitive, { className: "dndev-floating dndev-menu-content dndev-z-tooltip dndev-select-content", position: "popper", side: "bottom", sideOffset: 4, align: "start", "data-glow": "blank", children: _jsx(SelectRadix.Viewport, { children: _jsx(ScrollArea, { className: "dndev-menu-scroll-area", end: true, children: options.map((option) => {
|
|
45
|
+
if (option.value === '__label__') {
|
|
46
|
+
return (_jsx(SelectLabelPrimitive, { className: "dndev-menu-label", children: option.label }, option.label));
|
|
47
|
+
}
|
|
48
|
+
if (option.value === '__separator__') {
|
|
49
|
+
return (_jsx(SelectSeparatorPrimitive, { className: "dndev-menu-separator" }, "separator"));
|
|
50
|
+
}
|
|
51
|
+
return (_jsxs(SelectItemPrimitive, { value: option.value, disabled: option.disabled, className: "dndev-interactive", "data-role": "menu-item", children: [option.content ? (option.content) : (_jsx(_Fragment, { children: _jsxs(SelectRadix.ItemText, { children: [_jsx("span", { children: option.label }), option.description && (_jsx("span", { className: "dndev-select-item-description", children: option.description }))] }) })), _jsx(SelectRadix.ItemIndicator, { className: "dndev-dropdown-menu-checkmark dndev-dropdown-menu-trailing", children: _jsx(Check, {}) })] }, option.value));
|
|
52
|
+
}) }) }) }) })] }));
|
|
64
53
|
};
|
|
65
54
|
export default Select;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Skeleton/index.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACzE,wBAAwB;IACxB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAChD,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC9E,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAuBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,QAAQ,CAAC,EAChB,SAAS,EACT,OAAiB,EACjB,IAAe,EACf,KAAK,EACL,MAAM,EACN,KAAS,EACT,YAAY,EAAE,SAA6B,EAC3C,GAAG,KAAK,EACT,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Skeleton/index.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACzE,wBAAwB;IACxB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAChD,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC9E,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAuBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,QAAQ,CAAC,EAChB,SAAS,EACT,OAAiB,EACjB,IAAe,EACf,KAAK,EACL,MAAM,EACN,KAAS,EACT,YAAY,EAAE,SAA6B,EAC3C,GAAG,KAAK,EACT,EAAE,aAAa,2CAiDf;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -11,16 +11,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { cn } from '../../utils/helpers';
|
|
12
12
|
const sizePresets = {
|
|
13
13
|
text: { height: 'var(--gap-md)', width: '100%' },
|
|
14
|
-
heading: { height: 'var(--icon-touch)', width: '
|
|
14
|
+
heading: { height: 'var(--icon-touch)', width: '100%' },
|
|
15
15
|
avatar: {
|
|
16
16
|
height: 'var(--icon-touch)',
|
|
17
17
|
width: 'var(--icon-touch)',
|
|
18
18
|
borderRadius: 'var(--radius-full)',
|
|
19
19
|
},
|
|
20
|
-
button: { height: 'var(--icon-touch)', width: '
|
|
20
|
+
button: { height: 'var(--icon-touch)', width: '100%' },
|
|
21
21
|
card: { height: '8rem', width: '100%' },
|
|
22
22
|
image: { height: '12rem', width: '100%' },
|
|
23
|
-
custom: {},
|
|
23
|
+
custom: { width: '100%' },
|
|
24
24
|
};
|
|
25
25
|
const animationClasses = {
|
|
26
26
|
pulse: 'dndev-skeleton-pulse',
|
|
@@ -56,10 +56,13 @@ function Skeleton({ className, variant = 'pulse', size = 'custom', width, height
|
|
|
56
56
|
const animationClass = animationClasses[variant];
|
|
57
57
|
const style = {
|
|
58
58
|
...sizeStyles,
|
|
59
|
+
// Width: explicit width prop overrides preset, otherwise use preset (defaults to 100%)
|
|
59
60
|
...(width && { width: typeof width === 'number' ? `${width}px` : width }),
|
|
61
|
+
// Height: explicit height prop overrides preset
|
|
60
62
|
...(height && {
|
|
61
63
|
height: typeof height === 'number' ? `${height}px` : height,
|
|
62
64
|
}),
|
|
65
|
+
// User-provided style overrides everything
|
|
63
66
|
...props.style,
|
|
64
67
|
};
|
|
65
68
|
if (lines > 1) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Switch component
|
|
3
3
|
* @description Accessible switch component built on Radix UI primitives with semantic color variants.
|
|
4
|
+
* Supports optional labels for binary choices (e.g., Manual/Automatic).
|
|
4
5
|
*
|
|
5
|
-
* @version 0.0.
|
|
6
|
+
* @version 0.0.2
|
|
6
7
|
* @since 0.0.1
|
|
7
8
|
* @author AMBROISE PARK Consulting
|
|
8
9
|
*/
|
|
@@ -14,21 +15,34 @@ import './Switch.css';
|
|
|
14
15
|
export interface SwitchProps extends ComponentProps<typeof SwitchPrimitives.Root> {
|
|
15
16
|
/** Semantic color variant */
|
|
16
17
|
variant?: ControlVariant;
|
|
18
|
+
/** Label for unchecked state (e.g., "Manual") */
|
|
19
|
+
uncheckedLabel?: string;
|
|
20
|
+
/** Label for checked state (e.g., "Automatic") */
|
|
21
|
+
checkedLabel?: string;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* Accessible switch control with semantic color variants.
|
|
20
|
-
* Supports
|
|
25
|
+
* Supports optional labels for binary choices with automatic active/inactive styling.
|
|
21
26
|
*
|
|
22
27
|
* @component
|
|
23
28
|
* @example
|
|
24
29
|
* ```tsx
|
|
30
|
+
* // Simple switch without labels
|
|
25
31
|
* <Switch checked={enabled} onCheckedChange={setEnabled} variant="success" />
|
|
26
|
-
*
|
|
32
|
+
*
|
|
33
|
+
* // Switch with labels (Manual/Automatic)
|
|
34
|
+
* <Switch
|
|
35
|
+
* checked={isAutomatic}
|
|
36
|
+
* onCheckedChange={setIsAutomatic}
|
|
37
|
+
* uncheckedLabel="Manual"
|
|
38
|
+
* checkedLabel="Automatic"
|
|
39
|
+
* variant="muted"
|
|
40
|
+
* />
|
|
27
41
|
* ```
|
|
28
42
|
* @param {SwitchProps} props - The props for the switch
|
|
29
43
|
* @returns {JSX.Element} The rendered switch
|
|
30
44
|
*/
|
|
31
|
-
declare const Switch: ({ className, variant, ...props }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
declare const Switch: ({ className, variant, uncheckedLabel, checkedLabel, checked, ...props }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
46
|
export default Switch;
|
|
33
47
|
export { SwitchPrimitive, CONTROL_VARIANT as SWITCH_VARIANT };
|
|
34
48
|
export type { ControlVariant as SwitchVariant };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Switch/index.tsx"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Switch/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,WAAY,SAAQ,cAAc,CACjD,OAAO,gBAAgB,CAAC,IAAI,CAC7B;IACC,6BAA6B;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAoBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,MAAM,GAAI,yEAOb,WAAW,4CAyCb,CAAC;AAEF,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,eAAe,IAAI,cAAc,EAAE,CAAC;AAC9D,YAAY,EAAE,cAAc,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// packages/components/src/atomic/Switch/index.tsx
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Switch component
|
|
5
5
|
* @description Accessible switch component built on Radix UI primitives with semantic color variants.
|
|
6
|
+
* Supports optional labels for binary choices (e.g., Manual/Automatic).
|
|
6
7
|
*
|
|
7
|
-
* @version 0.0.
|
|
8
|
+
* @version 0.0.2
|
|
8
9
|
* @since 0.0.1
|
|
9
10
|
* @author AMBROISE PARK Consulting
|
|
10
11
|
*/
|
|
@@ -34,20 +35,38 @@ const switchVariants = cva('dndev-switch', {
|
|
|
34
35
|
});
|
|
35
36
|
/**
|
|
36
37
|
* Accessible switch control with semantic color variants.
|
|
37
|
-
* Supports
|
|
38
|
+
* Supports optional labels for binary choices with automatic active/inactive styling.
|
|
38
39
|
*
|
|
39
40
|
* @component
|
|
40
41
|
* @example
|
|
41
42
|
* ```tsx
|
|
43
|
+
* // Simple switch without labels
|
|
42
44
|
* <Switch checked={enabled} onCheckedChange={setEnabled} variant="success" />
|
|
43
|
-
*
|
|
45
|
+
*
|
|
46
|
+
* // Switch with labels (Manual/Automatic)
|
|
47
|
+
* <Switch
|
|
48
|
+
* checked={isAutomatic}
|
|
49
|
+
* onCheckedChange={setIsAutomatic}
|
|
50
|
+
* uncheckedLabel="Manual"
|
|
51
|
+
* checkedLabel="Automatic"
|
|
52
|
+
* variant="muted"
|
|
53
|
+
* />
|
|
44
54
|
* ```
|
|
45
55
|
* @param {SwitchProps} props - The props for the switch
|
|
46
56
|
* @returns {JSX.Element} The rendered switch
|
|
47
57
|
*/
|
|
48
|
-
const Switch = ({ className, variant, ...props }) => {
|
|
58
|
+
const Switch = ({ className, variant, uncheckedLabel, checkedLabel, checked, ...props }) => {
|
|
49
59
|
const variantAttrs = getVariantDataAttrs({ variant });
|
|
50
|
-
|
|
60
|
+
const hasLabels = uncheckedLabel || checkedLabel;
|
|
61
|
+
const switchElement = (_jsx(SwitchPrimitives.Root, { className: cn(switchVariants({ variant }), className), ...variantAttrs, checked: checked, ...props, children: _jsx(SwitchPrimitives.Thumb, { className: cn('dndev-switch-thumb') }) }));
|
|
62
|
+
// If no labels, return just the switch
|
|
63
|
+
if (!hasLabels) {
|
|
64
|
+
return switchElement;
|
|
65
|
+
}
|
|
66
|
+
// With labels: render [uncheckedLabel] [Switch] [checkedLabel]
|
|
67
|
+
// Add data-checked attribute to container for CSS styling
|
|
68
|
+
const isChecked = checked ?? false;
|
|
69
|
+
return (_jsxs("div", { className: "dndev-switch-with-labels", "data-checked": isChecked ? 'true' : 'false', children: [uncheckedLabel && (_jsx("span", { className: "dndev-switch-label dndev-switch-label-unchecked", children: uncheckedLabel })), switchElement, checkedLabel && (_jsx("span", { className: "dndev-switch-label dndev-switch-label-checked", children: checkedLabel }))] }));
|
|
51
70
|
};
|
|
52
71
|
export default Switch;
|
|
53
72
|
export { SwitchPrimitive, CONTROL_VARIANT as SWITCH_VARIANT };
|
|
@@ -3,9 +3,10 @@ import './Table.css';
|
|
|
3
3
|
/**
|
|
4
4
|
* Table column configuration
|
|
5
5
|
*
|
|
6
|
-
* LAYOUT
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* LAYOUT EXCEPTIONS:
|
|
7
|
+
* - `width`: Layout control for structural column layout (not styling)
|
|
8
|
+
* - `render`: Render prop pattern for custom cell content (modern children pattern)
|
|
9
|
+
* This is the preferred way to handle dynamic cell content vs nested component composition.
|
|
9
10
|
*
|
|
10
11
|
* @version 0.0.1
|
|
11
12
|
* @since 0.0.1
|
|
@@ -13,10 +14,16 @@ import './Table.css';
|
|
|
13
14
|
*/
|
|
14
15
|
export interface TableColumn<T = any> {
|
|
15
16
|
key: string;
|
|
16
|
-
|
|
17
|
+
/** Column header - can be a string or ReactNode (e.g., Button, icon) */
|
|
18
|
+
title: string | ReactNode;
|
|
17
19
|
dataIndex?: keyof T;
|
|
18
20
|
sortable?: boolean;
|
|
19
21
|
filterable?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Render prop for custom cell content - RENDER PROP EXCEPTION
|
|
24
|
+
* Modern pattern for dynamic content generation. Preferred over nested component composition.
|
|
25
|
+
* Allows rendering custom components (buttons, inputs, etc.) within table cells.
|
|
26
|
+
*/
|
|
20
27
|
render?: (value: any, record: T, index: number) => ReactNode;
|
|
21
28
|
/**
|
|
22
29
|
* Column width - LAYOUT EXCEPTION
|
|
@@ -26,9 +33,10 @@ export interface TableColumn<T = any> {
|
|
|
26
33
|
width?: string | number;
|
|
27
34
|
/**
|
|
28
35
|
* Text alignment - LAYOUT CONTROL
|
|
29
|
-
* Semantic alignment for data presentation (
|
|
36
|
+
* Semantic alignment for data presentation (start for text, end for numbers).
|
|
37
|
+
* Uses logical alignment for RTL support.
|
|
30
38
|
*/
|
|
31
|
-
align?: '
|
|
39
|
+
align?: 'start' | 'center' | 'end';
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* Data table component props
|
|
@@ -56,6 +64,8 @@ export interface DataTableProps<T = any> {
|
|
|
56
64
|
pageSize?: number;
|
|
57
65
|
/** Loading state */
|
|
58
66
|
loading?: boolean;
|
|
67
|
+
/** Excel-like grid lines (borders on all cells) */
|
|
68
|
+
gridLines?: boolean;
|
|
59
69
|
/** Callback when sorting changes */
|
|
60
70
|
onSort?: (column: string, direction: 'asc' | 'desc') => void;
|
|
61
71
|
/** Callback when selection changes */
|
|
@@ -98,7 +108,7 @@ declare function TableCaption({ className, ...props }: HTMLAttributes<HTMLTableC
|
|
|
98
108
|
* @param {DataTableProps} props - The props for the data table
|
|
99
109
|
* @returns {ReactNode} The rendered data table
|
|
100
110
|
*/
|
|
101
|
-
declare const DataTable: <T = any>({ data, columns, sortable, selectable, searchable, filterable, pagination, pageSize, loading, onSort, onSelect, onSearch, onFilter, className, }: DataTableProps<T>) => ReactNode;
|
|
111
|
+
declare const DataTable: <T = any>({ data, columns, sortable, selectable, searchable, filterable, pagination, pageSize, loading, gridLines, onSort, onSelect, onSearch, onFilter, className, }: DataTableProps<T>) => ReactNode;
|
|
102
112
|
export default Table;
|
|
103
113
|
export { TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, DataTable, };
|
|
104
114
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Table/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Table/index.ts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