@kirana-ui/react 0.1.1 → 0.2.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/llms.txt +1601 -223
- package/package.json +14 -2
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.d.ts +26 -15
- package/src/accordion.js +11 -10
- package/src/accordion.js.map +1 -1
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +3 -2
- package/src/autocomplete.d.ts +3 -2
- package/src/autosize.d.ts +5 -2
- package/src/autosize.js +2 -2
- package/src/autosize.js.map +1 -1
- package/src/avatar.d.ts +12 -8
- package/src/avatar.js +18 -9
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -2
- package/src/button.js +3 -3
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +49 -28
- package/src/calendar.js +7 -3
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +25 -15
- package/src/carousel.js +3 -3
- package/src/carousel.js.map +1 -1
- package/src/checkbox.d.ts +10 -7
- package/src/checkbox.js +18 -12
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +12 -8
- package/src/collapsible.js +8 -7
- package/src/collapsible.js.map +1 -1
- package/src/combobox.d.ts +88 -60
- package/src/combobox.js +44 -31
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +30 -21
- package/src/command.js +14 -7
- package/src/command.js.map +1 -1
- package/src/context-menu.d.ts +3 -2
- package/src/date-field.d.ts +25 -13
- package/src/date-field.js +7 -3
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +31 -40
- package/src/date-picker.js +3 -3
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +45 -35
- package/src/dialog.js +12 -8
- package/src/dialog.js.map +1 -1
- package/src/direction.d.ts +1 -0
- package/src/direction.js.map +1 -1
- package/src/drawer.d.ts +3 -2
- package/src/element.d.ts +12 -0
- package/src/element.js +20 -0
- package/src/element.js.map +1 -0
- package/src/field.d.ts +24 -16
- package/src/field.js +9 -7
- package/src/field.js.map +1 -1
- package/src/fieldset.d.ts +10 -5
- package/src/fieldset.js +4 -5
- package/src/fieldset.js.map +1 -1
- package/src/form.d.ts +5 -2
- package/src/form.js +6 -6
- package/src/form.js.map +1 -1
- package/src/hover-card.d.ts +16 -10
- package/src/hover-card.js +1 -1
- package/src/hover-card.js.map +1 -1
- package/src/hover-popup.d.ts +24 -14
- package/src/hover-popup.js +5 -13
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +13 -3
- package/src/input.d.ts +4 -2
- package/src/input.js +3 -3
- package/src/input.js.map +1 -1
- package/src/label.d.ts +4 -1
- package/src/label.js +3 -3
- package/src/label.js.map +1 -1
- package/src/listbox.d.ts +23 -15
- package/src/listbox.js +4 -5
- package/src/listbox.js.map +1 -1
- package/src/menu.d.ts +83 -65
- package/src/menu.js +10 -18
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +5 -3
- package/src/menubar.js +3 -3
- package/src/menubar.js.map +1 -1
- package/src/message-scroller.d.ts +15 -9
- package/src/message-scroller.js +3 -3
- package/src/message-scroller.js.map +1 -1
- package/src/meter.d.ts +18 -9
- package/src/meter.js +1 -1
- package/src/meter.js.map +1 -1
- package/src/navigation-menu.d.ts +50 -40
- package/src/navigation-menu.js +15 -24
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +19 -12
- package/src/number-field.js +6 -10
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +24 -15
- package/src/otp.js +7 -13
- package/src/otp.js.map +1 -1
- package/src/pagination.d.ts +26 -16
- package/src/pagination.js +3 -3
- package/src/pagination.js.map +1 -1
- package/src/popover.d.ts +30 -21
- package/src/popover.js +9 -13
- package/src/popover.js.map +1 -1
- package/src/progress.d.ts +18 -9
- package/src/progress.js +1 -1
- package/src/progress.js.map +1 -1
- package/src/qr-code.d.ts +12 -7
- package/src/qr-code.js +3 -3
- package/src/qr-code.js.map +1 -1
- package/src/radio-group.d.ts +17 -11
- package/src/radio-group.js +16 -19
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +13 -8
- package/src/resizable.js +3 -3
- package/src/resizable.js.map +1 -1
- package/src/runtime.d.ts +89 -15
- package/src/runtime.js +112 -19
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +26 -15
- package/src/scroll-area.js +9 -6
- package/src/scroll-area.js.map +1 -1
- package/src/select.d.ts +65 -45
- package/src/select.js +40 -35
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +4 -2
- package/src/separator.js +3 -3
- package/src/separator.js.map +1 -1
- package/src/slider.d.ts +35 -20
- package/src/slider.js +17 -18
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +10 -6
- package/src/switch.js +11 -9
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +22 -14
- package/src/tabs.js +5 -6
- package/src/tabs.js.map +1 -1
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +59 -23
- package/src/toast.js +59 -13
- package/src/toast.js.map +1 -1
- package/src/toggle-group.d.ts +5 -2
- package/src/toggle-group.js +3 -3
- package/src/toggle-group.js.map +1 -1
- package/src/toggle.d.ts +4 -2
- package/src/toggle.js +3 -3
- package/src/toggle.js.map +1 -1
- package/src/toolbar.d.ts +26 -11
- package/src/toolbar.js +23 -13
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +16 -10
- package/src/tooltip.js +1 -1
- package/src/tooltip.js.map +1 -1
- package/src/use-render.d.ts +38 -0
- package/src/use-render.js +50 -0
- package/src/use-render.js.map +1 -0
- package/src/value-bar.d.ts +19 -11
- package/src/value-bar.js +8 -5
- package/src/value-bar.js.map +1 -1
package/src/navigation-menu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
|
-
import { Portal as Portal$1, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { PartElement, Portal as Portal$1, parts, useController, useMount, useOptions, usePart, usePositioning, useSignal } from "./runtime.js";
|
|
3
3
|
import { defined, within } from "@kirana-ui/core";
|
|
4
|
-
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
import { createContext, useContext, useId, useMemo } from "react";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
|
|
@@ -34,18 +34,16 @@ function Root({ value, defaultValue, onValueChange, delay, closeDelay, orientati
|
|
|
34
34
|
children: usePart(controller.root, "nav", rest)
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
38
37
|
const List = (props) => usePart(useNavigation("List").list, "ul", props);
|
|
39
|
-
function Item({ value,
|
|
38
|
+
function Item({ value, ...props }) {
|
|
40
39
|
const controller = useNavigation("Item");
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
40
|
+
const generated = useId();
|
|
41
|
+
const key = value === void 0 ? generated : value;
|
|
42
|
+
const item = useMemo(() => controller.item(key), [controller, key]);
|
|
43
|
+
return usePart(controller.itemPart, "li", props, void 0, (content) => /* @__PURE__ */ jsx(Mounted, {
|
|
44
|
+
item,
|
|
45
|
+
children: content
|
|
46
|
+
}));
|
|
49
47
|
}
|
|
50
48
|
function Mounted({ item, children }) {
|
|
51
49
|
useMount(item);
|
|
@@ -63,7 +61,7 @@ function Content(props) {
|
|
|
63
61
|
const viewport = useSignal(useNavigation("Content").viewportElement);
|
|
64
62
|
if (!mounted || !viewport) return null;
|
|
65
63
|
return createPortal(/* @__PURE__ */ jsx(PartElement, {
|
|
66
|
-
|
|
64
|
+
of: item.content,
|
|
67
65
|
tag: "div",
|
|
68
66
|
...props
|
|
69
67
|
}), viewport);
|
|
@@ -80,22 +78,15 @@ function Link({ active, closeOnClick, ...props }) {
|
|
|
80
78
|
function Portal({ children }) {
|
|
81
79
|
return useSignal(useNavigation("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
|
|
82
80
|
}
|
|
83
|
-
function Positioner(
|
|
81
|
+
function Positioner(props) {
|
|
84
82
|
const controller = useNavigation("Positioner");
|
|
85
|
-
controller.positioning
|
|
86
|
-
side,
|
|
87
|
-
align,
|
|
88
|
-
sideOffset,
|
|
89
|
-
alignOffset,
|
|
90
|
-
collisionPadding
|
|
91
|
-
}));
|
|
92
|
-
return usePart(controller.positioner, "div", props);
|
|
83
|
+
return usePart(controller.positioner, "div", usePositioning(controller.positioning, props));
|
|
93
84
|
}
|
|
94
85
|
const Popup = (props) => usePart(useNavigation("Popup").popup, "div", props);
|
|
95
86
|
const Viewport = (props) => usePart(useNavigation("Viewport").viewport, "div", props);
|
|
96
87
|
const Arrow = (props) => usePart(useNavigation("Arrow").arrow, "div", props);
|
|
97
88
|
const Backdrop = (props) => usePart(useNavigation("Backdrop").backdrop, "div", props);
|
|
98
|
-
const NavigationMenu = {
|
|
89
|
+
const NavigationMenu = /* @__PURE__ */ parts("NavigationMenu", {
|
|
99
90
|
Root,
|
|
100
91
|
List,
|
|
101
92
|
Item,
|
|
@@ -109,7 +100,7 @@ const NavigationMenu = {
|
|
|
109
100
|
Viewport,
|
|
110
101
|
Arrow,
|
|
111
102
|
Backdrop
|
|
112
|
-
};
|
|
103
|
+
});
|
|
113
104
|
export { NavigationMenu };
|
|
114
105
|
|
|
115
106
|
//# sourceMappingURL=navigation-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-menu.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/navigation-menu.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type {
|
|
1
|
+
{"version":3,"file":"navigation-menu.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/navigation-menu.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu as Controller,\n NavigationMenuItem,\n NavigationMenuLinkOptions,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\nimport { createPortal } from \"react-dom\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport {\n Portal as BodyPortal,\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n usePositioning,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps, PortalProps, PositionerOptions } from \"./runtime.tsx\"\n\nexport type { PortalProps }\n\ntype Parts = Vocabulary[\"navigationMenu\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<NavigationMenuItem | null>(null)\n\nfunction useNavigation(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<NavigationMenu.${part}> must be inside <NavigationMenu.Root>`)\n return controller\n}\n\nfunction useItem(part: string): NavigationMenuItem {\n const item = useContext(ItemContext)\n if (!item) throw new Error(`<NavigationMenu.${part}> must be inside <NavigationMenu.Item>`)\n return item\n}\n\n/** `Value` is what tells an item from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"nav\",\n StateOf<Parts[\"root\"]>,\n Omit<NavigationMenuProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n delay,\n closeDelay,\n orientation,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller: Controller = useController<NavigationMenuProps<Value>, Controller<Value>>(\n within(createNavigationMenu<Value>, { direction }),\n { value, defaultValue, onValueChange, delay, closeDelay, orientation, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"nav\", rest)}</Context.Provider>\n )\n}\n\nexport type ListProps = PartComponentProps<\"ul\", StateOf<Parts[\"list\"]>>\n\nconst List = (props: ListProps) => usePart(useNavigation(\"List\").list, \"ul\", props)\n\nexport type ItemProps = PartComponentProps<\n \"li\",\n StateOf<Parts[\"item\"]>,\n {\n /**\n * What tells this item from the others: the menu's `value` while its content is shown. An\n * item that is given none makes its own.\n */\n value?: unknown\n }\n>\n\nfunction Item({ value, ...props }: ItemProps): ReactElement {\n const controller = useNavigation(\"Item\")\n // The same on every render of this item, a second one in StrictMode included.\n const generated = useId()\n const key = value === undefined ? generated : value\n const item = useMemo(() => controller.item(key), [controller, key])\n // Its trigger and content find the item, whatever element the caller asked for.\n return usePart(controller.itemPart, \"li\", props, undefined, (content) => (\n <Mounted item={item}>{content}</Mounted>\n ))\n}\n\nfunction Mounted({ item, children }: { item: NavigationMenuItem; children?: ReactNode }) {\n useMount(item)\n return <ItemContext.Provider value={item}>{children}</ItemContext.Provider>\n}\n\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\nexport type IconProps = PartComponentProps<\"span\", StateOf<Parts[\"icon\"]>>\n\nconst Trigger = (props: TriggerProps) => usePart(useItem(\"Trigger\").trigger, \"button\", props)\nconst Icon = (props: IconProps) => usePart(useItem(\"Icon\").icon, \"span\", props)\n\nexport type ContentProps = PartComponentProps<\"div\", StateOf<Parts[\"content\"]>>\n\n/** An item's content: drawn in `<NavigationMenu.Viewport>`, while it is shown. */\nfunction Content(props: ContentProps): ReactElement | null {\n const item = useItem(\"Content\")\n const mounted = useSignal(item.mounted)\n const viewport = useSignal(useNavigation(\"Content\").viewportElement)\n if (!mounted || !viewport) return null\n return createPortal(<PartElement of={item.content} tag=\"div\" {...props} />, viewport)\n}\n\nexport type LinkProps = PartComponentProps<\"a\", StateOf<Parts[\"link\"]>, NavigationMenuLinkOptions>\n\nfunction Link({ active, closeOnClick, ...props }: LinkProps): ReactElement {\n const controller = useNavigation(\"Link\")\n const options = useOptions({ active, closeOnClick })\n const part = useMemo(() => controller.link(() => defined(options.get())), [controller, options])\n return usePart(part, \"a\", props)\n}\n\nfunction Portal({ children }: PortalProps): ReactElement | null {\n const mounted = useSignal(useNavigation(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"positioner\"]>,\n PositionerOptions\n>\n\nfunction Positioner(props: PositionerProps): ReactElement {\n const controller = useNavigation(\"Positioner\")\n return usePart(controller.positioner, \"div\", usePositioning(controller.positioning, props))\n}\n\nexport type PopupProps = PartComponentProps<\"div\", StateOf<Parts[\"popup\"]>>\nexport type ViewportProps = PartComponentProps<\"div\", StateOf<Parts[\"viewport\"]>>\nexport type ArrowProps = PartComponentProps<\"div\", StateOf<Parts[\"arrow\"]>>\nexport type BackdropProps = PartComponentProps<\"div\", StateOf<Parts[\"backdrop\"]>>\n\nconst Popup = (props: PopupProps) => usePart(useNavigation(\"Popup\").popup, \"div\", props)\nconst Viewport = (props: ViewportProps) => usePart(useNavigation(\"Viewport\").viewport, \"div\", props)\nconst Arrow = (props: ArrowProps) => usePart(useNavigation(\"Arrow\").arrow, \"div\", props)\nconst Backdrop = (props: BackdropProps) => usePart(useNavigation(\"Backdrop\").backdrop, \"div\", props)\n\nexport const NavigationMenu = /* @__PURE__ */ parts(\"NavigationMenu\", {\n Root,\n List,\n Item,\n Trigger,\n Icon,\n Content,\n Link,\n Portal,\n Positioner,\n Popup,\n Viewport,\n Arrow,\n Backdrop,\n})\n"],"mappings":"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"}
|
package/src/number-field.d.ts
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { NumberFieldProps } from "@kirana-ui/core/number-field";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["numberField"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<NumberFieldProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function Root({ value, defaultValue, onValueChange, onValueCommitted, min, max, step, smallStep, largeStep, snapOnStep, allowWheelScrub, format, locale, disabled, readOnly, required, name, form, id,
|
|
8
|
-
|
|
9
|
+
}>;
|
|
10
|
+
declare function Root({ value, defaultValue, onValueChange, onValueCommitted, min, max, step, smallStep, largeStep, snapOnStep, allowWheelScrub, format, locale, disabled, readOnly, required, name, form, id, ...rest }: RootProps): ReactElement;
|
|
11
|
+
export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>>;
|
|
12
|
+
declare const Group: (props: GroupProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
|
|
9
14
|
/** The text input. Its text is the field's own. */
|
|
10
|
-
declare const Input: (props:
|
|
11
|
-
|
|
12
|
-
declare const
|
|
15
|
+
declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
export type IncrementProps = PartComponentProps<"button", StateOf<Parts["increment"]>>;
|
|
17
|
+
declare const Increment: (props: IncrementProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
18
|
+
export type DecrementProps = PartComponentProps<"button", StateOf<Parts["decrement"]>>;
|
|
19
|
+
declare const Decrement: (props: DecrementProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
20
|
export declare const NumberField: {
|
|
14
|
-
Root: typeof Root;
|
|
15
|
-
Group: typeof Group;
|
|
16
|
-
Input: typeof Input;
|
|
17
|
-
Increment: typeof Increment;
|
|
18
|
-
Decrement: typeof Decrement;
|
|
21
|
+
readonly Root: typeof Root;
|
|
22
|
+
readonly Group: typeof Group;
|
|
23
|
+
readonly Input: typeof Input;
|
|
24
|
+
readonly Increment: typeof Increment;
|
|
25
|
+
readonly Decrement: typeof Decrement;
|
|
19
26
|
};
|
|
20
27
|
export {};
|
|
21
28
|
//# sourceMappingURL=number-field.d.ts.map
|
package/src/number-field.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FieldContext } from "./field-context.js";
|
|
2
|
-
import { useController, useOwnText, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { parts, useController, useOwnText, usePart, useSignal } from "./runtime.js";
|
|
3
3
|
import { within } from "@kirana-ui/core";
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { createNumberField } from "@kirana-ui/core/number-field";
|
|
7
7
|
// src/number-field.tsx
|
|
8
8
|
const Context = createContext(null);
|
|
@@ -11,7 +11,7 @@ function useNumberField(part) {
|
|
|
11
11
|
if (!controller) throw new Error(`<NumberField.${part}> must be inside <NumberField.Root>`);
|
|
12
12
|
return controller;
|
|
13
13
|
}
|
|
14
|
-
function Root({ value, defaultValue, onValueChange, onValueCommitted, min, max, step, smallStep, largeStep, snapOnStep, allowWheelScrub, format, locale, disabled, readOnly, required, name, form, id,
|
|
14
|
+
function Root({ value, defaultValue, onValueChange, onValueCommitted, min, max, step, smallStep, largeStep, snapOnStep, allowWheelScrub, format, locale, disabled, readOnly, required, name, form, id, ...rest }) {
|
|
15
15
|
const field = useContext(FieldContext) ?? void 0;
|
|
16
16
|
const controller = useController(within(createNumberField, { field }), {
|
|
17
17
|
value,
|
|
@@ -37,26 +37,22 @@ function Root({ value, defaultValue, onValueChange, onValueCommitted, min, max,
|
|
|
37
37
|
const named = useSignal(controller.named);
|
|
38
38
|
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
39
39
|
value: controller,
|
|
40
|
-
children: /* @__PURE__ */ jsxs(
|
|
41
|
-
...rest,
|
|
42
|
-
children: [children, named ? /* @__PURE__ */ jsx(HiddenInput, {}) : null]
|
|
43
|
-
})
|
|
40
|
+
children: usePart(controller.root, "div", rest, void 0, (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, named ? /* @__PURE__ */ jsx(HiddenInput, {}) : null] }))
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
|
-
const RootElement = (props) => usePart(useNumberField("Root").root, "div", props);
|
|
47
43
|
const HiddenInput = () => usePart(useNumberField("Root").hidden, "input", {});
|
|
48
44
|
const Group = (props) => usePart(useNumberField("Group").group, "div", props);
|
|
49
45
|
/** The text input. Its text is the field's own. */
|
|
50
46
|
const Input = (props) => usePart(useOwnText(useNumberField("Input").input), "input", props);
|
|
51
47
|
const Increment = (props) => usePart(useNumberField("Increment").increment, "button", props);
|
|
52
48
|
const Decrement = (props) => usePart(useNumberField("Decrement").decrement, "button", props);
|
|
53
|
-
const NumberField = {
|
|
49
|
+
const NumberField = /* @__PURE__ */ parts("NumberField", {
|
|
54
50
|
Root,
|
|
55
51
|
Group,
|
|
56
52
|
Input,
|
|
57
53
|
Increment,
|
|
58
54
|
Decrement
|
|
59
|
-
};
|
|
55
|
+
});
|
|
60
56
|
export { NumberField };
|
|
61
57
|
|
|
62
58
|
//# sourceMappingURL=number-field.js.map
|
package/src/number-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field.js","names":[],"sources":["../../../../packages/react/src/number-field.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createNumberField } from \"@kirana-ui/core/number-field\"\nimport type { NumberField as Controller, NumberFieldProps } from \"@kirana-ui/core/number-field\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { useController, useOwnText, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useNumberField(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<NumberField.${part}> must be inside <NumberField.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<NumberFieldProps, \"id\"> & { id?: string }
|
|
1
|
+
{"version":3,"file":"number-field.js","names":[],"sources":["../../../../packages/react/src/number-field.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createNumberField } from \"@kirana-ui/core/number-field\"\nimport type { NumberField as Controller, NumberFieldProps } from \"@kirana-ui/core/number-field\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { parts, useController, useOwnText, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"numberField\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useNumberField(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<NumberField.${part}> must be inside <NumberField.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<NumberFieldProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n onValueCommitted,\n min,\n max,\n step,\n smallStep,\n largeStep,\n snapOnStep,\n allowWheelScrub,\n format,\n locale,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<NumberFieldProps, Controller>(\n within(createNumberField, { field }),\n {\n value,\n defaultValue,\n onValueChange,\n onValueCommitted,\n min,\n max,\n step,\n smallStep,\n largeStep,\n snapOnStep,\n allowWheelScrub,\n format,\n locale,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n }\n )\n const named = useSignal(controller.named)\n return (\n <Context.Provider value={controller}>\n {usePart(controller.root, \"div\", rest, undefined, (content) => (\n // Its hidden input is in the element, whatever element the caller asked for.\n <>\n {content}\n {named ? <HiddenInput /> : null}\n </>\n ))}\n </Context.Provider>\n )\n}\n\nconst HiddenInput = () => usePart(useNumberField(\"Root\").hidden, \"input\", {})\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>>\n\nconst Group = (props: GroupProps) => usePart(useNumberField(\"Group\").group, \"div\", props)\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\n/** The text input. Its text is the field's own. */\nconst Input = (props: InputProps) =>\n usePart(useOwnText(useNumberField(\"Input\").input), \"input\", props)\nexport type IncrementProps = PartComponentProps<\"button\", StateOf<Parts[\"increment\"]>>\n\nconst Increment = (props: IncrementProps) =>\n usePart(useNumberField(\"Increment\").increment, \"button\", props)\nexport type DecrementProps = PartComponentProps<\"button\", StateOf<Parts[\"decrement\"]>>\n\nconst Decrement = (props: DecrementProps) =>\n usePart(useNumberField(\"Decrement\").decrement, \"button\", props)\n\nexport const NumberField = /* @__PURE__ */ parts(\"NumberField\", {\n Root,\n Group,\n Input,\n Increment,\n Decrement,\n})\n"],"mappings":";;;;;;;AAcA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,eAAe,MAA0B;CAChD,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,gBAAgB,KAAK,oCAAoC;CAC1F,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,kBACA,KACA,KACA,MACA,WACA,WACA,YACA,iBACA,QACA,QACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cACjB,OAAO,mBAAmB,EAAE,MAAM,CAAC,GACnC;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,QAAQ,UAAU,WAAW,KAAK;CACxC,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACtB,UAAA,QAAQ,WAAW,MAAM,OAAO,MAAM,KAAA,IAAY,YAEjD,qBAAA,YAAA,EAAA,UAAA,CACG,SACA,QAAQ,oBAAC,aAAD,CAAc,CAAA,IAAI,IAC3B,EAAA,CAAA,CACH;CACe,CAAA;AAEtB;AAEA,MAAM,oBAAoB,QAAQ,eAAe,MAAM,CAAC,CAAC,QAAQ,SAAS,CAAC,CAAC;AAG5E,MAAM,SAAS,UAAsB,QAAQ,eAAe,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;;AAIxF,MAAM,SAAS,UACb,QAAQ,WAAW,eAAe,OAAO,CAAC,CAAC,KAAK,GAAG,SAAS,KAAK;AAGnE,MAAM,aAAa,UACjB,QAAQ,eAAe,WAAW,CAAC,CAAC,WAAW,UAAU,KAAK;AAGhE,MAAM,aAAa,UACjB,QAAQ,eAAe,WAAW,CAAC,CAAC,WAAW,UAAU,KAAK;AAEhE,MAAa,cAA8B,sBAAM,eAAe;CAC9D;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/otp.d.ts
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { OtpProps } from "@kirana-ui/core/otp";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["otp"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<OtpProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
9
|
+
}>;
|
|
7
10
|
declare function Root({ length, value, defaultValue, onValueChange, onComplete, mode, disabled, name, form, id, ...rest }: RootProps): ReactElement;
|
|
8
|
-
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
|
|
12
|
+
declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>>;
|
|
14
|
+
declare const Group: (props: GroupProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
15
|
+
export type SeparatorProps = PartComponentProps<"div", StateOf<Parts["separator"]>>;
|
|
16
|
+
declare const Separator: (props: SeparatorProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
17
|
+
export type SlotProps = PartComponentProps<"div", StateOf<Parts["slot"]>, {
|
|
18
|
+
/** Which character of the code it shows, from 0. */
|
|
13
19
|
index: number;
|
|
14
|
-
}
|
|
20
|
+
}>;
|
|
21
|
+
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
22
|
+
declare function Slot({ index, ...props }: SlotProps): ReactElement;
|
|
23
|
+
export type CaretProps = PartComponentProps<"div", StateOf<Parts["caret"]>>;
|
|
15
24
|
/** Drawn in its cell while the cell is the active one and empty. */
|
|
16
|
-
declare function Caret(props:
|
|
25
|
+
declare function Caret(props: CaretProps): ReactElement | null;
|
|
17
26
|
export declare const Otp: {
|
|
18
|
-
Root: typeof Root;
|
|
19
|
-
Input: typeof Input;
|
|
20
|
-
Group: typeof Group;
|
|
21
|
-
Slot: typeof Slot;
|
|
22
|
-
Separator: typeof Separator;
|
|
23
|
-
Caret: typeof Caret;
|
|
27
|
+
readonly Root: typeof Root;
|
|
28
|
+
readonly Input: typeof Input;
|
|
29
|
+
readonly Group: typeof Group;
|
|
30
|
+
readonly Slot: typeof Slot;
|
|
31
|
+
readonly Separator: typeof Separator;
|
|
32
|
+
readonly Caret: typeof Caret;
|
|
24
33
|
};
|
|
25
34
|
export {};
|
|
26
35
|
//# sourceMappingURL=otp.d.ts.map
|
package/src/otp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useController, usePart, useSignal } from "./runtime.js";
|
|
1
|
+
import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { createOtp } from "@kirana-ui/core/otp";
|
|
5
5
|
// src/otp.tsx
|
|
6
6
|
const Context = createContext(null);
|
|
@@ -28,22 +28,16 @@ function Root({ length, value, defaultValue, onValueChange, onComplete, mode, di
|
|
|
28
28
|
children: usePart(controller.root, "div", rest)
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
32
31
|
const Input = (props) => usePart(useOtp("Input").input, "input", props);
|
|
33
32
|
const Group = (props) => usePart(useOtp("Group").group, "div", props);
|
|
34
33
|
const Separator = (props) => usePart(useOtp("Separator").separator, "div", props);
|
|
35
34
|
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
36
|
-
function Slot({ index,
|
|
35
|
+
function Slot({ index, ...props }) {
|
|
37
36
|
const slot = useOtp("Slot").slot(index);
|
|
38
37
|
const char = useSignal(slot.char);
|
|
39
38
|
return /* @__PURE__ */ jsx(SlotContext.Provider, {
|
|
40
39
|
value: slot,
|
|
41
|
-
children: /* @__PURE__ */ jsxs(
|
|
42
|
-
part: slot.part,
|
|
43
|
-
tag: "div",
|
|
44
|
-
...props,
|
|
45
|
-
children: [char, children]
|
|
46
|
-
})
|
|
40
|
+
children: usePart(slot.part, "div", props, void 0, (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [char, content] }))
|
|
47
41
|
});
|
|
48
42
|
}
|
|
49
43
|
/** Drawn in its cell while the cell is the active one and empty. */
|
|
@@ -52,19 +46,19 @@ function Caret(props) {
|
|
|
52
46
|
const slot = useContext(SlotContext);
|
|
53
47
|
if (!slot) throw new Error("<Otp.Caret> must be inside <Otp.Slot>");
|
|
54
48
|
return useSignal(slot.caret) ? /* @__PURE__ */ jsx(PartElement, {
|
|
55
|
-
|
|
49
|
+
of: controller.caretPart,
|
|
56
50
|
tag: "div",
|
|
57
51
|
...props
|
|
58
52
|
}) : null;
|
|
59
53
|
}
|
|
60
|
-
const Otp = {
|
|
54
|
+
const Otp = /* @__PURE__ */ parts("Otp", {
|
|
61
55
|
Root,
|
|
62
56
|
Input,
|
|
63
57
|
Group,
|
|
64
58
|
Slot,
|
|
65
59
|
Separator,
|
|
66
60
|
Caret
|
|
67
|
-
};
|
|
61
|
+
});
|
|
68
62
|
export { Otp };
|
|
69
63
|
|
|
70
64
|
//# sourceMappingURL=otp.js.map
|
package/src/otp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/react/src/otp.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/react/src/otp.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp as Controller, OtpProps, OtpSlot } from \"@kirana-ui/core/otp\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"otp\"]\n\nconst Context = createContext<Controller | null>(null)\nconst SlotContext = createContext<OtpSlot | null>(null)\n\nfunction useOtp(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Otp.${part}> must be inside <Otp.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<OtpProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n length,\n value,\n defaultValue,\n onValueChange,\n onComplete,\n mode,\n disabled,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const controller = useController<OtpProps, Controller>(createOtp, {\n length,\n value,\n defaultValue,\n onValueChange,\n onComplete,\n mode,\n disabled,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\nconst Input = (props: InputProps) => usePart(useOtp(\"Input\").input, \"input\", props)\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>>\n\nconst Group = (props: GroupProps) => usePart(useOtp(\"Group\").group, \"div\", props)\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Separator = (props: SeparatorProps) => usePart(useOtp(\"Separator\").separator, \"div\", props)\n\nexport type SlotProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"slot\"]>,\n {\n /** Which character of the code it shows, from 0. */\n index: number\n }\n>\n\n/** One cell: it shows its character, then whatever it is given (a caret). */\nfunction Slot({ index, ...props }: SlotProps): ReactElement {\n const slot = useOtp(\"Slot\").slot(index)\n const char = useSignal(slot.char)\n return (\n <SlotContext.Provider value={slot}>\n {usePart(slot.part, \"div\", props, undefined, (content) => (\n // Its character comes first, whatever element the caller asked for.\n <>\n {char}\n {content}\n </>\n ))}\n </SlotContext.Provider>\n )\n}\n\nexport type CaretProps = PartComponentProps<\"div\", StateOf<Parts[\"caret\"]>>\n\n/** Drawn in its cell while the cell is the active one and empty. */\nfunction Caret(props: CaretProps): ReactElement | null {\n const controller = useOtp(\"Caret\")\n const slot = useContext(SlotContext)\n if (!slot) throw new Error(\"<Otp.Caret> must be inside <Otp.Slot>\")\n const shown = useSignal(slot.caret)\n return shown ? <PartElement of={controller.caretPart} tag=\"div\" {...props} /> : null\n}\n\nexport const Otp = /* @__PURE__ */ parts(\"Otp\", { Root, Input, Group, Slot, Separator, Caret })\n"],"mappings":";;;;;AAYA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAA8B,IAAI;AAEtD,SAAS,OAAO,MAA0B;CACxC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,QAAQ,KAAK,4BAA4B;CAC1E,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,QACA,OACA,cACA,eACA,YACA,MACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,aAAa,cAAoC,WAAW;EAChE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAIA,MAAM,SAAS,UAAsB,QAAQ,OAAO,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAGlF,MAAM,SAAS,UAAsB,QAAQ,OAAO,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAGhF,MAAM,aAAa,UAA0B,QAAQ,OAAO,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;;AAYhG,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,MAAM,OAAO,OAAO,MAAM,CAAC,CAAC,KAAK,KAAK;CACtC,MAAM,OAAO,UAAU,KAAK,IAAI;CAChC,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC1B,UAAA,QAAQ,KAAK,MAAM,OAAO,OAAO,KAAA,IAAY,YAE5C,qBAAA,YAAA,EAAA,UAAA,CACG,MACA,OACD,EAAA,CAAA,CACH;CACmB,CAAA;AAE1B;;AAKA,SAAS,MAAM,OAAwC;CACrD,MAAM,aAAa,OAAO,OAAO;CACjC,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,uCAAuC;CAElE,OADc,UAAU,KAAK,KAClB,IAAI,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAW,KAAI;EAAM,GAAI;CAAQ,CAAA,IAAI;AAClF;AAEA,MAAa,MAAsB,sBAAM,OAAO;CAAE;CAAM;CAAO;CAAO;CAAM;CAAW;AAAM,CAAC"}
|
package/src/pagination.d.ts
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement, ReactNode } from "react";
|
|
3
4
|
import { PaginationEntry, PaginationProps } from "@kirana-ui/core/pagination";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["pagination"];
|
|
7
|
+
export type RootProps = PartComponentProps<"nav", StateOf<Parts["root"]>, Omit<PaginationProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
9
|
+
}>;
|
|
7
10
|
declare function Root({ page, defaultPage, onPageChange, count, pageSize, siblingCount, boundaryCount, disabled, id, ...rest }: RootProps): ReactElement;
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
export interface ItemsProps {
|
|
12
|
+
/** Draws one entry, once for each: a page, or the mark for pages left out. */
|
|
10
13
|
children: (entry: PaginationEntry) => ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
14
|
+
}
|
|
15
|
+
/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */
|
|
16
|
+
declare function Items({ children }: ItemsProps): ReactElement;
|
|
17
|
+
export type ItemProps = PartComponentProps<"button", StateOf<Parts["item"]>, {
|
|
18
|
+
/** The page it goes to, from 1. */
|
|
13
19
|
page: number;
|
|
14
|
-
}
|
|
15
|
-
declare
|
|
16
|
-
|
|
17
|
-
declare const
|
|
20
|
+
}>;
|
|
21
|
+
declare function Item({ page, ...props }: ItemProps): ReactElement;
|
|
22
|
+
export type EllipsisProps = PartComponentProps<"span", StateOf<Parts["ellipsis"]>>;
|
|
23
|
+
declare const Ellipsis: (props: EllipsisProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
24
|
+
export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
|
|
25
|
+
declare const Previous: (props: PreviousProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
26
|
+
export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
27
|
+
declare const Next: (props: NextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
18
28
|
export declare const Pagination: {
|
|
19
|
-
Root: typeof Root;
|
|
20
|
-
Items: typeof Items;
|
|
21
|
-
Item: typeof Item;
|
|
22
|
-
Ellipsis: typeof Ellipsis;
|
|
23
|
-
Previous: typeof Previous;
|
|
24
|
-
Next: typeof Next;
|
|
29
|
+
readonly Root: typeof Root;
|
|
30
|
+
readonly Items: typeof Items;
|
|
31
|
+
readonly Item: typeof Item;
|
|
32
|
+
readonly Ellipsis: typeof Ellipsis;
|
|
33
|
+
readonly Previous: typeof Previous;
|
|
34
|
+
readonly Next: typeof Next;
|
|
25
35
|
};
|
|
26
36
|
export {};
|
|
27
37
|
//# sourceMappingURL=pagination.d.ts.map
|
package/src/pagination.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useController, usePart, useSignal } from "./runtime.js";
|
|
1
|
+
import { parts, useController, usePart, useSignal } from "./runtime.js";
|
|
2
2
|
import { Fragment, createContext, useContext } from "react";
|
|
3
3
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createPagination } from "@kirana-ui/core/pagination";
|
|
@@ -37,14 +37,14 @@ function Item({ page, ...props }) {
|
|
|
37
37
|
const Ellipsis = (props) => usePart(usePagination("Ellipsis").ellipsis, "span", props);
|
|
38
38
|
const Previous = (props) => usePart(usePagination("Previous").previous, "button", props);
|
|
39
39
|
const Next = (props) => usePart(usePagination("Next").next, "button", props);
|
|
40
|
-
const Pagination = {
|
|
40
|
+
const Pagination = /* @__PURE__ */ parts("Pagination", {
|
|
41
41
|
Root,
|
|
42
42
|
Items,
|
|
43
43
|
Item,
|
|
44
44
|
Ellipsis,
|
|
45
45
|
Previous,
|
|
46
46
|
Next
|
|
47
|
-
};
|
|
47
|
+
});
|
|
48
48
|
export { Pagination };
|
|
49
49
|
|
|
50
50
|
//# sourceMappingURL=pagination.js.map
|
package/src/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/react/src/pagination.tsx"],"sourcesContent":["import { createPagination } from \"@kirana-ui/core/pagination\"\nimport type {\n Pagination as Controller,\n PaginationEntry,\n PaginationProps,\n} from \"@kirana-ui/core/pagination\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction usePagination(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Pagination.${part}> must be inside <Pagination.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PaginationProps, \"id\"> & { id?: string }
|
|
1
|
+
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/react/src/pagination.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createPagination } from \"@kirana-ui/core/pagination\"\nimport type {\n Pagination as Controller,\n PaginationEntry,\n PaginationProps,\n} from \"@kirana-ui/core/pagination\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"pagination\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction usePagination(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Pagination.${part}> must be inside <Pagination.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"nav\",\n StateOf<Parts[\"root\"]>,\n Omit<PaginationProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n page,\n defaultPage,\n onPageChange,\n count,\n pageSize,\n siblingCount,\n boundaryCount,\n disabled,\n id,\n ...rest\n}: RootProps): ReactElement {\n const controller = useController<PaginationProps, Controller>(createPagination, {\n page,\n defaultPage,\n onPageChange,\n count,\n pageSize,\n siblingCount,\n boundaryCount,\n disabled,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"nav\", rest)}</Context.Provider>\n )\n}\n\nexport interface ItemsProps {\n /** Draws one entry, once for each: a page, or the mark for pages left out. */\n children: (entry: PaginationEntry) => ReactNode\n}\n\n/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */\nfunction Items({ children }: ItemsProps): ReactElement {\n const entries = useSignal(usePagination(\"Items\").entries)\n return (\n <>\n {entries.map((entry) => (\n <Fragment key={entry.key}>{children(entry)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"item\"]>,\n {\n /** The page it goes to, from 1. */\n page: number\n }\n>\n\nfunction Item({ page, ...props }: ItemProps): ReactElement {\n return usePart(usePagination(\"Item\").item(page), \"button\", props)\n}\n\nexport type EllipsisProps = PartComponentProps<\"span\", StateOf<Parts[\"ellipsis\"]>>\n\nconst Ellipsis = (props: EllipsisProps) =>\n usePart(usePagination(\"Ellipsis\").ellipsis, \"span\", props)\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(usePagination(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(usePagination(\"Next\").next, \"button\", props)\n\nexport const Pagination = /* @__PURE__ */ parts(\"Pagination\", {\n Root,\n Items,\n Item,\n Ellipsis,\n Previous,\n Next,\n})\n"],"mappings":";;;;;AAgBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,MACA,aACA,cACA,OACA,UACA,cACA,eACA,UACA,IACA,GAAG,QACuB;CAC1B,MAAM,aAAa,cAA2C,kBAAkB;EAC9E;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;;AAQA,SAAS,MAAM,EAAE,YAAsC;CACrD,MAAM,UAAU,UAAU,cAAc,OAAO,CAAC,CAAC,OAAO;CACxD,OACE,oBAAA,YAAA,EAAA,UACG,QAAQ,KAAK,UACZ,oBAAC,UAAD,EAAA,UAA2B,SAAS,KAAK,EAAY,GAAtC,MAAM,GAAgC,CACtD,EACD,CAAA;AAEN;AAWA,SAAS,KAAK,EAAE,MAAM,GAAG,SAAkC;CACzD,OAAO,QAAQ,cAAc,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,UAAU,KAAK;AAClE;AAIA,MAAM,YAAY,UAChB,QAAQ,cAAc,UAAU,CAAC,CAAC,UAAU,QAAQ,KAAK;AAG3D,MAAM,YAAY,UAChB,QAAQ,cAAc,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAG7D,MAAM,QAAQ,UAAqB,QAAQ,cAAc,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAEtF,MAAa,aAA6B,sBAAM,cAAc;CAC5D;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/popover.d.ts
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import {
|
|
1
|
+
import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
3
3
|
import { ReactElement, ReactNode } from "react";
|
|
4
4
|
import { Popover as Popover$1, PopoverProps } from "@kirana-ui/core/popover";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["popover"];
|
|
7
|
+
/**
|
|
8
|
+
* The popover its parts are inside. Exported for a component that is made of one (a date picker
|
|
9
|
+
* provides its own to the popover's parts).
|
|
10
|
+
*/
|
|
5
11
|
declare const Context: import("react").Context<Popover$1 | null>;
|
|
6
12
|
export type RootProps = Omit<PopoverProps, "id"> & {
|
|
7
13
|
id?: string;
|
|
8
14
|
children?: ReactNode;
|
|
9
15
|
};
|
|
10
16
|
declare function Root({ children, ...props }: RootProps): ReactElement;
|
|
11
|
-
declare function Portal({ children }:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
declare const
|
|
20
|
-
declare const
|
|
17
|
+
declare function Portal({ children }: PortalProps): ReactElement | null;
|
|
18
|
+
export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
|
|
19
|
+
declare function Positioner(props: PositionerProps): ReactElement;
|
|
20
|
+
export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>>;
|
|
21
|
+
export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
|
|
22
|
+
export type TitleProps = PartComponentProps<"h2", StateOf<Parts["title"]>>;
|
|
23
|
+
export type DescriptionProps = PartComponentProps<"p", StateOf<Parts["description"]>>;
|
|
24
|
+
export type CloseProps = PartComponentProps<"button", StateOf<Parts["close"]>>;
|
|
25
|
+
declare const Trigger: (props: TriggerProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
26
|
+
declare const Popup: (props: PopupProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
27
|
+
declare const Title: (props: TitleProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
28
|
+
declare const Description: (props: DescriptionProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
29
|
+
declare const Close: (props: CloseProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
21
30
|
export declare const Popover: {
|
|
22
|
-
Root: typeof Root;
|
|
23
|
-
Trigger: typeof Trigger;
|
|
24
|
-
Portal: typeof Portal;
|
|
25
|
-
Positioner: typeof Positioner;
|
|
26
|
-
Popup: typeof Popup;
|
|
27
|
-
Title: typeof Title;
|
|
28
|
-
Description: typeof Description;
|
|
29
|
-
Close: typeof Close;
|
|
31
|
+
readonly Root: typeof Root;
|
|
32
|
+
readonly Trigger: typeof Trigger;
|
|
33
|
+
readonly Portal: typeof Portal;
|
|
34
|
+
readonly Positioner: typeof Positioner;
|
|
35
|
+
readonly Popup: typeof Popup;
|
|
36
|
+
readonly Title: typeof Title;
|
|
37
|
+
readonly Description: typeof Description;
|
|
38
|
+
readonly Close: typeof Close;
|
|
30
39
|
};
|
|
31
|
-
export { Context as PopoverContext };
|
|
40
|
+
export { Context as PopoverContext, type PortalProps };
|
|
32
41
|
//# sourceMappingURL=popover.d.ts.map
|
package/src/popover.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Portal as Portal$1, useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
-
import { defined } from "@kirana-ui/core";
|
|
1
|
+
import { Portal as Portal$1, parts, useController, usePart, usePositioning, useSignal } from "./runtime.js";
|
|
3
2
|
import { createContext, useContext } from "react";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { createPopover } from "@kirana-ui/core/popover";
|
|
6
5
|
// src/popover.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The popover its parts are inside. Exported for a component that is made of one (a date picker
|
|
8
|
+
* provides its own to the popover's parts).
|
|
9
|
+
*/
|
|
7
10
|
const Context = createContext(null);
|
|
8
11
|
function usePopover(part) {
|
|
9
12
|
const controller = useContext(Context);
|
|
@@ -20,23 +23,16 @@ function Root({ children, ...props }) {
|
|
|
20
23
|
function Portal({ children }) {
|
|
21
24
|
return useSignal(usePopover("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
|
|
22
25
|
}
|
|
23
|
-
function Positioner(
|
|
26
|
+
function Positioner(props) {
|
|
24
27
|
const controller = usePopover("Positioner");
|
|
25
|
-
controller.positioning
|
|
26
|
-
side,
|
|
27
|
-
align,
|
|
28
|
-
sideOffset,
|
|
29
|
-
alignOffset,
|
|
30
|
-
collisionPadding
|
|
31
|
-
}));
|
|
32
|
-
return usePart(controller.positioner, "div", props);
|
|
28
|
+
return usePart(controller.positioner, "div", usePositioning(controller.positioning, props));
|
|
33
29
|
}
|
|
34
30
|
const Trigger = (props) => usePart(usePopover("Trigger").trigger, "button", props);
|
|
35
31
|
const Popup = (props) => usePart(usePopover("Popup").popup, "div", props);
|
|
36
32
|
const Title = (props) => usePart(usePopover("Title").title, "h2", props);
|
|
37
33
|
const Description = (props) => usePart(usePopover("Description").description, "p", props);
|
|
38
34
|
const Close = (props) => usePart(usePopover("Close").close, "button", props);
|
|
39
|
-
const Popover = {
|
|
35
|
+
const Popover = /* @__PURE__ */ parts("Popover", {
|
|
40
36
|
Root,
|
|
41
37
|
Trigger,
|
|
42
38
|
Portal,
|
|
@@ -45,7 +41,7 @@ const Popover = {
|
|
|
45
41
|
Title,
|
|
46
42
|
Description,
|
|
47
43
|
Close
|
|
48
|
-
};
|
|
44
|
+
});
|
|
49
45
|
export { Popover, Context as PopoverContext };
|
|
50
46
|
|
|
51
47
|
//# sourceMappingURL=popover.js.map
|