@puzzle-ui/ui 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/components/actions/button/button.css +5 -2
- package/dist/components/actions/button-group/button-group.css +16 -17
- package/dist/components/data-display/badge/badge.css +15 -2
- package/dist/components/data-display/badge/index.cjs +13 -2
- package/dist/components/data-display/badge/index.cjs.map +1 -1
- package/dist/components/data-display/badge/index.d.cts +7 -2
- package/dist/components/data-display/badge/index.d.ts +7 -2
- package/dist/components/data-display/badge/index.js +13 -2
- package/dist/components/data-display/badge/index.js.map +1 -1
- package/dist/components/data-display/rating/index.cjs +84 -0
- package/dist/components/data-display/rating/index.cjs.map +1 -0
- package/dist/components/data-display/rating/index.d.cts +3 -0
- package/dist/components/data-display/rating/index.d.ts +3 -0
- package/dist/components/data-display/rating/index.js +84 -0
- package/dist/components/data-display/rating/index.js.map +1 -0
- package/dist/components/data-display/rating/rating.css +72 -0
- package/dist/components/data-display/rating/rating.types.d.cts +15 -0
- package/dist/components/data-display/rating/rating.types.d.ts +15 -0
- package/dist/components/data-display/rating/rating.utils.cjs +27 -0
- package/dist/components/data-display/rating/rating.utils.cjs.map +1 -0
- package/dist/components/data-display/rating/rating.utils.js +25 -0
- package/dist/components/data-display/rating/rating.utils.js.map +1 -0
- package/dist/components/forms/checkbox/checkbox.css +2 -10
- package/dist/components/forms/input-group/input-group.d.cts +4 -2
- package/dist/components/forms/input-group/input-group.d.ts +4 -2
- package/dist/components/forms/radio-group/index.d.cts +2 -1
- package/dist/components/forms/radio-group/index.d.ts +2 -1
- package/dist/components/forms/stepper/index.d.cts +4 -2
- package/dist/components/forms/stepper/index.d.ts +4 -2
- package/dist/components/forms/time-picker/index.cjs +108 -0
- package/dist/components/forms/time-picker/index.cjs.map +1 -0
- package/dist/components/forms/time-picker/index.d.cts +3 -0
- package/dist/components/forms/time-picker/index.d.ts +3 -0
- package/dist/components/forms/time-picker/index.js +108 -0
- package/dist/components/forms/time-picker/index.js.map +1 -0
- package/dist/components/forms/time-picker/time-picker.css +166 -0
- package/dist/components/forms/time-picker/time-picker.types.d.cts +34 -0
- package/dist/components/forms/time-picker/time-picker.types.d.ts +34 -0
- package/dist/components/forms/time-picker/time-picker.utils.cjs +25 -0
- package/dist/components/forms/time-picker/time-picker.utils.cjs.map +1 -0
- package/dist/components/forms/time-picker/time-picker.utils.js +24 -0
- package/dist/components/forms/time-picker/time-picker.utils.js.map +1 -0
- package/dist/components/forms/token-input/index.cjs +189 -0
- package/dist/components/forms/token-input/index.cjs.map +1 -0
- package/dist/components/forms/token-input/index.d.cts +3 -0
- package/dist/components/forms/token-input/index.d.ts +3 -0
- package/dist/components/forms/token-input/index.js +189 -0
- package/dist/components/forms/token-input/index.js.map +1 -0
- package/dist/components/forms/token-input/token-input.css +145 -0
- package/dist/components/forms/token-input/token-input.types.d.cts +48 -0
- package/dist/components/forms/token-input/token-input.types.d.ts +48 -0
- package/dist/components/forms/token-input/token-input.utils.cjs +30 -0
- package/dist/components/forms/token-input/token-input.utils.cjs.map +1 -0
- package/dist/components/forms/token-input/token-input.utils.js +24 -0
- package/dist/components/forms/token-input/token-input.utils.js.map +1 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.css +14 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.utils.cjs +11 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.utils.cjs.map +1 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.utils.js +11 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.utils.js.map +1 -0
- package/dist/components/layout/aspect-ratio/index.cjs +16 -0
- package/dist/components/layout/aspect-ratio/index.cjs.map +1 -0
- package/dist/components/layout/aspect-ratio/index.d.cts +11 -0
- package/dist/components/layout/aspect-ratio/index.d.ts +11 -0
- package/dist/components/layout/aspect-ratio/index.js +16 -0
- package/dist/components/layout/aspect-ratio/index.js.map +1 -0
- package/dist/components/layout/container/container.css +1 -0
- package/dist/components/layout/page-layout/page-layout.css +1 -0
- package/dist/components/layout/scroll-area/index.cjs +27 -0
- package/dist/components/layout/scroll-area/index.cjs.map +1 -0
- package/dist/components/layout/scroll-area/index.d.cts +15 -0
- package/dist/components/layout/scroll-area/index.d.ts +15 -0
- package/dist/components/layout/scroll-area/index.js +27 -0
- package/dist/components/layout/scroll-area/index.js.map +1 -0
- package/dist/components/layout/scroll-area/scroll-area.css +25 -0
- package/dist/components/layout/scroll-area/scroll-area.utils.cjs +8 -0
- package/dist/components/layout/scroll-area/scroll-area.utils.cjs.map +1 -0
- package/dist/components/layout/scroll-area/scroll-area.utils.d.cts +2 -0
- package/dist/components/layout/scroll-area/scroll-area.utils.d.ts +2 -0
- package/dist/components/layout/scroll-area/scroll-area.utils.js +8 -0
- package/dist/components/layout/scroll-area/scroll-area.utils.js.map +1 -0
- package/dist/components/layout/section/index.cjs +10 -4
- package/dist/components/layout/section/index.cjs.map +1 -1
- package/dist/components/layout/section/index.d.cts +1 -1
- package/dist/components/layout/section/index.d.ts +1 -1
- package/dist/components/layout/section/index.js +11 -5
- package/dist/components/layout/section/index.js.map +1 -1
- package/dist/components/layout/section/section.css +9 -3
- package/dist/components/layout/section/types.d.cts +5 -5
- package/dist/components/layout/section/types.d.ts +5 -5
- package/dist/components/layout/separator/index.cjs +18 -0
- package/dist/components/layout/separator/index.cjs.map +1 -0
- package/dist/components/layout/separator/index.d.cts +17 -0
- package/dist/components/layout/separator/index.d.ts +17 -0
- package/dist/components/layout/separator/index.js +18 -0
- package/dist/components/layout/separator/index.js.map +1 -0
- package/dist/components/layout/separator/separator.css +15 -0
- package/dist/components/layout/separator/separator.utils.cjs +11 -0
- package/dist/components/layout/separator/separator.utils.cjs.map +1 -0
- package/dist/components/layout/separator/separator.utils.d.cts +2 -0
- package/dist/components/layout/separator/separator.utils.d.ts +2 -0
- package/dist/components/layout/separator/separator.utils.js +11 -0
- package/dist/components/layout/separator/separator.utils.js.map +1 -0
- package/dist/components/layout/stack/index.cjs +18 -2
- package/dist/components/layout/stack/index.cjs.map +1 -1
- package/dist/components/layout/stack/index.d.cts +8 -6
- package/dist/components/layout/stack/index.d.ts +8 -6
- package/dist/components/layout/stack/index.js +18 -2
- package/dist/components/layout/stack/index.js.map +1 -1
- package/dist/components/layout/stack/stack.css +118 -138
- package/dist/components/navigation/carousel/index.cjs +4 -1
- package/dist/components/navigation/carousel/index.cjs.map +1 -1
- package/dist/components/navigation/carousel/index.js +4 -1
- package/dist/components/navigation/carousel/index.js.map +1 -1
- package/dist/components/navigation/tabs/index.d.cts +3 -2
- package/dist/components/navigation/tabs/index.d.ts +3 -2
- package/dist/components/overlays/context-menu/context-menu.css +151 -0
- package/dist/components/overlays/context-menu/context-menu.types.d.cts +69 -0
- package/dist/components/overlays/context-menu/context-menu.types.d.ts +69 -0
- package/dist/components/overlays/context-menu/context-menu.utils.cjs +46 -0
- package/dist/components/overlays/context-menu/context-menu.utils.cjs.map +1 -0
- package/dist/components/overlays/context-menu/context-menu.utils.js +40 -0
- package/dist/components/overlays/context-menu/context-menu.utils.js.map +1 -0
- package/dist/components/overlays/context-menu/index.cjs +830 -0
- package/dist/components/overlays/context-menu/index.cjs.map +1 -0
- package/dist/components/overlays/context-menu/index.d.cts +42 -0
- package/dist/components/overlays/context-menu/index.d.ts +42 -0
- package/dist/components/overlays/context-menu/index.js +818 -0
- package/dist/components/overlays/context-menu/index.js.map +1 -0
- package/dist/components/typography/heading.cjs +6 -2
- package/dist/components/typography/heading.cjs.map +1 -1
- package/dist/components/typography/heading.d.cts +3 -2
- package/dist/components/typography/heading.d.ts +3 -2
- package/dist/components/typography/heading.js +6 -2
- package/dist/components/typography/heading.js.map +1 -1
- package/dist/components/typography/text.cjs +6 -2
- package/dist/components/typography/text.cjs.map +1 -1
- package/dist/components/typography/text.d.cts +3 -2
- package/dist/components/typography/text.d.ts +3 -2
- package/dist/components/typography/text.js +6 -2
- package/dist/components/typography/text.js.map +1 -1
- package/dist/components/utilities/preview/index.cjs +88 -20
- package/dist/components/utilities/preview/index.cjs.map +1 -1
- package/dist/components/utilities/preview/index.d.cts +6 -2
- package/dist/components/utilities/preview/index.d.ts +6 -2
- package/dist/components/utilities/preview/index.js +88 -20
- package/dist/components/utilities/preview/index.js.map +1 -1
- package/dist/components/utilities/preview/preview.css +26 -11
- package/dist/components/utilities/transition/index.d.cts +1 -1
- package/dist/components/utilities/transition/index.d.ts +1 -1
- package/dist/index.cjs +123 -97
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +8 -1
- package/package.json +6 -6
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
.puzzle-token-input {
|
|
2
|
+
align-items: flex-start;
|
|
3
|
+
gap: var(--puzzle-space-2, .5rem);
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
width: fit-content;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
display: flex;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.puzzle-token-input__label {
|
|
12
|
+
color: var(--puzzle-color-text);
|
|
13
|
+
font-size: var(--puzzle-font-size-sm, .875rem);
|
|
14
|
+
font-weight: var(--puzzle-font-weight-medium, 500);
|
|
15
|
+
line-height: var(--puzzle-font-line-height-normal, 1.5);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.puzzle-token-input__slots {
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--puzzle-space-2, .5rem);
|
|
21
|
+
direction: ltr;
|
|
22
|
+
flex-wrap: nowrap;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
display: flex;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.puzzle-token-input__slot {
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
border: var(--puzzle-border-width, 1px) solid var(--puzzle-color-border);
|
|
30
|
+
border-radius: var(--puzzle-radius-md, .5rem);
|
|
31
|
+
background: var(--puzzle-color-surface);
|
|
32
|
+
width: 2.5rem;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
height: 2.75rem;
|
|
35
|
+
color: var(--puzzle-color-text);
|
|
36
|
+
font: inherit;
|
|
37
|
+
font-size: 1.125rem;
|
|
38
|
+
font-weight: var(--puzzle-font-weight-medium, 500);
|
|
39
|
+
text-align: center;
|
|
40
|
+
font-variant-numeric: tabular-nums;
|
|
41
|
+
caret-color: var(--puzzle-color-ring);
|
|
42
|
+
touch-action: manipulation;
|
|
43
|
+
-webkit-tap-highlight-color: transparent;
|
|
44
|
+
transition: border-color var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease),
|
|
45
|
+
box-shadow var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease),
|
|
46
|
+
background-color var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease);
|
|
47
|
+
outline: none;
|
|
48
|
+
flex: none;
|
|
49
|
+
padding: 0;
|
|
50
|
+
line-height: 1;
|
|
51
|
+
display: block;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.puzzle-token-input__slot:hover:not(:disabled) {
|
|
55
|
+
border-color: var(--puzzle-color-text-muted);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.puzzle-token-input__slot:focus {
|
|
59
|
+
border-color: var(--puzzle-color-ring);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.puzzle-token-input__slot:focus-visible {
|
|
63
|
+
outline: 2px solid var(--puzzle-color-ring);
|
|
64
|
+
outline-offset: 2px;
|
|
65
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--puzzle-color-ring), transparent 82%);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.puzzle-token-input[data-invalid="true"] .puzzle-token-input__slot {
|
|
69
|
+
border-color: var(--puzzle-color-danger);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.puzzle-token-input[data-invalid="true"] .puzzle-token-input__slot:focus-visible {
|
|
73
|
+
outline-color: var(--puzzle-color-danger);
|
|
74
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--puzzle-color-danger), transparent 82%);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.puzzle-token-input[data-disabled="true"] {
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.puzzle-token-input[data-disabled="true"] .puzzle-token-input__slot {
|
|
82
|
+
opacity: .6;
|
|
83
|
+
cursor: not-allowed;
|
|
84
|
+
background: var(--puzzle-color-surface-sunken);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.puzzle-token-input[data-readonly="true"] .puzzle-token-input__slot {
|
|
88
|
+
cursor: default;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.puzzle-token-input[data-size="sm"] .puzzle-token-input__slot {
|
|
92
|
+
width: 2rem;
|
|
93
|
+
height: 2.25rem;
|
|
94
|
+
font-size: var(--puzzle-font-size-sm, .875rem);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.puzzle-token-input[data-size="md"] .puzzle-token-input__slot {
|
|
98
|
+
width: 2.5rem;
|
|
99
|
+
height: 2.75rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.puzzle-token-input[data-size="lg"] .puzzle-token-input__slot {
|
|
103
|
+
width: 3rem;
|
|
104
|
+
height: 3.25rem;
|
|
105
|
+
font-size: 1.375rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@media (width <= 360px) {
|
|
109
|
+
.puzzle-token-input__slots {
|
|
110
|
+
gap: var(--puzzle-space-1, .25rem);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.puzzle-token-input[data-size="md"] .puzzle-token-input__slot {
|
|
114
|
+
width: 2.25rem;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (forced-colors: active) {
|
|
119
|
+
.puzzle-token-input__slot {
|
|
120
|
+
color: fieldtext;
|
|
121
|
+
forced-color-adjust: auto;
|
|
122
|
+
background: field;
|
|
123
|
+
border-color: fieldtext;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.puzzle-token-input__slot:focus-visible {
|
|
127
|
+
outline-offset: 2px;
|
|
128
|
+
outline: 2px solid highlight;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.puzzle-token-input__slot:disabled {
|
|
132
|
+
color: graytext;
|
|
133
|
+
border-color: graytext;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.puzzle-token-input[data-invalid="true"] .puzzle-token-input__slot {
|
|
137
|
+
border-color: mark;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@media (prefers-reduced-motion: reduce) {
|
|
142
|
+
.puzzle-token-input__slot {
|
|
143
|
+
transition: none;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, ReactNode, Ref } from "react";
|
|
2
|
+
type TokenInputMode = "numeric" | "alphanumeric";
|
|
3
|
+
type TokenInputSize = "sm" | "md" | "lg";
|
|
4
|
+
type TokenInputProps = Omit<ComponentPropsWithoutRef<"div">, "children" | "id" | "onChange" | "onFocus" | "onBlur" | "onKeyDown"> & {
|
|
5
|
+
/** Number of characters in the token. Defaults to 6. */
|
|
6
|
+
length?: number;
|
|
7
|
+
/** Controlled token value. */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Initial value for uncontrolled usage. */
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
/** Called whenever the token value changes. */
|
|
12
|
+
onValueChange?: (value: string) => void;
|
|
13
|
+
/** Called when the token transitions from incomplete to complete. */
|
|
14
|
+
onComplete?: (value: string) => void;
|
|
15
|
+
/** Allowed characters. Defaults to numeric. */
|
|
16
|
+
mode?: TokenInputMode;
|
|
17
|
+
/** Masks the entered characters. */
|
|
18
|
+
mask?: boolean;
|
|
19
|
+
/** Disables all inputs. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Makes all inputs read-only. */
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
/** Marks every character input as required. */
|
|
24
|
+
required?: boolean;
|
|
25
|
+
/** Visual size of the individual character slots. */
|
|
26
|
+
size?: TokenInputSize;
|
|
27
|
+
/** Visible label associated with the first input. */
|
|
28
|
+
label?: ReactNode;
|
|
29
|
+
/** ID applied to the first native input. */
|
|
30
|
+
id?: string;
|
|
31
|
+
/** Name used for native form submission. */
|
|
32
|
+
name?: string;
|
|
33
|
+
/** Associates the hidden form input with a form. */
|
|
34
|
+
form?: string;
|
|
35
|
+
/** Input mode for the native character inputs. */
|
|
36
|
+
inputMode?: InputHTMLAttributes<HTMLInputElement>["inputMode"];
|
|
37
|
+
/** Autocomplete mode for the first character input. */
|
|
38
|
+
autoComplete?: InputHTMLAttributes<HTMLInputElement>["autoComplete"];
|
|
39
|
+
/** Ref forwarded to the first native input. */
|
|
40
|
+
ref?: Ref<HTMLInputElement>;
|
|
41
|
+
/** Called when an individual character input receives focus. */
|
|
42
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
43
|
+
/** Called when an individual character input loses focus. */
|
|
44
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
45
|
+
/** Called when an individual character input receives a key event. */
|
|
46
|
+
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
47
|
+
};
|
|
48
|
+
export type { TokenInputMode, TokenInputProps, TokenInputSize };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, ReactNode, Ref } from "react";
|
|
2
|
+
type TokenInputMode = "numeric" | "alphanumeric";
|
|
3
|
+
type TokenInputSize = "sm" | "md" | "lg";
|
|
4
|
+
type TokenInputProps = Omit<ComponentPropsWithoutRef<"div">, "children" | "id" | "onChange" | "onFocus" | "onBlur" | "onKeyDown"> & {
|
|
5
|
+
/** Number of characters in the token. Defaults to 6. */
|
|
6
|
+
length?: number;
|
|
7
|
+
/** Controlled token value. */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Initial value for uncontrolled usage. */
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
/** Called whenever the token value changes. */
|
|
12
|
+
onValueChange?: (value: string) => void;
|
|
13
|
+
/** Called when the token transitions from incomplete to complete. */
|
|
14
|
+
onComplete?: (value: string) => void;
|
|
15
|
+
/** Allowed characters. Defaults to numeric. */
|
|
16
|
+
mode?: TokenInputMode;
|
|
17
|
+
/** Masks the entered characters. */
|
|
18
|
+
mask?: boolean;
|
|
19
|
+
/** Disables all inputs. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Makes all inputs read-only. */
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
/** Marks every character input as required. */
|
|
24
|
+
required?: boolean;
|
|
25
|
+
/** Visual size of the individual character slots. */
|
|
26
|
+
size?: TokenInputSize;
|
|
27
|
+
/** Visible label associated with the first input. */
|
|
28
|
+
label?: ReactNode;
|
|
29
|
+
/** ID applied to the first native input. */
|
|
30
|
+
id?: string;
|
|
31
|
+
/** Name used for native form submission. */
|
|
32
|
+
name?: string;
|
|
33
|
+
/** Associates the hidden form input with a form. */
|
|
34
|
+
form?: string;
|
|
35
|
+
/** Input mode for the native character inputs. */
|
|
36
|
+
inputMode?: InputHTMLAttributes<HTMLInputElement>["inputMode"];
|
|
37
|
+
/** Autocomplete mode for the first character input. */
|
|
38
|
+
autoComplete?: InputHTMLAttributes<HTMLInputElement>["autoComplete"];
|
|
39
|
+
/** Ref forwarded to the first native input. */
|
|
40
|
+
ref?: Ref<HTMLInputElement>;
|
|
41
|
+
/** Called when an individual character input receives focus. */
|
|
42
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
43
|
+
/** Called when an individual character input loses focus. */
|
|
44
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
45
|
+
/** Called when an individual character input receives a key event. */
|
|
46
|
+
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
47
|
+
};
|
|
48
|
+
export type { TokenInputMode, TokenInputProps, TokenInputSize };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/components/forms/token-input/token-input.utils.ts
|
|
2
|
+
const sanitizeToken = (value, length, mode = "numeric") => {
|
|
3
|
+
return (mode === "numeric" ? value.replace(/[^0-9]/g, "") : value.replace(/[^a-zA-Z0-9]/g, "")).slice(0, Math.max(0, length));
|
|
4
|
+
};
|
|
5
|
+
const getNextActiveIndex = (value, length) => Math.min(value.length, length - 1);
|
|
6
|
+
const getPreviousActiveIndex = (index) => Math.max(0, index - 1);
|
|
7
|
+
const isTokenComplete = (value, length) => value.length === length;
|
|
8
|
+
const removeTokenCharacter = (value, index) => value.slice(0, index) + value.slice(index + 1);
|
|
9
|
+
const replaceTokenCharacter = (value, index, character, length, mode) => {
|
|
10
|
+
const normalized = sanitizeToken(character, length, mode);
|
|
11
|
+
if (!normalized) return removeTokenCharacter(value, index);
|
|
12
|
+
return sanitizeToken(value.slice(0, index) + normalized[0] + value.slice(index + 1), length, mode);
|
|
13
|
+
};
|
|
14
|
+
const insertTokenCharacters = (value, index, insertedValue, length, mode) => {
|
|
15
|
+
const normalized = sanitizeToken(insertedValue, length, mode);
|
|
16
|
+
if (!normalized) return value;
|
|
17
|
+
if (normalized.length >= length) return normalized.slice(0, length);
|
|
18
|
+
if (normalized.length === 1) return replaceTokenCharacter(value, index, normalized, length, mode);
|
|
19
|
+
const start = Math.max(0, Math.min(index, length));
|
|
20
|
+
return sanitizeToken(value.slice(0, start) + normalized + value.slice(start + normalized.length), length, mode);
|
|
21
|
+
};
|
|
22
|
+
exports.getNextActiveIndex = getNextActiveIndex;
|
|
23
|
+
exports.getPreviousActiveIndex = getPreviousActiveIndex;
|
|
24
|
+
exports.insertTokenCharacters = insertTokenCharacters;
|
|
25
|
+
exports.isTokenComplete = isTokenComplete;
|
|
26
|
+
exports.removeTokenCharacter = removeTokenCharacter;
|
|
27
|
+
exports.replaceTokenCharacter = replaceTokenCharacter;
|
|
28
|
+
exports.sanitizeToken = sanitizeToken;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=token-input.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-input.utils.cjs","names":[],"sources":["../../../../src/components/forms/token-input/token-input.utils.ts"],"sourcesContent":["import type { TokenInputMode } from \"./token-input.types\";\n\nconst sanitizeToken = (\n value: string,\n length: number,\n mode: TokenInputMode = \"numeric\",\n): string => {\n const normalized =\n mode === \"numeric\"\n ? value.replace(/[^0-9]/g, \"\")\n : value.replace(/[^a-zA-Z0-9]/g, \"\");\n\n return normalized.slice(0, Math.max(0, length));\n};\n\nconst getNextActiveIndex = (value: string, length: number): number =>\n Math.min(value.length, length - 1);\n\nconst getPreviousActiveIndex = (index: number): number =>\n Math.max(0, index - 1);\n\nconst isTokenComplete = (value: string, length: number): boolean =>\n value.length === length;\n\nconst removeTokenCharacter = (value: string, index: number): string =>\n value.slice(0, index) + value.slice(index + 1);\n\nconst replaceTokenCharacter = (\n value: string,\n index: number,\n character: string,\n length: number,\n mode: TokenInputMode,\n): string => {\n const normalized = sanitizeToken(character, length, mode);\n\n if (!normalized) {\n return removeTokenCharacter(value, index);\n }\n\n return sanitizeToken(\n value.slice(0, index) + normalized[0] + value.slice(index + 1),\n length,\n mode,\n );\n};\n\nconst insertTokenCharacters = (\n value: string,\n index: number,\n insertedValue: string,\n length: number,\n mode: TokenInputMode,\n): string => {\n const normalized = sanitizeToken(insertedValue, length, mode);\n\n if (!normalized) {\n return value;\n }\n\n // A complete token always replaces the existing token.\n if (normalized.length >= length) {\n return normalized.slice(0, length);\n }\n\n // A single character replaces the current position.\n if (normalized.length === 1) {\n return replaceTokenCharacter(value, index, normalized, length, mode);\n }\n\n // Multiple characters are inserted at the current position.\n const start = Math.max(0, Math.min(index, length));\n\n return sanitizeToken(\n value.slice(0, start) + normalized + value.slice(start + normalized.length),\n length,\n mode,\n );\n};\n\nexport {\n sanitizeToken,\n getNextActiveIndex,\n getPreviousActiveIndex,\n isTokenComplete,\n removeTokenCharacter,\n replaceTokenCharacter,\n insertTokenCharacters,\n};\n"],"mappings":";AAEA,MAAM,iBACJ,OACA,QACA,OAAuB,cACZ;CAMX,QAJE,SAAS,YACL,MAAM,QAAQ,WAAW,EAAE,IAC3B,MAAM,QAAQ,iBAAiB,EAAE,EAAA,CAErB,MAAM,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC;AAChD;AAEA,MAAM,sBAAsB,OAAe,WACzC,KAAK,IAAI,MAAM,QAAQ,SAAS,CAAC;AAEnC,MAAM,0BAA0B,UAC9B,KAAK,IAAI,GAAG,QAAQ,CAAC;AAEvB,MAAM,mBAAmB,OAAe,WACtC,MAAM,WAAW;AAEnB,MAAM,wBAAwB,OAAe,UAC3C,MAAM,MAAM,GAAG,KAAK,IAAI,MAAM,MAAM,QAAQ,CAAC;AAE/C,MAAM,yBACJ,OACA,OACA,WACA,QACA,SACW;CACX,MAAM,aAAa,cAAc,WAAW,QAAQ,IAAI;CAExD,IAAI,CAAC,YACH,OAAO,qBAAqB,OAAO,KAAK;CAG1C,OAAO,cACL,MAAM,MAAM,GAAG,KAAK,IAAI,WAAW,KAAK,MAAM,MAAM,QAAQ,CAAC,GAC7D,QACA,IACF;AACF;AAEA,MAAM,yBACJ,OACA,OACA,eACA,QACA,SACW;CACX,MAAM,aAAa,cAAc,eAAe,QAAQ,IAAI;CAE5D,IAAI,CAAC,YACH,OAAO;CAIT,IAAI,WAAW,UAAU,QACvB,OAAO,WAAW,MAAM,GAAG,MAAM;CAInC,IAAI,WAAW,WAAW,GACxB,OAAO,sBAAsB,OAAO,OAAO,YAAY,QAAQ,IAAI;CAIrE,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,MAAM,CAAC;CAEjD,OAAO,cACL,MAAM,MAAM,GAAG,KAAK,IAAI,aAAa,MAAM,MAAM,QAAQ,WAAW,MAAM,GAC1E,QACA,IACF;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/components/forms/token-input/token-input.utils.ts
|
|
2
|
+
const sanitizeToken = (value, length, mode = "numeric") => {
|
|
3
|
+
return (mode === "numeric" ? value.replace(/[^0-9]/g, "") : value.replace(/[^a-zA-Z0-9]/g, "")).slice(0, Math.max(0, length));
|
|
4
|
+
};
|
|
5
|
+
const getNextActiveIndex = (value, length) => Math.min(value.length, length - 1);
|
|
6
|
+
const getPreviousActiveIndex = (index) => Math.max(0, index - 1);
|
|
7
|
+
const isTokenComplete = (value, length) => value.length === length;
|
|
8
|
+
const removeTokenCharacter = (value, index) => value.slice(0, index) + value.slice(index + 1);
|
|
9
|
+
const replaceTokenCharacter = (value, index, character, length, mode) => {
|
|
10
|
+
const normalized = sanitizeToken(character, length, mode);
|
|
11
|
+
if (!normalized) return removeTokenCharacter(value, index);
|
|
12
|
+
return sanitizeToken(value.slice(0, index) + normalized[0] + value.slice(index + 1), length, mode);
|
|
13
|
+
};
|
|
14
|
+
const insertTokenCharacters = (value, index, insertedValue, length, mode) => {
|
|
15
|
+
const normalized = sanitizeToken(insertedValue, length, mode);
|
|
16
|
+
if (!normalized) return value;
|
|
17
|
+
if (normalized.length >= length) return normalized.slice(0, length);
|
|
18
|
+
if (normalized.length === 1) return replaceTokenCharacter(value, index, normalized, length, mode);
|
|
19
|
+
const start = Math.max(0, Math.min(index, length));
|
|
20
|
+
return sanitizeToken(value.slice(0, start) + normalized + value.slice(start + normalized.length), length, mode);
|
|
21
|
+
};
|
|
22
|
+
export { getNextActiveIndex, getPreviousActiveIndex, insertTokenCharacters, isTokenComplete, removeTokenCharacter, replaceTokenCharacter, sanitizeToken };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=token-input.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-input.utils.js","names":[],"sources":["../../../../src/components/forms/token-input/token-input.utils.ts"],"sourcesContent":["import type { TokenInputMode } from \"./token-input.types\";\n\nconst sanitizeToken = (\n value: string,\n length: number,\n mode: TokenInputMode = \"numeric\",\n): string => {\n const normalized =\n mode === \"numeric\"\n ? value.replace(/[^0-9]/g, \"\")\n : value.replace(/[^a-zA-Z0-9]/g, \"\");\n\n return normalized.slice(0, Math.max(0, length));\n};\n\nconst getNextActiveIndex = (value: string, length: number): number =>\n Math.min(value.length, length - 1);\n\nconst getPreviousActiveIndex = (index: number): number =>\n Math.max(0, index - 1);\n\nconst isTokenComplete = (value: string, length: number): boolean =>\n value.length === length;\n\nconst removeTokenCharacter = (value: string, index: number): string =>\n value.slice(0, index) + value.slice(index + 1);\n\nconst replaceTokenCharacter = (\n value: string,\n index: number,\n character: string,\n length: number,\n mode: TokenInputMode,\n): string => {\n const normalized = sanitizeToken(character, length, mode);\n\n if (!normalized) {\n return removeTokenCharacter(value, index);\n }\n\n return sanitizeToken(\n value.slice(0, index) + normalized[0] + value.slice(index + 1),\n length,\n mode,\n );\n};\n\nconst insertTokenCharacters = (\n value: string,\n index: number,\n insertedValue: string,\n length: number,\n mode: TokenInputMode,\n): string => {\n const normalized = sanitizeToken(insertedValue, length, mode);\n\n if (!normalized) {\n return value;\n }\n\n // A complete token always replaces the existing token.\n if (normalized.length >= length) {\n return normalized.slice(0, length);\n }\n\n // A single character replaces the current position.\n if (normalized.length === 1) {\n return replaceTokenCharacter(value, index, normalized, length, mode);\n }\n\n // Multiple characters are inserted at the current position.\n const start = Math.max(0, Math.min(index, length));\n\n return sanitizeToken(\n value.slice(0, start) + normalized + value.slice(start + normalized.length),\n length,\n mode,\n );\n};\n\nexport {\n sanitizeToken,\n getNextActiveIndex,\n getPreviousActiveIndex,\n isTokenComplete,\n removeTokenCharacter,\n replaceTokenCharacter,\n insertTokenCharacters,\n};\n"],"mappings":";AAEA,MAAM,iBACJ,OACA,QACA,OAAuB,cACZ;CAMX,QAJE,SAAS,YACL,MAAM,QAAQ,WAAW,EAAE,IAC3B,MAAM,QAAQ,iBAAiB,EAAE,EAAA,CAErB,MAAM,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC;AAChD;AAEA,MAAM,sBAAsB,OAAe,WACzC,KAAK,IAAI,MAAM,QAAQ,SAAS,CAAC;AAEnC,MAAM,0BAA0B,UAC9B,KAAK,IAAI,GAAG,QAAQ,CAAC;AAEvB,MAAM,mBAAmB,OAAe,WACtC,MAAM,WAAW;AAEnB,MAAM,wBAAwB,OAAe,UAC3C,MAAM,MAAM,GAAG,KAAK,IAAI,MAAM,MAAM,QAAQ,CAAC;AAE/C,MAAM,yBACJ,OACA,OACA,WACA,QACA,SACW;CACX,MAAM,aAAa,cAAc,WAAW,QAAQ,IAAI;CAExD,IAAI,CAAC,YACH,OAAO,qBAAqB,OAAO,KAAK;CAG1C,OAAO,cACL,MAAM,MAAM,GAAG,KAAK,IAAI,WAAW,KAAK,MAAM,MAAM,QAAQ,CAAC,GAC7D,QACA,IACF;AACF;AAEA,MAAM,yBACJ,OACA,OACA,eACA,QACA,SACW;CACX,MAAM,aAAa,cAAc,eAAe,QAAQ,IAAI;CAE5D,IAAI,CAAC,YACH,OAAO;CAIT,IAAI,WAAW,UAAU,QACvB,OAAO,WAAW,MAAM,GAAG,MAAM;CAInC,IAAI,WAAW,WAAW,GACxB,OAAO,sBAAsB,OAAO,OAAO,YAAY,QAAQ,IAAI;CAIrE,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,MAAM,CAAC;CAEjD,OAAO,cACL,MAAM,MAAM,GAAG,KAAK,IAAI,aAAa,MAAM,MAAM,QAAQ,WAAW,MAAM,GAC1E,QACA,IACF;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/components/layout/aspect-ratio/aspect-ratio.utils.ts
|
|
2
|
+
const getAspectRatioStyle = (ratio, style) => {
|
|
3
|
+
if (!Number.isFinite(ratio) || ratio <= 0) throw new RangeError("AspectRatio: ratio must be a positive finite number.");
|
|
4
|
+
return {
|
|
5
|
+
...style,
|
|
6
|
+
aspectRatio: ratio
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
exports.getAspectRatioStyle = getAspectRatioStyle;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=aspect-ratio.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspect-ratio.utils.cjs","names":[],"sources":["../../../../src/components/layout/aspect-ratio/aspect-ratio.utils.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nconst getAspectRatioStyle = (\n ratio: number,\n style?: CSSProperties,\n): CSSProperties => {\n if (!Number.isFinite(ratio) || ratio <= 0) {\n throw new RangeError(\n \"AspectRatio: ratio must be a positive finite number.\",\n );\n }\n\n return {\n ...style,\n aspectRatio: ratio,\n };\n};\n\nexport { getAspectRatioStyle };\n"],"mappings":";AAEA,MAAM,uBACJ,OACA,UACkB;CAClB,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GACtC,MAAM,IAAI,WACR,sDACF;CAGF,OAAO;EACL,GAAG;EACH,aAAa;CACf;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/components/layout/aspect-ratio/aspect-ratio.utils.ts
|
|
2
|
+
const getAspectRatioStyle = (ratio, style) => {
|
|
3
|
+
if (!Number.isFinite(ratio) || ratio <= 0) throw new RangeError("AspectRatio: ratio must be a positive finite number.");
|
|
4
|
+
return {
|
|
5
|
+
...style,
|
|
6
|
+
aspectRatio: ratio
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export { getAspectRatioStyle };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=aspect-ratio.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspect-ratio.utils.js","names":[],"sources":["../../../../src/components/layout/aspect-ratio/aspect-ratio.utils.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nconst getAspectRatioStyle = (\n ratio: number,\n style?: CSSProperties,\n): CSSProperties => {\n if (!Number.isFinite(ratio) || ratio <= 0) {\n throw new RangeError(\n \"AspectRatio: ratio must be a positive finite number.\",\n );\n }\n\n return {\n ...style,\n aspectRatio: ratio,\n };\n};\n\nexport { getAspectRatioStyle };\n"],"mappings":";AAEA,MAAM,uBACJ,OACA,UACkB;CAClB,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GACtC,MAAM,IAAI,WACR,sDACF;CAGF,OAAO;EACL,GAAG;EACH,aAAa;CACf;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_aspect_ratio_utils = require("./aspect-ratio.utils.cjs");
|
|
2
|
+
;/* empty css */
|
|
3
|
+
let _puzzle_ui_core = require("@puzzle-ui/core");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
// src/components/layout/aspect-ratio/index.tsx
|
|
6
|
+
const AspectRatio = ({ as, ratio = 1, className, style, children, ...rest }) => {
|
|
7
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(as ?? "div", {
|
|
8
|
+
className: (0, _puzzle_ui_core.cn)("puzzle-aspect-ratio", className),
|
|
9
|
+
style: require_aspect_ratio_utils.getAspectRatioStyle(ratio, style),
|
|
10
|
+
...rest,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.AspectRatio = AspectRatio;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["cn","getAspectRatioStyle"],"sources":["../../../../src/components/layout/aspect-ratio/index.tsx"],"sourcesContent":["import type {\n ComponentPropsWithRef,\n CSSProperties,\n ElementType,\n ReactNode,\n} from \"react\";\nimport { cn } from \"@puzzle-ui/core\";\nimport { getAspectRatioStyle } from \"./aspect-ratio.utils\";\nimport \"./aspect-ratio.css\";\n\ntype AspectRatioOwnProps<C extends ElementType> = {\n as?: C;\n ratio?: number;\n className?: string;\n style?: CSSProperties;\n children?: ReactNode;\n};\n\ntype AspectRatioProps<C extends ElementType = \"div\"> = AspectRatioOwnProps<C> &\n Omit<ComponentPropsWithRef<C>, keyof AspectRatioOwnProps<C> | \"as\">;\n\nconst AspectRatio = <C extends ElementType = \"div\">({\n as,\n ratio = 1,\n className,\n style,\n children,\n ...rest\n}: AspectRatioProps<C>) => {\n const Component = (as ?? \"div\") as ElementType;\n\n return (\n <Component\n className={cn(\"puzzle-aspect-ratio\", className)}\n style={getAspectRatioStyle(ratio, style)}\n {...rest}\n >\n {children}\n </Component>\n );\n};\n\nexport { AspectRatio, type AspectRatioProps };\n"],"mappings":";;;;;AAqBA,MAAM,eAA8C,EAClD,IACA,QAAQ,GACR,WACA,OACA,UACA,GAAG,WACsB;CAGzB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAHiB,MAAM,OAGvB;EACE,YAAA,GAAWA,gBAAAA,GAAAA,CAAG,uBAAuB,SAAS;EAC9C,OAAOC,2BAAAA,oBAAoB,OAAO,KAAK;EACvC,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSProperties, ComponentPropsWithRef, ElementType, ReactNode } from "react";
|
|
2
|
+
type AspectRatioOwnProps<C extends ElementType> = {
|
|
3
|
+
as?: C;
|
|
4
|
+
ratio?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
type AspectRatioProps<C extends ElementType = "div"> = AspectRatioOwnProps<C> & Omit<ComponentPropsWithRef<C>, keyof AspectRatioOwnProps<C> | "as">;
|
|
10
|
+
declare const AspectRatio: <C extends ElementType = "div">({ as, ratio, className, style, children, ...rest }: AspectRatioProps<C>) => import("react").JSX.Element;
|
|
11
|
+
export { AspectRatio, type AspectRatioProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSProperties, ComponentPropsWithRef, ElementType, ReactNode } from "react";
|
|
2
|
+
type AspectRatioOwnProps<C extends ElementType> = {
|
|
3
|
+
as?: C;
|
|
4
|
+
ratio?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
type AspectRatioProps<C extends ElementType = "div"> = AspectRatioOwnProps<C> & Omit<ComponentPropsWithRef<C>, keyof AspectRatioOwnProps<C> | "as">;
|
|
10
|
+
declare const AspectRatio: <C extends ElementType = "div">({ as, ratio, className, style, children, ...rest }: AspectRatioProps<C>) => import("react").JSX.Element;
|
|
11
|
+
export { AspectRatio, type AspectRatioProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getAspectRatioStyle } from "./aspect-ratio.utils.js";
|
|
2
|
+
import "./aspect-ratio.css";
|
|
3
|
+
import { cn } from "@puzzle-ui/core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/layout/aspect-ratio/index.tsx
|
|
6
|
+
const AspectRatio = ({ as, ratio = 1, className, style, children, ...rest }) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(as ?? "div", {
|
|
8
|
+
className: cn("puzzle-aspect-ratio", className),
|
|
9
|
+
style: getAspectRatioStyle(ratio, style),
|
|
10
|
+
...rest,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export { AspectRatio };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/layout/aspect-ratio/index.tsx"],"sourcesContent":["import type {\n ComponentPropsWithRef,\n CSSProperties,\n ElementType,\n ReactNode,\n} from \"react\";\nimport { cn } from \"@puzzle-ui/core\";\nimport { getAspectRatioStyle } from \"./aspect-ratio.utils\";\nimport \"./aspect-ratio.css\";\n\ntype AspectRatioOwnProps<C extends ElementType> = {\n as?: C;\n ratio?: number;\n className?: string;\n style?: CSSProperties;\n children?: ReactNode;\n};\n\ntype AspectRatioProps<C extends ElementType = \"div\"> = AspectRatioOwnProps<C> &\n Omit<ComponentPropsWithRef<C>, keyof AspectRatioOwnProps<C> | \"as\">;\n\nconst AspectRatio = <C extends ElementType = \"div\">({\n as,\n ratio = 1,\n className,\n style,\n children,\n ...rest\n}: AspectRatioProps<C>) => {\n const Component = (as ?? \"div\") as ElementType;\n\n return (\n <Component\n className={cn(\"puzzle-aspect-ratio\", className)}\n style={getAspectRatioStyle(ratio, style)}\n {...rest}\n >\n {children}\n </Component>\n );\n};\n\nexport { AspectRatio, type AspectRatioProps };\n"],"mappings":";;;;;AAqBA,MAAM,eAA8C,EAClD,IACA,QAAQ,GACR,WACA,OACA,UACA,GAAG,WACsB;CAGzB,OACE,oBAHiB,MAAM,OAGvB;EACE,WAAW,GAAG,uBAAuB,SAAS;EAC9C,OAAO,oBAAoB,OAAO,KAAK;EACvC,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_scroll_area_utils = require("./scroll-area.utils.cjs");
|
|
2
|
+
;/* empty css */
|
|
3
|
+
let _puzzle_ui_core = require("@puzzle-ui/core");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
// src/components/layout/scroll-area/index.tsx
|
|
6
|
+
const ScrollArea = ({ orientation = "vertical", children, className, role, tabIndex, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref, ...props }) => {
|
|
7
|
+
const overflow = require_scroll_area_utils.getScrollAreaOverflow(orientation);
|
|
8
|
+
const accessibleName = ariaLabel || ariaLabelledBy;
|
|
9
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10
|
+
...props,
|
|
11
|
+
ref,
|
|
12
|
+
role: role ?? (accessibleName ? "region" : void 0),
|
|
13
|
+
tabIndex: tabIndex ?? 0,
|
|
14
|
+
className: (0, _puzzle_ui_core.cn)("puzzle-scroll-area", className),
|
|
15
|
+
"data-orientation": orientation,
|
|
16
|
+
style: {
|
|
17
|
+
...overflow,
|
|
18
|
+
...props.style
|
|
19
|
+
},
|
|
20
|
+
"aria-label": ariaLabel,
|
|
21
|
+
"aria-labelledby": ariaLabelledBy,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.ScrollArea = ScrollArea;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["getScrollAreaOverflow","cn"],"sources":["../../../../src/components/layout/scroll-area/index.tsx"],"sourcesContent":["import { cn } from \"@puzzle-ui/core\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { getScrollAreaOverflow } from \"./scroll-area.utils\";\nimport type { ScrollAreaOrientation } from \"./scroll-area.utils\";\nimport \"./scroll-area.css\";\n\ntype ScrollAreaProps = Omit<ComponentPropsWithRef<\"div\">, \"children\"> & {\n /**\n * Content rendered inside the scrollable viewport.\n */\n children?: ReactNode;\n\n /**\n * The axis or axes that can scroll.\n * @default \"vertical\"\n */\n orientation?: ScrollAreaOrientation;\n};\n\nconst ScrollArea = ({\n orientation = \"vertical\",\n children,\n className,\n role,\n tabIndex,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ref,\n ...props\n}: ScrollAreaProps) => {\n const overflow = getScrollAreaOverflow(orientation);\n const accessibleName = ariaLabel || ariaLabelledBy;\n\n return (\n <div\n {...props}\n ref={ref}\n role={role ?? (accessibleName ? \"region\" : undefined)}\n tabIndex={tabIndex ?? 0}\n className={cn(\"puzzle-scroll-area\", className)}\n data-orientation={orientation}\n style={{ ...overflow, ...props.style }}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </div>\n );\n};\n\nexport { ScrollArea, type ScrollAreaProps, type ScrollAreaOrientation };\n"],"mappings":";;;;;AAmBA,MAAM,cAAc,EAClB,cAAc,YACd,UACA,WACA,MACA,UACA,cAAc,WACd,mBAAmB,gBACnB,KACA,GAAG,YACkB;CACrB,MAAM,WAAWA,0BAAAA,sBAAsB,WAAW;CAClD,MAAM,iBAAiB,aAAa;CAEpC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,MAAM,SAAS,iBAAiB,WAAW,KAAA;EAC3C,UAAU,YAAY;EACtB,YAAA,GAAWC,gBAAAA,GAAAA,CAAG,sBAAsB,SAAS;EAC7C,oBAAkB;EAClB,OAAO;GAAE,GAAG;GAAU,GAAG,MAAM;EAAM;EACrC,cAAY;EACZ,mBAAiB;EAEhB;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScrollAreaOrientation } from "./scroll-area.utils.cjs";
|
|
2
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
type ScrollAreaProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
4
|
+
/**
|
|
5
|
+
* Content rendered inside the scrollable viewport.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* The axis or axes that can scroll.
|
|
10
|
+
* @default "vertical"
|
|
11
|
+
*/
|
|
12
|
+
orientation?: ScrollAreaOrientation;
|
|
13
|
+
};
|
|
14
|
+
declare const ScrollArea: ({ orientation, children, className, role, tabIndex, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref, ...props }: ScrollAreaProps) => import("react").JSX.Element;
|
|
15
|
+
export { ScrollArea, type ScrollAreaOrientation, type ScrollAreaProps };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScrollAreaOrientation } from "./scroll-area.utils.js";
|
|
2
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
type ScrollAreaProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
4
|
+
/**
|
|
5
|
+
* Content rendered inside the scrollable viewport.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* The axis or axes that can scroll.
|
|
10
|
+
* @default "vertical"
|
|
11
|
+
*/
|
|
12
|
+
orientation?: ScrollAreaOrientation;
|
|
13
|
+
};
|
|
14
|
+
declare const ScrollArea: ({ orientation, children, className, role, tabIndex, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref, ...props }: ScrollAreaProps) => import("react").JSX.Element;
|
|
15
|
+
export { ScrollArea, type ScrollAreaOrientation, type ScrollAreaProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getScrollAreaOverflow } from "./scroll-area.utils.js";
|
|
2
|
+
import "./scroll-area.css";
|
|
3
|
+
import { cn } from "@puzzle-ui/core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/layout/scroll-area/index.tsx
|
|
6
|
+
const ScrollArea = ({ orientation = "vertical", children, className, role, tabIndex, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref, ...props }) => {
|
|
7
|
+
const overflow = getScrollAreaOverflow(orientation);
|
|
8
|
+
const accessibleName = ariaLabel || ariaLabelledBy;
|
|
9
|
+
return /* @__PURE__ */ jsx("div", {
|
|
10
|
+
...props,
|
|
11
|
+
ref,
|
|
12
|
+
role: role ?? (accessibleName ? "region" : void 0),
|
|
13
|
+
tabIndex: tabIndex ?? 0,
|
|
14
|
+
className: cn("puzzle-scroll-area", className),
|
|
15
|
+
"data-orientation": orientation,
|
|
16
|
+
style: {
|
|
17
|
+
...overflow,
|
|
18
|
+
...props.style
|
|
19
|
+
},
|
|
20
|
+
"aria-label": ariaLabel,
|
|
21
|
+
"aria-labelledby": ariaLabelledBy,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export { ScrollArea };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/layout/scroll-area/index.tsx"],"sourcesContent":["import { cn } from \"@puzzle-ui/core\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { getScrollAreaOverflow } from \"./scroll-area.utils\";\nimport type { ScrollAreaOrientation } from \"./scroll-area.utils\";\nimport \"./scroll-area.css\";\n\ntype ScrollAreaProps = Omit<ComponentPropsWithRef<\"div\">, \"children\"> & {\n /**\n * Content rendered inside the scrollable viewport.\n */\n children?: ReactNode;\n\n /**\n * The axis or axes that can scroll.\n * @default \"vertical\"\n */\n orientation?: ScrollAreaOrientation;\n};\n\nconst ScrollArea = ({\n orientation = \"vertical\",\n children,\n className,\n role,\n tabIndex,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ref,\n ...props\n}: ScrollAreaProps) => {\n const overflow = getScrollAreaOverflow(orientation);\n const accessibleName = ariaLabel || ariaLabelledBy;\n\n return (\n <div\n {...props}\n ref={ref}\n role={role ?? (accessibleName ? \"region\" : undefined)}\n tabIndex={tabIndex ?? 0}\n className={cn(\"puzzle-scroll-area\", className)}\n data-orientation={orientation}\n style={{ ...overflow, ...props.style }}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </div>\n );\n};\n\nexport { ScrollArea, type ScrollAreaProps, type ScrollAreaOrientation };\n"],"mappings":";;;;;AAmBA,MAAM,cAAc,EAClB,cAAc,YACd,UACA,WACA,MACA,UACA,cAAc,WACd,mBAAmB,gBACnB,KACA,GAAG,YACkB;CACrB,MAAM,WAAW,sBAAsB,WAAW;CAClD,MAAM,iBAAiB,aAAa;CAEpC,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,MAAM,SAAS,iBAAiB,WAAW,KAAA;EAC3C,UAAU,YAAY;EACtB,WAAW,GAAG,sBAAsB,SAAS;EAC7C,oBAAkB;EAClB,OAAO;GAAE,GAAG;GAAU,GAAG,MAAM;EAAM;EACrC,cAAY;EACZ,mBAAiB;EAEhB;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.puzzle-scroll-area {
|
|
2
|
+
overscroll-behavior: contain;
|
|
3
|
+
-webkit-overflow-scrolling: touch;
|
|
4
|
+
scrollbar-width: thin;
|
|
5
|
+
scrollbar-color: var(--puzzle-color-border) transparent;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
min-height: 0;
|
|
8
|
+
display: block;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.puzzle-scroll-area::-webkit-scrollbar {
|
|
12
|
+
width: .5rem;
|
|
13
|
+
height: .5rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.puzzle-scroll-area::-webkit-scrollbar-track {
|
|
17
|
+
background: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.puzzle-scroll-area::-webkit-scrollbar-thumb {
|
|
21
|
+
background-color: var(--puzzle-color-border);
|
|
22
|
+
background-clip: content-box;
|
|
23
|
+
border: 2px solid #0000;
|
|
24
|
+
border-radius: 999px;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/components/layout/scroll-area/scroll-area.utils.ts
|
|
2
|
+
const getScrollAreaOverflow = (orientation) => ({
|
|
3
|
+
overflowX: orientation === "horizontal" || orientation === "both" ? "auto" : "hidden",
|
|
4
|
+
overflowY: orientation === "vertical" || orientation === "both" ? "auto" : "hidden"
|
|
5
|
+
});
|
|
6
|
+
exports.getScrollAreaOverflow = getScrollAreaOverflow;
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=scroll-area.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-area.utils.cjs","names":[],"sources":["../../../../src/components/layout/scroll-area/scroll-area.utils.ts"],"sourcesContent":["type ScrollAreaOrientation = \"vertical\" | \"horizontal\" | \"both\";\n\ntype ScrollAreaOverflow = {\n overflowX: \"auto\" | \"hidden\";\n overflowY: \"auto\" | \"hidden\";\n};\n\nconst getScrollAreaOverflow = (\n orientation: ScrollAreaOrientation,\n): ScrollAreaOverflow => ({\n overflowX:\n orientation === \"horizontal\" || orientation === \"both\" ? \"auto\" : \"hidden\",\n overflowY:\n orientation === \"vertical\" || orientation === \"both\" ? \"auto\" : \"hidden\",\n});\n\nexport {\n getScrollAreaOverflow,\n type ScrollAreaOrientation,\n type ScrollAreaOverflow,\n};\n"],"mappings":";AAOA,MAAM,yBACJ,iBACwB;CACxB,WACE,gBAAgB,gBAAgB,gBAAgB,SAAS,SAAS;CACpE,WACE,gBAAgB,cAAc,gBAAgB,SAAS,SAAS;AACpE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/components/layout/scroll-area/scroll-area.utils.ts
|
|
2
|
+
const getScrollAreaOverflow = (orientation) => ({
|
|
3
|
+
overflowX: orientation === "horizontal" || orientation === "both" ? "auto" : "hidden",
|
|
4
|
+
overflowY: orientation === "vertical" || orientation === "both" ? "auto" : "hidden"
|
|
5
|
+
});
|
|
6
|
+
export { getScrollAreaOverflow };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=scroll-area.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-area.utils.js","names":[],"sources":["../../../../src/components/layout/scroll-area/scroll-area.utils.ts"],"sourcesContent":["type ScrollAreaOrientation = \"vertical\" | \"horizontal\" | \"both\";\n\ntype ScrollAreaOverflow = {\n overflowX: \"auto\" | \"hidden\";\n overflowY: \"auto\" | \"hidden\";\n};\n\nconst getScrollAreaOverflow = (\n orientation: ScrollAreaOrientation,\n): ScrollAreaOverflow => ({\n overflowX:\n orientation === \"horizontal\" || orientation === \"both\" ? \"auto\" : \"hidden\",\n overflowY:\n orientation === \"vertical\" || orientation === \"both\" ? \"auto\" : \"hidden\",\n});\n\nexport {\n getScrollAreaOverflow,\n type ScrollAreaOrientation,\n type ScrollAreaOverflow,\n};\n"],"mappings":";AAOA,MAAM,yBACJ,iBACwB;CACxB,WACE,gBAAgB,gBAAgB,gBAAgB,SAAS,SAAS;CACpE,WACE,gBAAgB,cAAc,gBAAgB,SAAS,SAAS;AACpE"}
|