@once-ui-system/core 2.0.0-alpha.1 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/catalog.json +11 -4
- package/ai/components/Effect.json +1 -1
- package/ai/components/Feedback.json +1 -0
- package/ai/components/Form.json +15 -0
- package/ai/components/Input.json +3 -2
- package/ai/components/{Particle.json → ParticleFx.json} +1 -1
- package/ai/components/ScrollContainer.json +9 -1
- package/ai/components/Textarea.json +3 -2
- package/ai/components/ThemeSwitcher.json +2 -1
- package/ai/examples/blocks/Footer4.tsx +2 -2
- package/ai/examples/blocks/manifest.json +2 -2
- package/ai/gotchas.json +7 -0
- package/ai/manifest.json +2 -2
- package/ai/rules.md +1 -1
- package/ai/spec.json +35 -10
- package/dist/ai/catalog.json +11 -4
- package/dist/ai/components/Effect.json +1 -1
- package/dist/ai/components/Feedback.json +1 -0
- package/dist/ai/components/Form.json +15 -0
- package/dist/ai/components/Input.json +3 -2
- package/dist/ai/components/{Particle.json → ParticleFx.json} +1 -1
- package/dist/ai/components/ScrollContainer.json +9 -1
- package/dist/ai/components/Textarea.json +3 -2
- package/dist/ai/components/ThemeSwitcher.json +2 -1
- package/dist/ai/examples/blocks/manifest.json +2 -2
- package/dist/ai/gotchas.json +7 -0
- package/dist/ai/manifest.json +2 -2
- package/dist/ai/rules.md +1 -1
- package/dist/ai/spec.json +35 -10
- package/dist/components/Animation.d.ts +1 -2
- package/dist/components/Animation.d.ts.map +1 -1
- package/dist/components/Animation.js +1 -1
- package/dist/components/Animation.js.map +1 -1
- package/dist/components/ArrowNavigationContext.d.ts.map +1 -1
- package/dist/components/ArrowNavigationContext.js +12 -3
- package/dist/components/ArrowNavigationContext.js.map +1 -1
- package/dist/components/ContextMenu.d.ts +1 -1
- package/dist/components/ContextMenu.d.ts.map +1 -1
- package/dist/components/CursorCard.d.ts +1 -1
- package/dist/components/CursorCard.d.ts.map +1 -1
- package/dist/components/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker.js +7 -0
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/DropdownWrapper.d.ts +1 -1
- package/dist/components/DropdownWrapper.d.ts.map +1 -1
- package/dist/components/DropdownWrapper.js +178 -35
- package/dist/components/DropdownWrapper.js.map +1 -1
- package/dist/components/DropdownWrapper.module.scss +3 -1
- package/dist/components/Effect.d.ts +2 -2
- package/dist/components/Effect.d.ts.map +1 -1
- package/dist/components/Effect.js +2 -2
- package/dist/components/Effect.js.map +1 -1
- package/dist/components/Feedback.d.ts +4 -0
- package/dist/components/Feedback.d.ts.map +1 -1
- package/dist/components/Feedback.js +2 -2
- package/dist/components/Feedback.js.map +1 -1
- package/dist/components/FocusTrap.d.ts +3 -3
- package/dist/components/FocusTrap.d.ts.map +1 -1
- package/dist/components/FocusTrap.js +10 -0
- package/dist/components/FocusTrap.js.map +1 -1
- package/dist/components/Form.d.ts +48 -0
- package/dist/components/Form.d.ts.map +1 -0
- package/dist/components/Form.js +191 -0
- package/dist/components/Form.js.map +1 -0
- package/dist/components/Form.module.scss +160 -0
- package/dist/components/FormContext.d.ts +20 -0
- package/dist/components/FormContext.d.ts.map +1 -0
- package/dist/components/FormContext.js +12 -0
- package/dist/components/FormContext.js.map +1 -0
- package/dist/components/Input.d.ts +3 -0
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +13 -2
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Input.module.scss +27 -6
- package/dist/components/{Particle.d.ts → ParticleFx.d.ts} +9 -4
- package/dist/components/ParticleFx.d.ts.map +1 -0
- package/dist/components/{Particle.js → ParticleFx.js} +9 -4
- package/dist/components/ParticleFx.js.map +1 -0
- package/dist/components/ScrollContainer.d.ts +69 -2
- package/dist/components/ScrollContainer.d.ts.map +1 -1
- package/dist/components/ScrollContainer.js +377 -46
- package/dist/components/ScrollContainer.js.map +1 -1
- package/dist/components/ScrollContainer.module.scss +131 -0
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Setting.d.ts.map +1 -1
- package/dist/components/Setting.js +6 -1
- package/dist/components/Setting.js.map +1 -1
- package/dist/components/Textarea.d.ts +3 -0
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/Textarea.js +22 -6
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeSwitcher.d.ts +16 -0
- package/dist/components/ThemeSwitcher.d.ts.map +1 -1
- package/dist/components/ThemeSwitcher.js +48 -9
- package/dist/components/ThemeSwitcher.js.map +1 -1
- package/dist/components/ThemeSwitcher.module.scss +112 -0
- package/dist/components/UserMenu.d.ts +1 -1
- package/dist/components/UserMenu.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/data/emoji-data.json +10 -0
- package/dist/hooks/useArrowNavigation.d.ts.map +1 -1
- package/dist/hooks/useArrowNavigation.js +52 -7
- package/dist/hooks/useArrowNavigation.js.map +1 -1
- package/dist/modules/navigation/MegaMenu.d.ts.map +1 -1
- package/dist/modules/navigation/MegaMenu.js +76 -10
- package/dist/modules/navigation/MegaMenu.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/components/Particle.d.ts.map +0 -1
- package/dist/components/Particle.js.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The track paints past the viewport by default.
|
|
3
|
+
*
|
|
4
|
+
* This is the point of moving a transform instead of scrolling a box: tiles
|
|
5
|
+
* either side of the ones in front stay visible, so the run reads as something
|
|
6
|
+
* continuous that has been moved along rather than a window with two hard cuts
|
|
7
|
+
* in it.
|
|
8
|
+
*
|
|
9
|
+
* `overflow: clip` with a large `overflow-clip-margin` rather than
|
|
10
|
+
* `overflow: visible`, because visible overflow is not confined to the
|
|
11
|
+
* direction it is wanted in: a track wider than the page would extend the
|
|
12
|
+
* document's scrollable area and give the whole page a horizontal scrollbar,
|
|
13
|
+
* which is a page-level bug produced by a component that cannot see the page.
|
|
14
|
+
* A clip margin is the same effect with a boundary — tiles paint well past the
|
|
15
|
+
* edges, and nothing reaches far enough to push the document out.
|
|
16
|
+
*
|
|
17
|
+
* `clip` is not `hidden`: `hidden` makes the element a scroll container, which
|
|
18
|
+
* would let a stray focus or a wheel gesture scroll the track sideways and put
|
|
19
|
+
* the transform and the scroll offset into disagreement about where the track
|
|
20
|
+
* is. `clip` cannot scroll, which is what this needs.
|
|
21
|
+
*/
|
|
22
|
+
.viewport {
|
|
23
|
+
overflow: clip;
|
|
24
|
+
overflow-clip-margin: 100vw;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Self-contained: nothing paints outside the component's own box. */
|
|
28
|
+
.viewportClipped {
|
|
29
|
+
overflow: clip;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.viewport,
|
|
33
|
+
.viewportClipped {
|
|
34
|
+
/*
|
|
35
|
+
* Horizontal gestures belong to the track and vertical ones to the page.
|
|
36
|
+
* Without this the browser claims the whole gesture before the pointer
|
|
37
|
+
* handler can decide, and a carousel becomes a place where the page stops
|
|
38
|
+
* scrolling.
|
|
39
|
+
*/
|
|
40
|
+
touch-action: pan-y;
|
|
41
|
+
cursor: grab;
|
|
42
|
+
|
|
43
|
+
&:focus-visible {
|
|
44
|
+
outline: var(--static-space-2) solid var(--brand-border-strong);
|
|
45
|
+
outline-offset: var(--static-space-2);
|
|
46
|
+
border-radius: var(--radius-m);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&[data-dragging="true"] {
|
|
50
|
+
cursor: grabbing;
|
|
51
|
+
/* A drag across tiles selects their text otherwise, and the selection
|
|
52
|
+
highlight follows the pointer across the whole run. */
|
|
53
|
+
user-select: none;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.track {
|
|
58
|
+
/*
|
|
59
|
+
* `width: max-content` is what makes a transform track possible at all:
|
|
60
|
+
* the row lays out at the sum of its tiles rather than at the width of its
|
|
61
|
+
* parent, so there is something to move. Without it the tiles would be
|
|
62
|
+
* squeezed into one viewport's width and the transform would move an
|
|
63
|
+
* already-complete layout off the screen.
|
|
64
|
+
*/
|
|
65
|
+
width: max-content;
|
|
66
|
+
will-change: transform;
|
|
67
|
+
transition: transform var(--transition-duration-macro-long) var(--transition-eased);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.tile {
|
|
71
|
+
/* A track item that can shrink is a track item that has no width of its own
|
|
72
|
+
once the row is wider than its parent. */
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* For `proximity`. The scale itself is set per tile from the distance to the
|
|
77
|
+
* front, which only the component can know; the easing belongs here so it
|
|
78
|
+
* matches the track's, and so a tile settles into its new size on the same
|
|
79
|
+
* curve the track settles onto its new offset. During a drag the component
|
|
80
|
+
* turns this off inline and the size follows the pointer.
|
|
81
|
+
*
|
|
82
|
+
* `transform-origin: center` keeps a shrinking tile in its own slot instead
|
|
83
|
+
* of pulling away from one side of the gap.
|
|
84
|
+
*/
|
|
85
|
+
transform-origin: center;
|
|
86
|
+
transition: transform var(--transition-duration-macro-long) var(--transition-eased);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.marker {
|
|
90
|
+
appearance: none;
|
|
91
|
+
border: 0;
|
|
92
|
+
padding: 0;
|
|
93
|
+
width: var(--static-space-8);
|
|
94
|
+
height: var(--static-space-8);
|
|
95
|
+
border-radius: var(--radius-full);
|
|
96
|
+
background: var(--neutral-alpha-medium);
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
transition:
|
|
99
|
+
background var(--transition-duration-micro-medium) var(--transition-eased),
|
|
100
|
+
width var(--transition-duration-micro-medium) var(--transition-eased);
|
|
101
|
+
|
|
102
|
+
&:hover {
|
|
103
|
+
background: var(--neutral-alpha-strong);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&:focus-visible {
|
|
107
|
+
outline: var(--static-space-2) solid var(--brand-border-strong);
|
|
108
|
+
outline-offset: var(--static-space-2);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* The one in front is a bar rather than a brighter dot: the difference
|
|
112
|
+
survives being small, and being colour-blind. */
|
|
113
|
+
&[data-active="true"] {
|
|
114
|
+
width: var(--static-space-20);
|
|
115
|
+
background: var(--brand-solid-strong);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@media (prefers-reduced-motion: reduce) {
|
|
120
|
+
.track {
|
|
121
|
+
transition: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.tile {
|
|
125
|
+
transition: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.marker {
|
|
129
|
+
transition: none;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { InputProps, OptionProps, DropdownWrapperProps } from ".";
|
|
3
|
-
import { Placement } from "
|
|
3
|
+
import type { Placement } from "../types";
|
|
4
4
|
type SelectOptionType = Omit<OptionProps, "selected">;
|
|
5
5
|
interface SelectProps extends Omit<InputProps, "onSelect" | "value">, Pick<DropdownWrapperProps, "minHeight" | "minWidth" | "maxWidth"> {
|
|
6
6
|
options: SelectOptionType[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA2C,SAAS,EAAS,MAAM,OAAO,CAAC;AAEzF,OAAO,EAML,UAAU,EAEV,WAAW,EACX,oBAAoB,EAIrB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"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E,CAAC"}
|
|
@@ -29,7 +29,12 @@ Setting.displayName = "Setting";
|
|
|
29
29
|
* A Setting whose sub-settings live *inside* its box rather than beside it, so
|
|
30
30
|
* the relationship survives when the group is one of ten in a scrolling panel.
|
|
31
31
|
*/
|
|
32
|
-
const SettingGroup = ({ label, description, info, control, open, children, ...flex }) => (_jsxs(Column, { fillWidth: true, radius: "l",
|
|
32
|
+
const SettingGroup = ({ label, description, info, control, open, children, ...flex }) => (_jsxs(Column, { fillWidth: true, radius: "l",
|
|
33
|
+
// The group is one surface: the header and the body it reveals share a
|
|
34
|
+
// background, so opening it grows the panel rather than stacking a second
|
|
35
|
+
// one inside the first. An alpha border sits on whatever is behind it,
|
|
36
|
+
// which is what a group nested in a panel needs.
|
|
37
|
+
background: "surface", border: "neutral-alpha-weak", overflow: "hidden", ...flex, children: [_jsxs(Row, { fillWidth: true, padding: "8", gap: "12", vertical: "center", horizontal: "between", wrap: true, children: [_jsxs(Column, { gap: "4", paddingLeft: "8", paddingY: "4", children: [_jsxs(Row, { vertical: "center", gap: "8", children: [renderLabel(label), info && _jsx(InfoTip, { children: info })] }), description && (_jsx(Text, { variant: "label-default-xs", onBackground: "neutral-weak", children: description }))] }), control && (_jsx(Row, { horizontal: "end", vertical: "center", gap: "8", children: control }))] }), open && children && (_jsx(Column, { fillWidth: true, gap: "8", padding: "8", borderTop: "neutral-alpha-weak", children: children }))] }));
|
|
33
38
|
SettingGroup.displayName = "SettingGroup";
|
|
34
39
|
/**
|
|
35
40
|
* One row carrying the axes of a single property — "Tilt" as X and Y side by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Setting.js","sourceRoot":"","sources":["../../src/components/Setting.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,MAAM,EAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AAErD;;;;;;;;GAQG;AAEH,qEAAqE;AACrE,SAAS,WAAW,CAAC,KA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,EAAC,IAAI,EAAC,IAAI,kBACzB,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CACzB,MAAC,GAAG,IAAa,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAC,QAAQ,EAAC,GAAG,EAAC,GAAG,EAAC,WAAW,EAAC,GAAG,aACtF,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,kBAAkB,EAAC,YAAY,EAAC,cAAc,YACvE,IAAI,CAAC,KAAK,GACN,EACN,IAAI,CAAC,OAAO,KAJL,KAAK,CAKT,CACP,CAAC,GACE,IACC,CACV,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -28,6 +28,9 @@ interface TextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>
|
|
|
28
28
|
resize?: "horizontal" | "vertical" | "both" | "none";
|
|
29
29
|
validate?: (value: ReactNode) => ReactNode | null;
|
|
30
30
|
disabled?: boolean;
|
|
31
|
+
/** How many columns to occupy inside a `Form` grid. `Form` reads this off
|
|
32
|
+
* the child and strips it; outside a `Form` it does nothing. */
|
|
33
|
+
span?: number;
|
|
31
34
|
}
|
|
32
35
|
declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
33
36
|
export { Textarea };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAIZ,sBAAsB,EAEtB,SAAS,EACV,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Text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pB,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -5,7 +5,13 @@ import classNames from "clsx";
|
|
|
5
5
|
import { Column, Row, Text } from ".";
|
|
6
6
|
import styles from "./Input.module.scss";
|
|
7
7
|
import { useDebounce } from "../hooks/useDebounce";
|
|
8
|
-
|
|
8
|
+
import { useFieldSize } from "./FormContext";
|
|
9
|
+
const Textarea = forwardRef(({ id, label, placeholder, lines = "auto", size, error = false, errorMessage, description, corners, className, prefix, suffix, variant = "default", focusRing = false, characterCount, resize = "vertical", validate, disabled = false,
|
|
10
|
+
// Consumed by `Form`, never rendered. See Input.tsx.
|
|
11
|
+
span, children, onFocus, onBlur, onChange, onAnimationStart, style, ...props }, ref) => {
|
|
12
|
+
// A `Form` can set the size for every field in it; the field's own
|
|
13
|
+
// prop still wins, and `"m"` is still the default on its own.
|
|
14
|
+
const resolvedSize = useFieldSize(size);
|
|
9
15
|
const [isFocused, setIsFocused] = useState(false);
|
|
10
16
|
// Seeded from `defaultValue` too: an uncontrolled field — how a settings
|
|
11
17
|
// form normally renders saved data — has no `value`, so the label never
|
|
@@ -93,12 +99,18 @@ const Textarea = forwardRef(({ id, label, placeholder, lines = "auto", size = "m
|
|
|
93
99
|
const textareaClassNames = classNames(styles.input, styles.textarea, "font-body", "font-default", {
|
|
94
100
|
[styles.withPrefix]: prefix,
|
|
95
101
|
[styles.withSuffix]: suffix,
|
|
96
|
-
[styles.placeholder]: placeholder,
|
|
97
102
|
[styles.hasChildren]: children,
|
|
98
103
|
});
|
|
99
104
|
return (_jsxs(Column, { gap: "8", fillWidth: true, fitHeight: true, className: classNames(className, {
|
|
100
105
|
[styles.error]: displayError && debouncedValue !== "",
|
|
101
|
-
}), children: [_jsxs(Row
|
|
106
|
+
}), children: [_jsxs(Row
|
|
107
|
+
// See Input.tsx: the surface `Form` fuses, two levels down.
|
|
108
|
+
, { "data-surface": "field",
|
|
109
|
+
// Height comes from the size token via `.base`, the same as an
|
|
110
|
+
// input's. This used to be a hardcoded 48 or 56, which ignored
|
|
111
|
+
// `size` entirely and left a placeholder-only textarea 8px shorter
|
|
112
|
+
// than the input beside it.
|
|
113
|
+
transition: "micro-medium", border: variant === "ghost" ? "transparent" : "neutral-medium", background: variant === "ghost" ? "transparent" : "neutral-alpha-weak", overflow: "hidden", vertical: "stretch", className: classNames(styles.base, focusRing && styles.focusRing, styles[resolvedSize], lines !== "auto" && resize !== "none" && styles.resizeHandle, corners === "none" ? "radius-none" : corners ? `radius-l-${corners}` : "radius-l", lines !== "auto" && resize !== "none" && "radius-s-bottom-right"), children: [prefix && (_jsx(Row, { paddingLeft: "12", className: styles.prefix, children: prefix })), _jsxs(Column, { fillWidth: true, padding: "4", children: [_jsx("textarea", { ...props, ref: (node) => {
|
|
102
114
|
if (typeof ref === "function") {
|
|
103
115
|
ref(node);
|
|
104
116
|
}
|
|
@@ -106,11 +118,15 @@ const Textarea = forwardRef(({ id, label, placeholder, lines = "auto", size = "m
|
|
|
106
118
|
ref.current = node;
|
|
107
119
|
}
|
|
108
120
|
textareaRef.current = node;
|
|
109
|
-
}, id: id, rows: typeof lines === "number" ? lines : 1, placeholder: placeholder, disabled: disabled, onFocus: handleFocus, onBlur: handleBlur, onAnimationStart: handleAnimationStart, className: textareaClassNames
|
|
121
|
+
}, id: id, rows: typeof lines === "number" ? lines : 1, placeholder: placeholder, disabled: disabled, onFocus: handleFocus, onBlur: handleBlur, onAnimationStart: handleAnimationStart, className: `${textareaClassNames} scrollbar-minimal`, "aria-describedby": displayError ? `${id}-error` : undefined, "aria-invalid": !!displayError, style: {
|
|
110
122
|
...style,
|
|
111
123
|
resize: lines === "auto" ? "none" : resize,
|
|
112
|
-
}, onChange: handleChange }),
|
|
113
|
-
|
|
124
|
+
}, onChange: handleChange }), label && (_jsx(Text, { as: "label", variant: "label-default-m", htmlFor: id, className: classNames(styles.label, styles.textareaLabel, {
|
|
125
|
+
// `|| placeholder` is the whole point of the pairing: a
|
|
126
|
+
// placeholder is visible immediately, so the label has to be
|
|
127
|
+
// out of its way from the first paint rather than waiting
|
|
128
|
+
// for focus. Identical to `Input`.
|
|
129
|
+
[styles.floating]: isFocused || isFilled || placeholder,
|
|
114
130
|
}), children: label })), children, characterCount && props.maxLength && (_jsx(Row, { fillWidth: true, paddingLeft: "12", paddingY: "4", className: styles.suffix, children: _jsx(Text, { variant: "label-default-s", onBackground: props.maxLength - String(props.value || '').length <= 5
|
|
115
131
|
? "danger-weak"
|
|
116
132
|
: props.maxLength - String(props.value || '').length <= 10
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,EAEV,WAAW,GAEZ,MAAM,OAAO,CAAC;AACf,OAAO,UAAU,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AACtC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,EAEV,WAAW,GAEZ,MAAM,OAAO,CAAC;AACf,OAAO,UAAU,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AACtC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA6C7C,MAAM,QAAQ,GAAG,UAAU,CACzB,CACE,EACE,EAAE,EACF,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
|
12
12
|
*/
|
|
13
13
|
collapsed?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Which way a collapsed group opens. Ignored when not `collapsed`.
|
|
16
|
+
*
|
|
17
|
+
* `"row"` grows sideways in the flow of the layout, which is right when the
|
|
18
|
+
* control has room beside it and wrong when it has neighbours: the group
|
|
19
|
+
* widening pushes them along, and the option you were pointing at moves out
|
|
20
|
+
* from under the pointer.
|
|
21
|
+
*
|
|
22
|
+
* `"column"` lifts the options into a panel over the page and opens it
|
|
23
|
+
* downwards, so the control keeps a one-option footprint whatever it is
|
|
24
|
+
* doing and nothing around it moves. Downwards rather than centred on the
|
|
25
|
+
* active option: the open panel is taller than a typical header, so
|
|
26
|
+
* anchoring it on the second or third option would put its top edge above
|
|
27
|
+
* the viewport.
|
|
28
|
+
*/
|
|
29
|
+
direction?: "row" | "column";
|
|
14
30
|
}
|
|
15
31
|
declare const ThemeSwitcher: React.ForwardRefExoticComponent<Omit<ThemeSwitcherProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
16
32
|
export { ThemeSwitcher };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeSwitcher.d.ts","sourceRoot":"","sources":["../../src/components/ThemeSwitcher.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ThemeSwitcher.d.ts","sourceRoot":"","sources":["../../src/components/ThemeSwitcher.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAsB,GAAG,EAAE,MAAM,GAAG,CAAC;AAS5C,UAAU,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC;IACnE;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,wGA8GlB,CAAC;AAIF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import classNames from "clsx";
|
|
4
4
|
import React, { forwardRef } from "react";
|
|
5
|
-
import { IconButton, Row } from ".";
|
|
6
5
|
import { useTheme } from "../contexts";
|
|
6
|
+
import { Column, IconButton, Row } from ".";
|
|
7
7
|
import styles from "./ThemeSwitcher.module.scss";
|
|
8
8
|
const THEMES = [
|
|
9
9
|
{ value: "system", icon: "computer", label: "System theme" },
|
|
10
10
|
{ value: "dark", icon: "dark", label: "Dark theme" },
|
|
11
11
|
{ value: "light", icon: "light", label: "Light theme" },
|
|
12
12
|
];
|
|
13
|
-
const ThemeSwitcher = forwardRef(({ collapsed, className, ...flex }, ref) => {
|
|
13
|
+
const ThemeSwitcher = forwardRef(({ collapsed, direction = "row", className, ...flex }, ref) => {
|
|
14
14
|
const { theme, setTheme } = useTheme();
|
|
15
15
|
const [mounted, setMounted] = React.useState(false);
|
|
16
16
|
// The server does not know the visitor's theme, so nothing is marked active
|
|
@@ -18,13 +18,52 @@ const ThemeSwitcher = forwardRef(({ collapsed, className, ...flex }, ref) => {
|
|
|
18
18
|
React.useEffect(() => {
|
|
19
19
|
setMounted(true);
|
|
20
20
|
}, []);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
/*
|
|
22
|
+
* Opening downwards, the active option leads.
|
|
23
|
+
*
|
|
24
|
+
* The shut control is the active option — that is what a collapsed group
|
|
25
|
+
* is. Open it in fixed order and the panel's first slot belongs to
|
|
26
|
+
* whichever theme happens to be listed first, so the icon the pointer is
|
|
27
|
+
* already resting on changes identity as the panel unrolls: you hover the
|
|
28
|
+
* moon and the computer arrives underneath your cursor. Click without
|
|
29
|
+
* looking and you have set the wrong theme.
|
|
30
|
+
*
|
|
31
|
+
* Leading with the active option keeps one invariant instead — the theme
|
|
32
|
+
* in force is always the one in the anchor slot, before opening and again
|
|
33
|
+
* after choosing. The other two keep their order relative to each other,
|
|
34
|
+
* so the list is still predictable.
|
|
35
|
+
*
|
|
36
|
+
* Reordered here rather than with CSS `order` so that the tab order and
|
|
37
|
+
* the visual order stay the same thing. Keys are stable, so React moves
|
|
38
|
+
* the existing nodes and a focused button keeps its focus.
|
|
39
|
+
*/
|
|
40
|
+
const ordered = collapsed && direction === "column" && mounted
|
|
41
|
+
? [...THEMES].sort((a, b) => Number(theme === b.value) - Number(theme === a.value))
|
|
42
|
+
: THEMES;
|
|
43
|
+
const options = ordered.map(({ value, icon, label }) => {
|
|
44
|
+
const active = mounted && theme === value;
|
|
45
|
+
return (_jsx(Row, { fit: true,
|
|
46
|
+
// Collapsed, an unresolved theme would hide all three and leave an
|
|
47
|
+
// empty pill, so before mount the group renders open.
|
|
48
|
+
className: classNames(styles.option, mounted && !active && styles.inactive), suppressHydrationWarning: true, children: _jsx(IconButton, { icon: icon, variant: active ? "primary" : "tertiary", onClick: () => setTheme(value), "aria-label": label, "aria-pressed": active, suppressHydrationWarning: true }) }, value));
|
|
49
|
+
});
|
|
50
|
+
/*
|
|
51
|
+
* Opening downwards needs two elements, not one.
|
|
52
|
+
*
|
|
53
|
+
* The outer box is what the layout sees, and it stays the size of a single
|
|
54
|
+
* option however many are showing — that is the whole point of the
|
|
55
|
+
* collapsed control, and a group that grows in the flow would push its
|
|
56
|
+
* neighbours along every time it opened. The panel is taken out of the
|
|
57
|
+
* flow and hung from the outer box's top-left, so it grows over the page
|
|
58
|
+
* instead of through the header.
|
|
59
|
+
*
|
|
60
|
+
* The border and the radius move to the panel with the options, because
|
|
61
|
+
* they belong to the thing that is actually visible.
|
|
62
|
+
*/
|
|
63
|
+
if (collapsed && direction === "column") {
|
|
64
|
+
return (_jsx(Row, { "data-border": "rounded", ref: ref, fit: true, className: classNames(styles.anchor, className), suppressHydrationWarning: true, ...flex, children: _jsx(Column, { gap: "2", border: "neutral-alpha-weak", radius: "full", background: "page", className: classNames(styles.collapsed, styles.panel), suppressHydrationWarning: true, children: options }) }));
|
|
65
|
+
}
|
|
66
|
+
return (_jsx(Row, { "data-border": "rounded", ref: ref, gap: "2", border: "neutral-alpha-weak", radius: "full", suppressHydrationWarning: true, className: classNames(collapsed && styles.collapsed, className), ...flex, children: options }));
|
|
28
67
|
});
|
|
29
68
|
ThemeSwitcher.displayName = "ThemeSwitcher";
|
|
30
69
|
export { ThemeSwitcher };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeSwitcher.js","sourceRoot":"","sources":["../../src/components/ThemeSwitcher.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,UAAU,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ThemeSwitcher.js","sourceRoot":"","sources":["../../src/components/ThemeSwitcher.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,UAAU,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;AAC5C,OAAO,MAAM,MAAM,6BAA6B,CAAC;AAEjD,MAAM,MAAM,GAAG;IACb,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;IAC5D,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;IACpD,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAA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CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EACxC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,gBAClB,KAAK,kBACH,MAAM,EACpB,wBAAwB,SACxB,IAdG,KAAK,CAeN,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;;;OAYG;IACH,IAAI,SAAS,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,CACL,KAAC,GAAG,mBACU,SAAS,EACrB,GAAG,EAAE,GAAG,EACR,GAAG,QACH,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/C,wBAAwB,WACpB,IAAI,YAER,KAAC,MAAM,IACL,GAAG,EAAC,GAAG,EACP,MAAM,EAAC,oBAAoB,EAC3B,MAAM,EAAC,MAAM,EACb,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EACrD,wBAAwB,kBAEvB,OAAO,GACD,GACL,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,GAAG,mBACU,SAAS,EACrB,GAAG,EAAE,GAAG,EACR,GAAG,EAAC,GAAG,EACP,MAAM,EAAC,oBAAoB,EAC3B,MAAM,EAAC,MAAM,EACb,wBAAwB,QACxB,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,KAC3D,IAAI,YAEP,OAAO,GACJ,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -24,19 +24,31 @@
|
|
|
24
24
|
overflow: hidden;
|
|
25
25
|
transition:
|
|
26
26
|
max-width var(--transition-duration-micro-medium, 0.15s) ease,
|
|
27
|
+
margin var(--transition-duration-micro-medium, 0.15s) ease,
|
|
27
28
|
opacity var(--transition-duration-micro-short, 0.1s) ease;
|
|
28
29
|
max-width: var(--static-space-40, 2.5rem);
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
/* A zero-width option still owns its share of the group's gap, which left
|
|
33
|
+
the pill a few pixels wider than the one button it shows. Each hidden
|
|
34
|
+
option takes one gap with it: the gap before it, or, for the first
|
|
35
|
+
option, the gap after it. The value is the group's `gap="2"`. */
|
|
31
36
|
.option.inactive {
|
|
32
37
|
max-width: 0;
|
|
33
38
|
opacity: 0;
|
|
39
|
+
margin-left: calc(-1 * var(--static-space-2, 0.125rem));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.option.inactive:first-child {
|
|
43
|
+
margin-left: 0;
|
|
44
|
+
margin-right: calc(-1 * var(--static-space-2, 0.125rem));
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
&:hover .option.inactive,
|
|
37
48
|
&:focus-within .option.inactive {
|
|
38
49
|
max-width: var(--static-space-40, 2.5rem);
|
|
39
50
|
opacity: 1;
|
|
51
|
+
margin: 0;
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
|
|
@@ -44,6 +56,7 @@
|
|
|
44
56
|
.collapsed .option.inactive {
|
|
45
57
|
max-width: var(--static-space-40, 2.5rem);
|
|
46
58
|
opacity: 1;
|
|
59
|
+
margin: 0;
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
62
|
|
|
@@ -52,3 +65,102 @@
|
|
|
52
65
|
transition: none;
|
|
53
66
|
}
|
|
54
67
|
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Opening downwards, over the page.
|
|
71
|
+
*
|
|
72
|
+
* The anchor is what the surrounding layout sees, and it is exactly one option
|
|
73
|
+
* — so a header reserves one slot whether the group is open or shut, and
|
|
74
|
+
* nothing beside it moves when it opens. `overflow: visible` matters: the
|
|
75
|
+
* panel is taller than a typical header and has to be allowed out of it.
|
|
76
|
+
*/
|
|
77
|
+
.anchor {
|
|
78
|
+
position: relative;
|
|
79
|
+
width: var(--static-space-40, 2.5rem);
|
|
80
|
+
height: var(--static-space-40, 2.5rem);
|
|
81
|
+
overflow: visible;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.panel {
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: 0;
|
|
87
|
+
left: 0;
|
|
88
|
+
/* Above the page, and above a sticky header's own content. */
|
|
89
|
+
z-index: 1;
|
|
90
|
+
|
|
91
|
+
/* Shut, the panel is the size of the one option it shows and has no edges of
|
|
92
|
+
its own to draw: a pill border around a single icon button is a second
|
|
93
|
+
outline around the button's own. They arrive with the panel opening. */
|
|
94
|
+
border-color: transparent;
|
|
95
|
+
background: transparent;
|
|
96
|
+
transition:
|
|
97
|
+
border-color var(--transition-duration-micro-medium, 0.15s) ease,
|
|
98
|
+
background var(--transition-duration-micro-medium, 0.15s) ease,
|
|
99
|
+
box-shadow var(--transition-duration-micro-medium, 0.15s) ease;
|
|
100
|
+
|
|
101
|
+
&:hover,
|
|
102
|
+
&:focus-within {
|
|
103
|
+
border-color: var(--neutral-alpha-weak);
|
|
104
|
+
background: var(--page-background);
|
|
105
|
+
box-shadow: var(--shadow-m);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/*
|
|
109
|
+
* Vertical clipping, where the row variant clips horizontally.
|
|
110
|
+
*
|
|
111
|
+
* `max-height` rather than `height` so the option is never squashed on the
|
|
112
|
+
* way out, and the margin trick is the row variant's, turned ninety degrees:
|
|
113
|
+
* a zero-height option still owns its share of the column's `gap="2"`, which
|
|
114
|
+
* would leave the shut panel a few pixels taller than the button it shows.
|
|
115
|
+
*/
|
|
116
|
+
.option {
|
|
117
|
+
max-width: none;
|
|
118
|
+
max-height: var(--static-space-40, 2.5rem);
|
|
119
|
+
transition:
|
|
120
|
+
max-height var(--transition-duration-micro-medium, 0.15s) ease,
|
|
121
|
+
margin var(--transition-duration-micro-medium, 0.15s) ease,
|
|
122
|
+
opacity var(--transition-duration-micro-short, 0.1s) ease;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.option.inactive {
|
|
126
|
+
max-width: none;
|
|
127
|
+
max-height: 0;
|
|
128
|
+
opacity: 0;
|
|
129
|
+
margin-left: 0;
|
|
130
|
+
margin-right: 0;
|
|
131
|
+
margin-top: calc(-1 * var(--static-space-2, 0.125rem));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.option.inactive:first-child {
|
|
135
|
+
margin-top: 0;
|
|
136
|
+
margin-bottom: calc(-1 * var(--static-space-2, 0.125rem));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&:hover .option.inactive,
|
|
140
|
+
&:focus-within .option.inactive {
|
|
141
|
+
max-height: var(--static-space-40, 2.5rem);
|
|
142
|
+
opacity: 1;
|
|
143
|
+
margin: 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@media (hover: none) {
|
|
148
|
+
.panel .option.inactive {
|
|
149
|
+
max-height: var(--static-space-40, 2.5rem);
|
|
150
|
+
opacity: 1;
|
|
151
|
+
margin: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Always open on a touch device, so it must carry its edges and reserve its
|
|
155
|
+
height rather than hanging over whatever is under it. */
|
|
156
|
+
.panel {
|
|
157
|
+
position: relative;
|
|
158
|
+
border-color: var(--neutral-alpha-weak);
|
|
159
|
+
background: var(--page-background);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.anchor {
|
|
163
|
+
width: auto;
|
|
164
|
+
height: auto;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { UserProps, DropdownWrapperProps } from ".";
|
|
3
|
-
import { Placement } from "
|
|
3
|
+
import type { Placement } from "../types";
|
|
4
4
|
interface UserMenuProps extends UserProps, Pick<DropdownWrapperProps, "minHeight" | "minWidth" | "maxWidth"> {
|
|
5
5
|
selected?: boolean;
|
|
6
6
|
placement?: Placement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMenu.d.ts","sourceRoot":"","sources":["../../src/components/UserMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAyB,SAAS,EAAE,oBAAoB,EAAU,MAAM,GAAG,CAAC;AAEnF,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"UserMenu.d.ts","sourceRoot":"","sources":["../../src/components/UserMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAyB,SAAS,EAAE,oBAAoB,EAAU,MAAM,GAAG,CAAC;AAEnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,UAAU,aACR,SAAQ,SAAS,EACf,IAAI,CAAC,oBAAoB,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,QAAA,MAAM,QAAQ,sFAwCZ,CAAC;AAGH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -47,6 +47,7 @@ export * from "./ClientFlex";
|
|
|
47
47
|
export * from "./Flex";
|
|
48
48
|
export * from "./FlipFx";
|
|
49
49
|
export * from "./FocusTrap";
|
|
50
|
+
export * from "./Form";
|
|
50
51
|
export * from "./GlitchFx";
|
|
51
52
|
export * from "./ServerGrid";
|
|
52
53
|
export * from "./ClientGrid";
|
|
@@ -77,7 +78,7 @@ export * from "./NumberInput";
|
|
|
77
78
|
export * from "./OgCard";
|
|
78
79
|
export * from "./Option";
|
|
79
80
|
export * from "./OTPInput";
|
|
80
|
-
export * from "./
|
|
81
|
+
export * from "./ParticleFx";
|
|
81
82
|
export * from "./PasswordInput";
|
|
82
83
|
export * from "./ProgressBar";
|
|
83
84
|
export * from "./Pulse";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,e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