@journ/nude 0.1.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/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/accordion-parts.d.ts +15 -0
- package/dist/accordion-parts.js +19 -0
- package/dist/accordion.d.ts +10 -0
- package/dist/accordion.js +10 -0
- package/dist/alert-dialog-parts.d.ts +13 -0
- package/dist/alert-dialog-parts.js +15 -0
- package/dist/alert-dialog.d.ts +14 -0
- package/dist/alert-dialog.js +15 -0
- package/dist/alert.d.ts +11 -0
- package/dist/alert.js +12 -0
- package/dist/animated-size.d.ts +18 -0
- package/dist/animated-size.js +55 -0
- package/dist/avatar-parts.d.ts +10 -0
- package/dist/avatar-parts.js +14 -0
- package/dist/avatar.d.ts +9 -0
- package/dist/avatar.js +9 -0
- package/dist/badge.d.ts +4 -0
- package/dist/badge.js +5 -0
- package/dist/breadcrumbs.d.ts +11 -0
- package/dist/breadcrumbs.js +15 -0
- package/dist/bulk-bar.d.ts +8 -0
- package/dist/bulk-bar.js +9 -0
- package/dist/button.d.ts +13 -0
- package/dist/button.js +21 -0
- package/dist/calendar-parts.d.ts +81 -0
- package/dist/calendar-parts.js +213 -0
- package/dist/calendar.d.ts +17 -0
- package/dist/calendar.js +17 -0
- package/dist/card.d.ts +12 -0
- package/dist/card.js +13 -0
- package/dist/carousel-parts.d.ts +29 -0
- package/dist/carousel-parts.js +98 -0
- package/dist/carousel.d.ts +11 -0
- package/dist/carousel.js +11 -0
- package/dist/checkbox-parts.d.ts +7 -0
- package/dist/checkbox-parts.js +9 -0
- package/dist/checkbox.d.ts +7 -0
- package/dist/checkbox.js +8 -0
- package/dist/chip.d.ts +22 -0
- package/dist/chip.js +29 -0
- package/dist/collapsible-parts.d.ts +7 -0
- package/dist/collapsible-parts.js +9 -0
- package/dist/collapsible.d.ts +8 -0
- package/dist/collapsible.js +9 -0
- package/dist/combobox-parts.d.ts +85 -0
- package/dist/combobox-parts.js +61 -0
- package/dist/combobox.d.ts +84 -0
- package/dist/combobox.js +21 -0
- package/dist/command-palette-parts.d.ts +22 -0
- package/dist/command-palette-parts.js +56 -0
- package/dist/command-palette.d.ts +64 -0
- package/dist/command-palette.js +18 -0
- package/dist/composer.d.ts +7 -0
- package/dist/composer.js +8 -0
- package/dist/context-menu-parts.d.ts +8 -0
- package/dist/context-menu-parts.js +10 -0
- package/dist/context-menu.d.ts +12 -0
- package/dist/context-menu.js +13 -0
- package/dist/currency-input-parts.d.ts +22 -0
- package/dist/currency-input-parts.js +57 -0
- package/dist/currency-input.d.ts +8 -0
- package/dist/currency-input.js +8 -0
- package/dist/data-table-parts.d.ts +101 -0
- package/dist/data-table-parts.js +220 -0
- package/dist/data-table.d.ts +12 -0
- package/dist/data-table.js +12 -0
- package/dist/date-input-parts.d.ts +15 -0
- package/dist/date-input-parts.js +54 -0
- package/dist/date-input.d.ts +8 -0
- package/dist/date-input.js +8 -0
- package/dist/date-picker-parts.d.ts +29 -0
- package/dist/date-picker-parts.js +33 -0
- package/dist/date-picker.d.ts +29 -0
- package/dist/date-picker.js +15 -0
- package/dist/date-range-picker-parts.d.ts +37 -0
- package/dist/date-range-picker-parts.js +63 -0
- package/dist/date-range-picker.d.ts +29 -0
- package/dist/date-range-picker.js +15 -0
- package/dist/description-list.d.ts +8 -0
- package/dist/description-list.js +9 -0
- package/dist/dialog-parts.d.ts +12 -0
- package/dist/dialog-parts.js +14 -0
- package/dist/dialog.d.ts +14 -0
- package/dist/dialog.js +15 -0
- package/dist/divider.d.ts +5 -0
- package/dist/divider.js +9 -0
- package/dist/drawer-parts.d.ts +24 -0
- package/dist/drawer-parts.js +14 -0
- package/dist/drawer.d.ts +27 -0
- package/dist/drawer.js +15 -0
- package/dist/dropdown-menu-parts.d.ts +8 -0
- package/dist/dropdown-menu-parts.js +10 -0
- package/dist/dropdown-menu.d.ts +12 -0
- package/dist/dropdown-menu.js +13 -0
- package/dist/empty-state.d.ts +10 -0
- package/dist/empty-state.js +11 -0
- package/dist/field-parts.d.ts +15 -0
- package/dist/field-parts.js +63 -0
- package/dist/field.d.ts +11 -0
- package/dist/field.js +11 -0
- package/dist/file-dropzone-parts.d.ts +34 -0
- package/dist/file-dropzone-parts.js +108 -0
- package/dist/file-dropzone.d.ts +10 -0
- package/dist/file-dropzone.js +10 -0
- package/dist/heading.d.ts +9 -0
- package/dist/heading.js +12 -0
- package/dist/hover-card-parts.d.ts +8 -0
- package/dist/hover-card-parts.js +12 -0
- package/dist/hover-card.d.ts +9 -0
- package/dist/hover-card.js +9 -0
- package/dist/icon-button.d.ts +6 -0
- package/dist/icon-button.js +5 -0
- package/dist/icon.d.ts +7 -0
- package/dist/icon.js +12 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +87 -0
- package/dist/input.d.ts +4 -0
- package/dist/input.js +5 -0
- package/dist/lib/commit-on.d.ts +15 -0
- package/dist/lib/commit-on.js +17 -0
- package/dist/lib/menu-parts.d.ts +21 -0
- package/dist/lib/menu-parts.js +23 -0
- package/dist/lib/modal-content.d.ts +17 -0
- package/dist/lib/modal-content.js +17 -0
- package/dist/lib/modal-parts.d.ts +6 -0
- package/dist/lib/modal-parts.js +7 -0
- package/dist/lib/part.d.ts +6 -0
- package/dist/lib/part.js +13 -0
- package/dist/lib/picker.d.ts +44 -0
- package/dist/lib/picker.js +75 -0
- package/dist/lib/visually-hidden.d.ts +6 -0
- package/dist/lib/visually-hidden.js +15 -0
- package/dist/link.d.ts +9 -0
- package/dist/link.js +12 -0
- package/dist/markdown.d.ts +10 -0
- package/dist/markdown.js +10 -0
- package/dist/message.d.ts +13 -0
- package/dist/message.js +15 -0
- package/dist/month-picker-parts.d.ts +19 -0
- package/dist/month-picker-parts.js +38 -0
- package/dist/month-picker.d.ts +15 -0
- package/dist/month-picker.js +15 -0
- package/dist/month-stepper-parts.d.ts +16 -0
- package/dist/month-stepper-parts.js +52 -0
- package/dist/month-stepper.d.ts +10 -0
- package/dist/month-stepper.js +10 -0
- package/dist/multiple-selector-parts.d.ts +39 -0
- package/dist/multiple-selector-parts.js +118 -0
- package/dist/multiple-selector.d.ts +76 -0
- package/dist/multiple-selector.js +23 -0
- package/dist/nav-bar.d.ts +7 -0
- package/dist/nav-bar.js +8 -0
- package/dist/navigation-menu-parts.d.ts +18 -0
- package/dist/navigation-menu-parts.js +25 -0
- package/dist/navigation-menu.d.ts +12 -0
- package/dist/navigation-menu.js +12 -0
- package/dist/otp-input-parts.d.ts +9 -0
- package/dist/otp-input-parts.js +11 -0
- package/dist/otp-input.d.ts +8 -0
- package/dist/otp-input.js +9 -0
- package/dist/page-header.d.ts +8 -0
- package/dist/page-header.js +9 -0
- package/dist/page.d.ts +8 -0
- package/dist/page.js +9 -0
- package/dist/pagination.d.ts +13 -0
- package/dist/pagination.js +24 -0
- package/dist/pill-select.d.ts +4 -0
- package/dist/pill-select.js +5 -0
- package/dist/popover-parts.d.ts +9 -0
- package/dist/popover-parts.js +13 -0
- package/dist/popover.d.ts +10 -0
- package/dist/popover.js +10 -0
- package/dist/portal.d.ts +15 -0
- package/dist/portal.js +20 -0
- package/dist/progress-parts.d.ts +11 -0
- package/dist/progress-parts.js +32 -0
- package/dist/progress.d.ts +8 -0
- package/dist/progress.js +8 -0
- package/dist/quantity-input-parts.d.ts +21 -0
- package/dist/quantity-input-parts.js +86 -0
- package/dist/quantity-input.d.ts +10 -0
- package/dist/quantity-input.js +10 -0
- package/dist/radio-parts.d.ts +13 -0
- package/dist/radio-parts.js +17 -0
- package/dist/radio.d.ts +8 -0
- package/dist/radio.js +8 -0
- package/dist/scroll-area-parts.d.ts +17 -0
- package/dist/scroll-area-parts.js +21 -0
- package/dist/scroll-area.d.ts +10 -0
- package/dist/scroll-area.js +10 -0
- package/dist/select-parts.d.ts +26 -0
- package/dist/select-parts.js +38 -0
- package/dist/select.d.ts +14 -0
- package/dist/select.js +14 -0
- package/dist/sheet-parts.d.ts +15 -0
- package/dist/sheet-parts.js +15 -0
- package/dist/sheet.d.ts +14 -0
- package/dist/sheet.js +16 -0
- package/dist/sidebar.d.ts +14 -0
- package/dist/sidebar.js +17 -0
- package/dist/skeleton.d.ts +4 -0
- package/dist/skeleton.js +5 -0
- package/dist/slider-parts.d.ts +9 -0
- package/dist/slider-parts.js +11 -0
- package/dist/slider.d.ts +9 -0
- package/dist/slider.js +10 -0
- package/dist/spinner.d.ts +6 -0
- package/dist/spinner.js +23 -0
- package/dist/stack-parts.d.ts +22 -0
- package/dist/stack-parts.js +125 -0
- package/dist/stack.d.ts +10 -0
- package/dist/stack.js +10 -0
- package/dist/stat.d.ts +9 -0
- package/dist/stat.js +10 -0
- package/dist/step-button.d.ts +11 -0
- package/dist/step-button.js +13 -0
- package/dist/stepper-parts.d.ts +19 -0
- package/dist/stepper-parts.js +44 -0
- package/dist/stepper.d.ts +11 -0
- package/dist/stepper.js +11 -0
- package/dist/switch-parts.d.ts +6 -0
- package/dist/switch-parts.js +8 -0
- package/dist/switch.d.ts +7 -0
- package/dist/switch.js +8 -0
- package/dist/table.d.ts +12 -0
- package/dist/table.js +13 -0
- package/dist/tabs-parts.d.ts +8 -0
- package/dist/tabs-parts.js +10 -0
- package/dist/tabs.d.ts +9 -0
- package/dist/tabs.js +10 -0
- package/dist/tag-input-parts.d.ts +30 -0
- package/dist/tag-input-parts.js +99 -0
- package/dist/tag-input.d.ts +10 -0
- package/dist/tag-input.js +10 -0
- package/dist/text-morph.d.ts +17 -0
- package/dist/text-morph.js +62 -0
- package/dist/text-shimmer.d.ts +9 -0
- package/dist/text-shimmer.js +8 -0
- package/dist/text.d.ts +4 -0
- package/dist/text.js +5 -0
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.js +5 -0
- package/dist/time-range-parts.d.ts +22 -0
- package/dist/time-range-parts.js +56 -0
- package/dist/time-range.d.ts +10 -0
- package/dist/time-range.js +10 -0
- package/dist/toast-parts.d.ts +12 -0
- package/dist/toast-parts.js +21 -0
- package/dist/toast.d.ts +13 -0
- package/dist/toast.js +12 -0
- package/dist/toggle-group-parts.d.ts +6 -0
- package/dist/toggle-group-parts.js +8 -0
- package/dist/toggle-group.d.ts +7 -0
- package/dist/toggle-group.js +8 -0
- package/dist/tooltip-parts.d.ts +10 -0
- package/dist/tooltip-parts.js +17 -0
- package/dist/tooltip.d.ts +10 -0
- package/dist/tooltip.js +10 -0
- package/dist/touch-target.d.ts +6 -0
- package/dist/touch-target.js +10 -0
- package/package.json +83 -0
package/dist/spinner.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
//#region src/spinner.tsx
|
|
3
|
+
/** Announces itself as "Loading" unless `aria-hidden` says another element already does. */
|
|
4
|
+
const Spinner = ({ "aria-hidden": hidden, ...props }) => /* @__PURE__ */ jsxs("svg", {
|
|
5
|
+
"data-slot": "spinner",
|
|
6
|
+
role: hidden ? void 0 : "status",
|
|
7
|
+
"aria-label": hidden ? void 0 : "Loading",
|
|
8
|
+
"aria-hidden": hidden,
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
fill: "none",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeWidth: 3,
|
|
13
|
+
strokeLinecap: "round",
|
|
14
|
+
...props,
|
|
15
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
16
|
+
cx: "12",
|
|
17
|
+
cy: "12",
|
|
18
|
+
r: "9",
|
|
19
|
+
opacity: .2
|
|
20
|
+
}), /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9" })]
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Spinner };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
//#region src/stack-parts.d.ts
|
|
3
|
+
type RootProps = Omit<ComponentPropsWithRef<'div'>, 'defaultValue'> & {
|
|
4
|
+
defaultValue: string;
|
|
5
|
+
onValueChange?: (value: string) => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Activating an item moves it to the end of the stack (the front) and the
|
|
9
|
+
* remaining items keep their relative order. Positions are animated with a FLIP
|
|
10
|
+
* transition so every item glides to its new place.
|
|
11
|
+
*/
|
|
12
|
+
declare const Root: ({ defaultValue, onValueChange, ...props }: RootProps) => import("react").JSX.Element;
|
|
13
|
+
type ItemProps = Omit<ComponentPropsWithRef<'div'>, 'ref'> & {
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
/** Sets `order` and `z-index` inline, so the stack only reorders inside a flex or grid root. */
|
|
17
|
+
declare const Item: ({ value, style, ...props }: ItemProps) => import("react").JSX.Element;
|
|
18
|
+
declare const Trigger: ({ onClick, ...props }: ComponentPropsWithRef<'button'>) => import("react").JSX.Element;
|
|
19
|
+
/** Inert and hidden while its item is not the active one. */
|
|
20
|
+
declare const Content: (props: ComponentPropsWithRef<'div'>) => import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Content, Item, type ItemProps, Root, type RootProps, Trigger };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createRequiredContext, prefersReducedMotion } from "@journ/lift";
|
|
5
|
+
import { animate } from "animejs";
|
|
6
|
+
//#region src/stack-parts.tsx
|
|
7
|
+
const [StackContext, useStack] = createRequiredContext("Stack.Root");
|
|
8
|
+
const [ItemContext, useItemValue] = createRequiredContext("Stack.Item");
|
|
9
|
+
/**
|
|
10
|
+
* Activating an item moves it to the end of the stack (the front) and the
|
|
11
|
+
* remaining items keep their relative order. Positions are animated with a FLIP
|
|
12
|
+
* transition so every item glides to its new place.
|
|
13
|
+
*/
|
|
14
|
+
const Root = ({ defaultValue, onValueChange, ...props }) => {
|
|
15
|
+
const [history, setHistory] = useState([defaultValue]);
|
|
16
|
+
const elements = useRef(/* @__PURE__ */ new Map());
|
|
17
|
+
const firstRects = useRef(null);
|
|
18
|
+
const active = history[history.length - 1] ?? defaultValue;
|
|
19
|
+
const register = useCallback((value, element) => {
|
|
20
|
+
if (element) elements.current.set(value, element);
|
|
21
|
+
else elements.current.delete(value);
|
|
22
|
+
}, []);
|
|
23
|
+
const activate = useCallback((value) => {
|
|
24
|
+
if (value === active) return;
|
|
25
|
+
firstRects.current = new Map([...elements.current].map(([key, element]) => [key, element.getBoundingClientRect().top]));
|
|
26
|
+
setHistory((current) => [...current.filter((entry) => entry !== value), value]);
|
|
27
|
+
onValueChange?.(value);
|
|
28
|
+
}, [active, onValueChange]);
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
const first = firstRects.current;
|
|
31
|
+
firstRects.current = null;
|
|
32
|
+
if (!first || prefersReducedMotion()) return;
|
|
33
|
+
for (const [value, element] of elements.current) {
|
|
34
|
+
const previous = first.get(value);
|
|
35
|
+
if (previous === void 0) continue;
|
|
36
|
+
const delta = previous - element.getBoundingClientRect().top;
|
|
37
|
+
if (delta !== 0) animate(element, {
|
|
38
|
+
translateY: [delta, 0],
|
|
39
|
+
duration: 300,
|
|
40
|
+
ease: "outExpo"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, [history]);
|
|
44
|
+
return /* @__PURE__ */ jsx(StackContext, {
|
|
45
|
+
value: {
|
|
46
|
+
active,
|
|
47
|
+
history,
|
|
48
|
+
activate,
|
|
49
|
+
register
|
|
50
|
+
},
|
|
51
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
52
|
+
"data-slot": "stack",
|
|
53
|
+
...props
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
/** Sets `order` and `z-index` inline, so the stack only reorders inside a flex or grid root. */
|
|
58
|
+
const Item = ({ value, style, ...props }) => {
|
|
59
|
+
const { active, history, register } = useStack();
|
|
60
|
+
const position = history.indexOf(value) + 1;
|
|
61
|
+
const itemStyle = {
|
|
62
|
+
...style,
|
|
63
|
+
order: position,
|
|
64
|
+
zIndex: position
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsx(ItemContext, {
|
|
67
|
+
value,
|
|
68
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
69
|
+
"data-slot": "stack-item",
|
|
70
|
+
"data-value": value,
|
|
71
|
+
"data-active": active === value,
|
|
72
|
+
ref: (element) => {
|
|
73
|
+
register(value, element);
|
|
74
|
+
return () => register(value, null);
|
|
75
|
+
},
|
|
76
|
+
...props,
|
|
77
|
+
style: itemStyle
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const Trigger = ({ onClick, ...props }) => {
|
|
82
|
+
const { active, activate } = useStack();
|
|
83
|
+
const value = useItemValue();
|
|
84
|
+
return /* @__PURE__ */ jsx("button", {
|
|
85
|
+
type: "button",
|
|
86
|
+
"data-slot": "stack-trigger",
|
|
87
|
+
"aria-expanded": active === value,
|
|
88
|
+
...props,
|
|
89
|
+
onClick: (event) => {
|
|
90
|
+
onClick?.(event);
|
|
91
|
+
activate(value);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/** Inert and hidden while its item is not the active one. */
|
|
96
|
+
const Content = (props) => {
|
|
97
|
+
const { active } = useStack();
|
|
98
|
+
const isActive = active === useItemValue();
|
|
99
|
+
const element = useRef(null);
|
|
100
|
+
const mounted = useRef(false);
|
|
101
|
+
useLayoutEffect(() => {
|
|
102
|
+
if (!mounted.current) {
|
|
103
|
+
mounted.current = true;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!isActive || !element.current || prefersReducedMotion()) return;
|
|
107
|
+
animate(element.current, {
|
|
108
|
+
opacity: [0, 1],
|
|
109
|
+
translateY: [12, 0],
|
|
110
|
+
duration: 250,
|
|
111
|
+
delay: 100,
|
|
112
|
+
ease: "outExpo"
|
|
113
|
+
});
|
|
114
|
+
}, [isActive]);
|
|
115
|
+
return /* @__PURE__ */ jsx("div", {
|
|
116
|
+
ref: element,
|
|
117
|
+
"data-slot": "stack-content",
|
|
118
|
+
"data-active": isActive,
|
|
119
|
+
inert: !isActive,
|
|
120
|
+
hidden: !isActive,
|
|
121
|
+
...props
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
export { Content, Item, Root, Trigger };
|
package/dist/stack.d.ts
ADDED
package/dist/stack.js
ADDED
package/dist/stat.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/stat.d.ts
|
|
2
|
+
declare const Stat: {
|
|
3
|
+
Root: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => import("react").ReactNode;
|
|
4
|
+
Label: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>) => import("react").ReactNode;
|
|
5
|
+
Value: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>) => import("react").ReactNode;
|
|
6
|
+
Hint: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>) => import("react").ReactNode;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Stat };
|
package/dist/stat.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IconButtonProps } from "./icon-button.js";
|
|
2
|
+
//#region src/step-button.d.ts
|
|
3
|
+
type StepButtonProps = Omit<IconButtonProps, 'onClick'> & {
|
|
4
|
+
/** Runs after the caller's own `onClick`. */
|
|
5
|
+
onStep: () => void;
|
|
6
|
+
onClick?: IconButtonProps['onClick'];
|
|
7
|
+
};
|
|
8
|
+
/** The icon button behind every previous, next, minus and plus control. */
|
|
9
|
+
declare const StepButton: ({ onStep, onClick, ...props }: StepButtonProps) => import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { StepButton, type StepButtonProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IconButton } from "./icon-button.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/step-button.tsx
|
|
4
|
+
/** The icon button behind every previous, next, minus and plus control. */
|
|
5
|
+
const StepButton = ({ onStep, onClick, ...props }) => /* @__PURE__ */ jsx(IconButton, {
|
|
6
|
+
...props,
|
|
7
|
+
onClick: (event) => {
|
|
8
|
+
onClick?.(event);
|
|
9
|
+
onStep();
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
//#endregion
|
|
13
|
+
export { StepButton };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
//#region src/stepper-parts.d.ts
|
|
3
|
+
type StepStatus = 'complete' | 'current' | 'upcoming';
|
|
4
|
+
declare const useStepperItem: any;
|
|
5
|
+
type RootProps = ComponentPropsWithRef<'ol'> & {
|
|
6
|
+
/** The step the user is on, starting at 1. */
|
|
7
|
+
value: number;
|
|
8
|
+
};
|
|
9
|
+
declare const Root: ({ value, ...props }: RootProps) => import("react").JSX.Element;
|
|
10
|
+
type ItemProps = ComponentPropsWithRef<'li'> & {
|
|
11
|
+
step: number;
|
|
12
|
+
};
|
|
13
|
+
declare const Item: ({ step, ...props }: ItemProps) => import("react").JSX.Element;
|
|
14
|
+
/** Shows the step number unless children are given. */
|
|
15
|
+
declare const Indicator: ({ children, ...props }: ComponentPropsWithRef<'span'>) => import("react").JSX.Element;
|
|
16
|
+
declare const Label: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
|
|
17
|
+
declare const Description: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Description, Indicator, Item, Label, Root, type StepStatus, useStepperItem };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { part } from "./lib/part.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createRequiredContext } from "@journ/lift";
|
|
5
|
+
//#region src/stepper-parts.tsx
|
|
6
|
+
const [StepperContext, useStepper] = createRequiredContext("Stepper.Root");
|
|
7
|
+
const [ItemContext, useStepperItem] = createRequiredContext("Stepper.Item");
|
|
8
|
+
const Root = ({ value, ...props }) => /* @__PURE__ */ jsx(StepperContext, {
|
|
9
|
+
value: { value },
|
|
10
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
11
|
+
"data-slot": "stepper",
|
|
12
|
+
...props
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
const Item = ({ step, ...props }) => {
|
|
16
|
+
const context = useStepper();
|
|
17
|
+
const status = step < context.value ? "complete" : step === context.value ? "current" : "upcoming";
|
|
18
|
+
return /* @__PURE__ */ jsx(ItemContext, {
|
|
19
|
+
value: {
|
|
20
|
+
step,
|
|
21
|
+
status
|
|
22
|
+
},
|
|
23
|
+
children: /* @__PURE__ */ jsx("li", {
|
|
24
|
+
"data-slot": "stepper-item",
|
|
25
|
+
"data-status": status,
|
|
26
|
+
"aria-current": status === "current" ? "step" : void 0,
|
|
27
|
+
...props
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
/** Shows the step number unless children are given. */
|
|
32
|
+
const Indicator = ({ children, ...props }) => {
|
|
33
|
+
const { step } = useStepperItem();
|
|
34
|
+
return /* @__PURE__ */ jsx("span", {
|
|
35
|
+
"data-slot": "stepper-indicator",
|
|
36
|
+
"aria-hidden": true,
|
|
37
|
+
...props,
|
|
38
|
+
children: children ?? step
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const Label = part("span", "stepper-label");
|
|
42
|
+
const Description = part("span", "stepper-description");
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Description, Indicator, Item, Label, Root, useStepperItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Indicator, Item, Root } from "./stepper-parts.js";
|
|
2
|
+
//#region src/stepper.d.ts
|
|
3
|
+
declare const Stepper: {
|
|
4
|
+
Root: typeof Root;
|
|
5
|
+
Item: typeof Item;
|
|
6
|
+
Indicator: typeof Indicator;
|
|
7
|
+
Label: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
|
|
8
|
+
Description: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Stepper };
|
package/dist/stepper.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as RadixSwitch from "@radix-ui/react-switch";
|
|
2
|
+
//#region src/switch-parts.d.ts
|
|
3
|
+
declare const Root: (props: RadixSwitch.SwitchProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactNode;
|
|
4
|
+
declare const Thumb: (props: RadixSwitch.SwitchThumbProps & import("react").RefAttributes<HTMLSpanElement>) => import("react").ReactNode;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Root, Thumb };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { part } from "./lib/part.js";
|
|
3
|
+
import * as RadixSwitch from "@radix-ui/react-switch";
|
|
4
|
+
//#region src/switch-parts.tsx
|
|
5
|
+
const Root = part(RadixSwitch.Root, "switch");
|
|
6
|
+
const Thumb = part(RadixSwitch.Thumb, "switch-thumb");
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Root, Thumb };
|
package/dist/switch.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/switch.d.ts
|
|
2
|
+
declare const Switch: {
|
|
3
|
+
Root: (props: import("@radix-ui/react-switch").SwitchProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactNode;
|
|
4
|
+
Thumb: (props: import("@radix-ui/react-switch").SwitchThumbProps & import("react").RefAttributes<HTMLSpanElement>) => import("react").ReactNode;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { Switch };
|
package/dist/switch.js
ADDED
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/table.d.ts
|
|
2
|
+
declare const Table: {
|
|
3
|
+
Root: (props: import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>) => import("react").ReactNode;
|
|
4
|
+
Caption: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>) => import("react").ReactNode;
|
|
5
|
+
Head: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>) => import("react").ReactNode;
|
|
6
|
+
Body: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>) => import("react").ReactNode;
|
|
7
|
+
Row: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>) => import("react").ReactNode;
|
|
8
|
+
Header: (props: import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>) => import("react").ReactNode;
|
|
9
|
+
Cell: (props: import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>) => import("react").ReactNode;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Table };
|
package/dist/table.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { part } from "./lib/part.js";
|
|
2
|
+
//#region src/table.tsx
|
|
3
|
+
const Table = {
|
|
4
|
+
Root: part("table", "table"),
|
|
5
|
+
Caption: part("caption", "table-caption"),
|
|
6
|
+
Head: part("thead", "table-head"),
|
|
7
|
+
Body: part("tbody", "table-body"),
|
|
8
|
+
Row: part("tr", "table-row"),
|
|
9
|
+
Header: part("th", "table-header"),
|
|
10
|
+
Cell: part("td", "table-cell")
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Table };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as RadixTabs from "@radix-ui/react-tabs";
|
|
2
|
+
//#region src/tabs-parts.d.ts
|
|
3
|
+
declare const Root: (props: RadixTabs.TabsProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
|
|
4
|
+
declare const List: (props: RadixTabs.TabsListProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
|
|
5
|
+
declare const Trigger: (props: RadixTabs.TabsTriggerProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactNode;
|
|
6
|
+
declare const Content: (props: RadixTabs.TabsContentProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Content, List, Root, Trigger };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { part } from "./lib/part.js";
|
|
3
|
+
import * as RadixTabs from "@radix-ui/react-tabs";
|
|
4
|
+
//#region src/tabs-parts.tsx
|
|
5
|
+
const Root = part(RadixTabs.Root, "tabs");
|
|
6
|
+
const List = part(RadixTabs.List, "tabs-list");
|
|
7
|
+
const Trigger = part(RadixTabs.Trigger, "tabs-trigger");
|
|
8
|
+
const Content = part(RadixTabs.Content, "tabs-content");
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Content, List, Root, Trigger };
|
package/dist/tabs.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/tabs.d.ts
|
|
2
|
+
declare const Tabs: {
|
|
3
|
+
Root: (props: import("@radix-ui/react-tabs").TabsProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
|
|
4
|
+
List: (props: import("@radix-ui/react-tabs").TabsListProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
|
|
5
|
+
Trigger: (props: import("@radix-ui/react-tabs").TabsTriggerProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactNode;
|
|
6
|
+
Content: (props: import("@radix-ui/react-tabs").TabsContentProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Tabs };
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChipTagProps as TagProps$1 } from "./chip.js";
|
|
2
|
+
import { Composer } from "./composer.js";
|
|
3
|
+
import { ComponentPropsWithRef, ElementType, ReactNode } from "react";
|
|
4
|
+
//#region src/tag-input-parts.d.ts
|
|
5
|
+
declare const useTagInput: any;
|
|
6
|
+
type RootProps = Omit<ComponentPropsWithRef<'div'>, 'defaultValue' | 'onChange'> & {
|
|
7
|
+
value?: string[];
|
|
8
|
+
defaultValue?: string[];
|
|
9
|
+
onValueChange?: (tags: string[]) => void;
|
|
10
|
+
/** Return false to refuse a tag, e.g. an invalid email. The text stays so it can be fixed. */
|
|
11
|
+
validate?: (tag: string) => boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/** Tags are trimmed, unique (ignoring case) and never empty. */
|
|
15
|
+
declare const Root: ({ value, defaultValue, onValueChange, validate, children, ...props }: RootProps) => import("react").JSX.Element;
|
|
16
|
+
type TagComponents = {
|
|
17
|
+
/** The chip rendered per tag. It receives `removeLabel`, `onRemove` and the tag as children. */
|
|
18
|
+
components?: {
|
|
19
|
+
Tag?: ElementType;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type TagProps = Omit<TagProps$1, 'children' | 'onRemove'> & TagComponents & {
|
|
23
|
+
value: string;
|
|
24
|
+
};
|
|
25
|
+
declare const Tag: ({ value, components, ...props }: TagProps) => import("react").JSX.Element;
|
|
26
|
+
/** One `Tag` per value. Use `useTagInput` and `Tag` yourself for a custom list. */
|
|
27
|
+
declare const Tags: ({ components }: TagComponents) => any;
|
|
28
|
+
declare const Field: ({ onKeyDown, onBlur, onPaste, ...props }: ComponentPropsWithRef<typeof Composer.Input>) => import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Field, Root, type RootProps, Tag, type TagProps, Tags, useTagInput };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Chip } from "./chip.js";
|
|
3
|
+
import { Composer } from "./composer.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createRequiredContext, useControllableState } from "@journ/lift";
|
|
7
|
+
//#region src/tag-input-parts.tsx
|
|
8
|
+
const [TagInputContext, useTagInput] = createRequiredContext("TagInput.Root");
|
|
9
|
+
const none = [];
|
|
10
|
+
/** Tags are trimmed, unique (ignoring case) and never empty. */
|
|
11
|
+
const Root = ({ value, defaultValue = none, onValueChange, validate, children, ...props }) => {
|
|
12
|
+
const [stored, setStored] = useControllableState(value, defaultValue, onValueChange);
|
|
13
|
+
const tags = stored ?? none;
|
|
14
|
+
const [text, setText] = useState("");
|
|
15
|
+
const [invalid, setInvalid] = useState(false);
|
|
16
|
+
const add = (...incoming) => {
|
|
17
|
+
const next = [...tags];
|
|
18
|
+
let refused = false;
|
|
19
|
+
for (const raw of incoming) {
|
|
20
|
+
const tag = raw.trim();
|
|
21
|
+
if (!tag || next.some((existing) => existing.toLowerCase() === tag.toLowerCase())) continue;
|
|
22
|
+
if (validate && !validate(tag)) {
|
|
23
|
+
refused = true;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
next.push(tag);
|
|
27
|
+
}
|
|
28
|
+
setInvalid(refused);
|
|
29
|
+
if (next.length !== tags.length) setStored(next);
|
|
30
|
+
if (!refused) setText("");
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ jsx(TagInputContext, {
|
|
33
|
+
value: {
|
|
34
|
+
tags,
|
|
35
|
+
text,
|
|
36
|
+
invalid,
|
|
37
|
+
setText: (next) => (setInvalid(false), setText(next)),
|
|
38
|
+
add,
|
|
39
|
+
remove: (tag) => setStored(tags.filter((existing) => existing !== tag)),
|
|
40
|
+
removeLast: () => tags.length > 0 && setStored(tags.slice(0, -1))
|
|
41
|
+
},
|
|
42
|
+
children: /* @__PURE__ */ jsx(Composer.Root, {
|
|
43
|
+
"data-slot": "tag-input",
|
|
44
|
+
...props,
|
|
45
|
+
children
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const Tag = ({ value, components, ...props }) => {
|
|
50
|
+
const { remove } = useTagInput();
|
|
51
|
+
const ChipTag = components?.Tag ?? Chip.Tag;
|
|
52
|
+
return /* @__PURE__ */ jsx(ChipTag, {
|
|
53
|
+
"data-slot": "tag-input-tag",
|
|
54
|
+
removeLabel: `Remove ${value}`,
|
|
55
|
+
onRemove: () => remove(value),
|
|
56
|
+
...props,
|
|
57
|
+
children: value
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
/** One `Tag` per value. Use `useTagInput` and `Tag` yourself for a custom list. */
|
|
61
|
+
const Tags = ({ components }) => {
|
|
62
|
+
const { tags } = useTagInput();
|
|
63
|
+
return tags.map((tag) => /* @__PURE__ */ jsx(Tag, {
|
|
64
|
+
value: tag,
|
|
65
|
+
components
|
|
66
|
+
}, tag));
|
|
67
|
+
};
|
|
68
|
+
const Field = ({ onKeyDown, onBlur, onPaste, ...props }) => {
|
|
69
|
+
const { text, invalid, setText, add, removeLast } = useTagInput();
|
|
70
|
+
return /* @__PURE__ */ jsx(Composer.Input, {
|
|
71
|
+
"data-slot": "tag-input-field",
|
|
72
|
+
"aria-invalid": invalid || void 0,
|
|
73
|
+
...props,
|
|
74
|
+
value: text,
|
|
75
|
+
onChange: (event) => setText(event.target.value),
|
|
76
|
+
onKeyDown: (event) => {
|
|
77
|
+
onKeyDown?.(event);
|
|
78
|
+
if (event.key === "Enter" || event.key === ",") {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
add(text);
|
|
81
|
+
}
|
|
82
|
+
if (event.key === "Backspace" && text === "") removeLast();
|
|
83
|
+
},
|
|
84
|
+
onBlur: (event) => {
|
|
85
|
+
onBlur?.(event);
|
|
86
|
+
add(text);
|
|
87
|
+
},
|
|
88
|
+
onPaste: (event) => {
|
|
89
|
+
onPaste?.(event);
|
|
90
|
+
const pasted = event.clipboardData.getData("text");
|
|
91
|
+
if (/[,\n;]/.test(pasted)) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
add(...pasted.split(/[,\n;]+/));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { Field, Root, Tag, Tags, useTagInput };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Field, Root, RootProps, Tag, Tags, useTagInput } from "./tag-input-parts.js";
|
|
2
|
+
//#region src/tag-input.d.ts
|
|
3
|
+
declare const TagInput: {
|
|
4
|
+
Root: typeof Root;
|
|
5
|
+
Tags: typeof Tags;
|
|
6
|
+
Tag: typeof Tag;
|
|
7
|
+
Field: typeof Field;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { TagInput, type RootProps as TagInputProps, useTagInput };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ElementType } from "react";
|
|
2
|
+
//#region src/text-morph.d.ts
|
|
3
|
+
type TextMorphProps = Omit<ComponentPropsWithRef<'span'>, 'children'> & {
|
|
4
|
+
children: string;
|
|
5
|
+
as?: ElementType;
|
|
6
|
+
classNames?: {
|
|
7
|
+
label?: string;
|
|
8
|
+
char?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Plays text one character at a time. When the text changes, only the characters
|
|
13
|
+
* that differ drop in again. Screen readers get the whole string once.
|
|
14
|
+
*/
|
|
15
|
+
declare const TextMorph: ({ children: text, as: Component, classNames, style, ...props }: TextMorphProps) => import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { TextMorph, type TextMorphProps };
|