@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/popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller, PopoverProps } from \"@kirana-ui/core/popover\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport {\n Portal as BodyPortal,\n parts,\n useController,\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[\"popover\"]\n\n/**\n * The popover its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the popover's parts).\n */\nconst Context = createContext<Controller | null>(null)\n/** For a component made of this one's parts: a date picker. */\nexport { Context as PopoverContext }\n\nfunction usePopover(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Popover.${part}> must be inside <Popover.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PopoverProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(createPopover, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: PortalProps): ReactElement | null {\n const mounted = useSignal(usePopover(\"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 = usePopover(\"Positioner\")\n return usePart(controller.positioner, \"div\", usePositioning(controller.positioning, props))\n}\n\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\nexport type PopupProps = PartComponentProps<\"div\", StateOf<Parts[\"popup\"]>>\nexport type TitleProps = PartComponentProps<\"h2\", StateOf<Parts[\"title\"]>>\nexport type DescriptionProps = PartComponentProps<\"p\", StateOf<Parts[\"description\"]>>\nexport type CloseProps = PartComponentProps<\"button\", StateOf<Parts[\"close\"]>>\n\nconst Trigger = (props: TriggerProps) => usePart(usePopover(\"Trigger\").trigger, \"button\", props)\nconst Popup = (props: PopupProps) => usePart(usePopover(\"Popup\").popup, \"div\", props)\nconst Title = (props: TitleProps) => usePart(usePopover(\"Title\").title, \"h2\", props)\nconst Description = (props: DescriptionProps) =>\n usePart(usePopover(\"Description\").description, \"p\", props)\nconst Close = (props: CloseProps) => usePart(usePopover(\"Close\").close, \"button\", props)\n\nexport const Popover = /* @__PURE__ */ parts(\"Popover\", {\n Root,\n Trigger,\n Portal,\n Positioner,\n Popup,\n Title,\n Description,\n Close,\n})\n"],"mappings":";;;;;;;;;AAyBA,MAAM,UAAU,cAAiC,IAAI;AAIrD,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;CAC7D,MAAM,aAAa,cAAc,eAAe,KAAK;CACrD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;AAEA,SAAS,OAAO,EAAE,YAA8C;CAE9D,OADgB,UAAU,WAAW,QAAQ,CAAC,CAAC,OAClC,IAAI,oBAACA,UAAD,EAAa,SAAqB,CAAA,IAAI;AACzD;AAQA,SAAS,WAAW,OAAsC;CACxD,MAAM,aAAa,WAAW,YAAY;CAC1C,OAAO,QAAQ,WAAW,YAAY,OAAO,eAAe,WAAW,aAAa,KAAK,CAAC;AAC5F;AAQA,MAAM,WAAW,UAAwB,QAAQ,WAAW,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AAC/F,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AACpF,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK;AACnF,MAAM,eAAe,UACnB,QAAQ,WAAW,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AAC3D,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAEvF,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/progress.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ValueOptions } from "./value-bar.js";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
|
+
import { ProgressProps } from "@kirana-ui/core/progress";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["progress"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<ProgressProps, "id"> & {
|
|
8
|
+
id?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type TrackProps = PartComponentProps<"div", StateOf<Parts["track"]>>;
|
|
11
|
+
export type IndicatorProps = PartComponentProps<"div", StateOf<Parts["indicator"]>>;
|
|
12
|
+
export type ValueProps = PartComponentProps<"span", StateOf<Parts["value"]>, ValueOptions>;
|
|
13
|
+
export type LabelProps = PartComponentProps<"span", StateOf<Parts["label"]>>;
|
|
2
14
|
export declare const Progress: {
|
|
3
|
-
Root: (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Value: ({ children, ...props }: Omit<PartComponentProps<undefined>, "children"> & {
|
|
9
|
-
children?: ((text: string | undefined) => import("react").ReactNode) | undefined;
|
|
10
|
-
}) => import("react").ReactElement;
|
|
11
|
-
Label: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
15
|
+
Root: (props: RootProps) => import("react").ReactElement;
|
|
16
|
+
Track: (props: TrackProps) => import("react").ReactElement;
|
|
17
|
+
Indicator: (props: IndicatorProps) => import("react").ReactElement;
|
|
18
|
+
Value: (props: ValueProps) => import("react").ReactElement;
|
|
19
|
+
Label: (props: LabelProps) => import("react").ReactElement;
|
|
12
20
|
};
|
|
21
|
+
export {};
|
|
13
22
|
//# sourceMappingURL=progress.d.ts.map
|
package/src/progress.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { valueBar } from "./value-bar.js";
|
|
2
2
|
import { createProgress } from "@kirana-ui/core/progress";
|
|
3
3
|
// src/progress.tsx
|
|
4
|
-
const Progress = valueBar("Progress", createProgress);
|
|
4
|
+
const Progress = /* @__PURE__ */ valueBar("Progress", createProgress);
|
|
5
5
|
export { Progress };
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=progress.js.map
|
package/src/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/react/src/progress.tsx"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { valueBar } from \"./value-bar.tsx\"\n\nexport const Progress = valueBar(\"Progress\", createProgress)\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/react/src/progress.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createProgress } from \"@kirana-ui/core/progress\"\nimport type { ProgressProps } from \"@kirana-ui/core/progress\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\n\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { valueBar } from \"./value-bar.tsx\"\nimport type { ValueOptions } from \"./value-bar.tsx\"\n\ntype Parts = Vocabulary[\"progress\"]\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<ProgressProps, \"id\"> & { id?: string }\n>\nexport type TrackProps = PartComponentProps<\"div\", StateOf<Parts[\"track\"]>>\nexport type IndicatorProps = PartComponentProps<\"div\", StateOf<Parts[\"indicator\"]>>\nexport type ValueProps = PartComponentProps<\"span\", StateOf<Parts[\"value\"]>, ValueOptions>\nexport type LabelProps = PartComponentProps<\"span\", StateOf<Parts[\"label\"]>>\n\nexport const Progress = /* @__PURE__ */ valueBar<\n ProgressProps,\n {\n Root: RootProps\n Track: TrackProps\n Indicator: IndicatorProps\n Value: ValueProps\n Label: LabelProps\n }\n>(\"Progress\", createProgress)\n"],"mappings":";;;AAqBA,MAAa,WAA2B,yBAStC,YAAY,cAAc"}
|
package/src/qr-code.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["qrCode"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<QrCodeProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
9
|
+
}>;
|
|
7
10
|
declare function Root({ value, correction, id, ...rest }: RootProps): ReactElement;
|
|
8
|
-
|
|
9
|
-
declare const
|
|
11
|
+
export type FrameProps = PartComponentProps<"svg", StateOf<Parts["frame"]>>;
|
|
12
|
+
declare const Frame: (props: FrameProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export type PatternProps = PartComponentProps<"path", StateOf<Parts["pattern"]>>;
|
|
14
|
+
declare const Pattern: (props: PatternProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
15
|
export declare const QrCode: {
|
|
11
|
-
Root: typeof Root;
|
|
12
|
-
Frame: typeof Frame;
|
|
13
|
-
Pattern: typeof Pattern;
|
|
16
|
+
readonly Root: typeof Root;
|
|
17
|
+
readonly Frame: typeof Frame;
|
|
18
|
+
readonly Pattern: typeof Pattern;
|
|
14
19
|
};
|
|
15
20
|
export {};
|
|
16
21
|
//# sourceMappingURL=qr-code.d.ts.map
|
package/src/qr-code.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useController, usePart } from "./runtime.js";
|
|
1
|
+
import { parts, useController, usePart } from "./runtime.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createQrCode } from "@kirana-ui/core/qr-code";
|
|
@@ -22,11 +22,11 @@ function Root({ value, correction, id, ...rest }) {
|
|
|
22
22
|
}
|
|
23
23
|
const Frame = (props) => usePart(useQrCode("Frame").frame, "svg", props);
|
|
24
24
|
const Pattern = (props) => usePart(useQrCode("Pattern").pattern, "path", props);
|
|
25
|
-
const QrCode = {
|
|
25
|
+
const QrCode = /* @__PURE__ */ parts("QrCode", {
|
|
26
26
|
Root,
|
|
27
27
|
Frame,
|
|
28
28
|
Pattern
|
|
29
|
-
};
|
|
29
|
+
});
|
|
30
30
|
export { QrCode };
|
|
31
31
|
|
|
32
32
|
//# sourceMappingURL=qr-code.js.map
|
package/src/qr-code.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/react/src/qr-code.tsx"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCodeProps } from \"@kirana-ui/core/qr-code\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useQrCode(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<QrCode.${part}> must be inside <QrCode.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<QrCodeProps, \"id\"> & { id?: string }
|
|
1
|
+
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/react/src/qr-code.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCodeProps } from \"@kirana-ui/core/qr-code\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"qrCode\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useQrCode(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<QrCode.${part}> must be inside <QrCode.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<QrCodeProps, \"id\"> & { id?: string }\n>\n\nfunction Root({ value, correction, id, ...rest }: RootProps): ReactElement {\n const controller = useController<QrCodeProps, Controller>(createQrCode, {\n value,\n correction,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type FrameProps = PartComponentProps<\"svg\", StateOf<Parts[\"frame\"]>>\n\nconst Frame = (props: FrameProps) => usePart(useQrCode(\"Frame\").frame, \"svg\", props)\nexport type PatternProps = PartComponentProps<\"path\", StateOf<Parts[\"pattern\"]>>\n\nconst Pattern = (props: PatternProps) => usePart(useQrCode(\"Pattern\").pattern, \"path\", props)\n\nexport const QrCode = /* @__PURE__ */ parts(\"QrCode\", { Root, Frame, Pattern })\n"],"mappings":";;;;;AAYA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,UAAU,MAA0B;CAC3C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,WAAW,KAAK,+BAA+B;CAChF,OAAO;AACT;AAQA,SAAS,KAAK,EAAE,OAAO,YAAY,IAAI,GAAG,QAAiC;CACzE,MAAM,aAAa,cAAuC,cAAc;EACtE;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,UAAU,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAGnF,MAAM,WAAW,UAAwB,QAAQ,UAAU,SAAS,CAAC,CAAC,SAAS,QAAQ,KAAK;AAE5F,MAAa,SAAyB,sBAAM,UAAU;CAAE;CAAM;CAAO;AAAQ,CAAC"}
|
package/src/radio-group.d.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { RadioGroupProps } from "@kirana-ui/core/radio-group";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["radioGroup"];
|
|
7
|
+
/** `Value` is what tells an item from the others: the type of `value`. */
|
|
8
|
+
export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<RadioGroupProps<Value>, "id"> & {
|
|
5
9
|
id?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function Root<Value>({ value, defaultValue, onValueChange, disabled, readOnly, required, name, form, id, ...rest }: RootProps<Value>): ReactElement;
|
|
8
|
-
export
|
|
10
|
+
}>;
|
|
11
|
+
declare function Root<Value = unknown>({ value, defaultValue, onValueChange, disabled, readOnly, required, name, form, id, ...rest }: RootProps<Value>): ReactElement;
|
|
12
|
+
export type ItemProps = PartComponentProps<"span", StateOf<Parts["item"]>, {
|
|
13
|
+
/** What the group's value is while this item is the chosen one. */
|
|
9
14
|
value: unknown;
|
|
15
|
+
/** Disables this item: it cannot be chosen. */
|
|
10
16
|
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
declare function Item({ value, disabled,
|
|
13
|
-
export
|
|
17
|
+
}>;
|
|
18
|
+
declare function Item({ value, disabled, ...rest }: ItemProps): ReactElement;
|
|
19
|
+
export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>, {
|
|
14
20
|
/** Keeps the mark in the page while its item is not the chosen one. */
|
|
15
21
|
keepMounted?: boolean;
|
|
16
|
-
}
|
|
22
|
+
}>;
|
|
17
23
|
declare function Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null;
|
|
18
24
|
export declare const RadioGroup: {
|
|
19
|
-
Root: typeof Root;
|
|
20
|
-
Item: typeof Item;
|
|
21
|
-
Indicator: typeof Indicator;
|
|
25
|
+
readonly Root: typeof Root;
|
|
26
|
+
readonly Item: typeof Item;
|
|
27
|
+
readonly Indicator: typeof Indicator;
|
|
22
28
|
};
|
|
23
29
|
export {};
|
|
24
30
|
//# sourceMappingURL=radio-group.d.ts.map
|
package/src/radio-group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
2
|
import { FieldContext } from "./field-context.js";
|
|
3
|
-
import { useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
3
|
+
import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
4
4
|
import { defined, within } from "@kirana-ui/core";
|
|
5
5
|
import { createContext, useContext, useMemo } from "react";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { createRadioGroup } from "@kirana-ui/core/radio-group";
|
|
8
8
|
// src/radio-group.tsx
|
|
9
9
|
const Context = createContext(null);
|
|
@@ -33,14 +33,17 @@ function Root({ value, defaultValue, onValueChange, disabled, readOnly, required
|
|
|
33
33
|
});
|
|
34
34
|
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
35
35
|
value: controller,
|
|
36
|
-
children: /* @__PURE__ */ jsx(
|
|
36
|
+
children: /* @__PURE__ */ jsx(PartElement, {
|
|
37
|
+
of: controller.root,
|
|
38
|
+
tag: "div",
|
|
39
|
+
...rest
|
|
40
|
+
})
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
function Item({ value, disabled, children, ...rest }) {
|
|
43
|
+
function Item({ value, disabled, ...rest }) {
|
|
41
44
|
const controller = useRadioGroup("Item");
|
|
42
45
|
const options = useOptions({ disabled });
|
|
43
|
-
const
|
|
46
|
+
const made = useMemo(() => {
|
|
44
47
|
const read = () => defined(options.get());
|
|
45
48
|
return {
|
|
46
49
|
item: controller.item(value, read),
|
|
@@ -53,18 +56,12 @@ function Item({ value, disabled, children, ...rest }) {
|
|
|
53
56
|
]);
|
|
54
57
|
return /* @__PURE__ */ jsx(ItemContext.Provider, {
|
|
55
58
|
value,
|
|
56
|
-
children: /* @__PURE__ */ jsxs(PartElement, {
|
|
57
|
-
|
|
58
|
-
tag: "
|
|
59
|
-
|
|
60
|
-
children: [children, /* @__PURE__ */ jsx(PartElement, {
|
|
61
|
-
part: parts.input,
|
|
62
|
-
tag: "input"
|
|
63
|
-
})]
|
|
64
|
-
})
|
|
59
|
+
children: usePart(made.item, "span", rest, void 0, (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, /* @__PURE__ */ jsx(PartElement, {
|
|
60
|
+
of: made.input,
|
|
61
|
+
tag: "input"
|
|
62
|
+
})] }))
|
|
65
63
|
});
|
|
66
64
|
}
|
|
67
|
-
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
68
65
|
function Indicator({ keepMounted, ...props }) {
|
|
69
66
|
const controller = useRadioGroup("Indicator");
|
|
70
67
|
const value = useContext(ItemContext);
|
|
@@ -72,16 +69,16 @@ function Indicator({ keepMounted, ...props }) {
|
|
|
72
69
|
useMount(indicator);
|
|
73
70
|
if (!useSignal(indicator.mounted) && !keepMounted) return null;
|
|
74
71
|
return /* @__PURE__ */ jsx(PartElement, {
|
|
75
|
-
|
|
72
|
+
of: indicator.part,
|
|
76
73
|
tag: "span",
|
|
77
74
|
...props
|
|
78
75
|
});
|
|
79
76
|
}
|
|
80
|
-
const RadioGroup = {
|
|
77
|
+
const RadioGroup = /* @__PURE__ */ parts("RadioGroup", {
|
|
81
78
|
Root,
|
|
82
79
|
Item,
|
|
83
80
|
Indicator
|
|
84
|
-
};
|
|
81
|
+
});
|
|
85
82
|
export { RadioGroup };
|
|
86
83
|
|
|
87
84
|
//# sourceMappingURL=radio-group.js.map
|
package/src/radio-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/react/src/radio-group.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type {
|
|
1
|
+
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/react/src/radio-group.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroup as Controller, RadioGroupProps } from \"@kirana-ui/core/radio-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport {\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"radioGroup\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<unknown>(undefined)\n\nfunction useRadioGroup(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<RadioGroup.${part}> must be inside <RadioGroup.Root>`)\n return controller\n}\n\n/** `Value` is what tells an item from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<RadioGroupProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createRadioGroup<Value>, { field, direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"item\"]>,\n {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n /** Disables this item: it cannot be chosen. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useRadioGroup(\"Item\")\n const options = useOptions({ disabled })\n const made = useMemo(() => {\n const read = () => defined(options.get())\n return { item: controller.item(value, read), input: controller.itemInput(value, read) }\n }, [controller, value, options])\n return (\n <ItemContext.Provider value={value}>\n {usePart(made.item, \"span\", rest, undefined, (content) => (\n // Its native input is the element's last child, whatever element the caller asked for.\n <>\n {content}\n <PartElement of={made.input} tag=\"input\" />\n </>\n ))}\n </ItemContext.Provider>\n )\n}\n\nexport type IndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean\n }\n>\n\nfunction Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const controller = useRadioGroup(\"Indicator\")\n const value = useContext(ItemContext)\n const indicator = useMemo(() => controller.indicator(value), [controller, value])\n useMount(indicator)\n const mounted = useSignal(indicator.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={indicator.part} tag=\"span\" {...props} />\n}\n\nexport const RadioGroup = /* @__PURE__ */ parts(\"RadioGroup\", { Root, Item, Indicator })\n"],"mappings":";;;;;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAuB,KAAA,CAAS;AAEpD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QAC8B;CACjC,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,kBAAyB;EAAE;EAAO;CAAU,CAAC;CACnE,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACvC,CAAA;AAEtB;AAaA,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,QAAiC;CACnE,MAAM,aAAa,cAAc,MAAM;CACvC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,OAAO,cAAc;EACzB,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC;EACxC,OAAO;GAAE,MAAM,WAAW,KAAK,OAAO,IAAI;GAAG,OAAO,WAAW,UAAU,OAAO,IAAI;EAAE;CACxF,GAAG;EAAC;EAAY;EAAO;CAAO,CAAC;CAC/B,OACE,oBAAC,YAAY,UAAb;EAA6B;EAC1B,UAAA,QAAQ,KAAK,MAAM,QAAQ,MAAM,KAAA,IAAY,YAE5C,qBAAA,YAAA,EAAA,UAAA,CACG,SACD,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAO,KAAI;EAAS,CAAA,CAC1C,EAAA,CAAA,CACH;CACmB,CAAA;AAE1B;AAWA,SAAS,UAAU,EAAE,aAAa,GAAG,SAA8C;CACjF,MAAM,aAAa,cAAc,WAAW;CAC5C,MAAM,QAAQ,WAAW,WAAW;CACpC,MAAM,YAAY,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAChF,SAAS,SAAS;CAElB,IAAI,CADY,UAAU,UAAU,OACzB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,UAAU;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA;AACjE;AAEA,MAAa,aAA6B,sBAAM,cAAc;CAAE;CAAM;CAAM;AAAU,CAAC"}
|
package/src/resizable.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { ResizablePanelOptions, ResizableProps } from "@kirana-ui/core/resizable";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["resizable"];
|
|
7
|
+
export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, Omit<ResizableProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
9
|
+
}>;
|
|
7
10
|
declare function Group({ orientation, onSizesChange, keyboardStep, disabled, id, ...rest }: GroupProps): ReactElement;
|
|
8
|
-
export type PanelProps = PartComponentProps
|
|
11
|
+
export type PanelProps = PartComponentProps<"div", StateOf<Parts["panel"]>, ResizablePanelOptions>;
|
|
9
12
|
declare function Panel({ defaultSize, minSize, maxSize, ...props }: PanelProps): ReactElement;
|
|
10
|
-
|
|
13
|
+
export type HandleProps = PartComponentProps<"div", StateOf<Parts["handle"]>, {
|
|
14
|
+
/** Disables this handle: it cannot be dragged or moved with the keyboard. */
|
|
11
15
|
disabled?: boolean;
|
|
12
|
-
}
|
|
16
|
+
}>;
|
|
17
|
+
declare function Handle({ disabled, ...props }: HandleProps): ReactElement;
|
|
13
18
|
export declare const Resizable: {
|
|
14
|
-
Group: typeof Group;
|
|
15
|
-
Panel: typeof Panel;
|
|
16
|
-
Handle: typeof Handle;
|
|
19
|
+
readonly Group: typeof Group;
|
|
20
|
+
readonly Panel: typeof Panel;
|
|
21
|
+
readonly Handle: typeof Handle;
|
|
17
22
|
};
|
|
18
23
|
export {};
|
|
19
24
|
//# sourceMappingURL=resizable.d.ts.map
|
package/src/resizable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
|
-
import { useController, useOptions, usePart } from "./runtime.js";
|
|
2
|
+
import { parts, useController, useOptions, usePart } from "./runtime.js";
|
|
3
3
|
import { defined, within } from "@kirana-ui/core";
|
|
4
4
|
import { createContext, useContext, useMemo } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -41,11 +41,11 @@ function Handle({ disabled, ...props }) {
|
|
|
41
41
|
const part = useMemo(() => controller.handle(() => defined(options.get())), [controller, options]);
|
|
42
42
|
return usePart(part, "div", props);
|
|
43
43
|
}
|
|
44
|
-
const Resizable = {
|
|
44
|
+
const Resizable = /* @__PURE__ */ parts("Resizable", {
|
|
45
45
|
Group,
|
|
46
46
|
Panel,
|
|
47
47
|
Handle
|
|
48
|
-
};
|
|
48
|
+
});
|
|
49
49
|
export { Resizable };
|
|
50
50
|
|
|
51
51
|
//# sourceMappingURL=resizable.js.map
|
package/src/resizable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/react/src/resizable.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport { createResizable } from \"@kirana-ui/core/resizable\"\nimport type {\n Resizable as Controller,\n ResizablePanelOptions,\n ResizableProps,\n} from \"@kirana-ui/core/resizable\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useResizable(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Resizable.${part}> must be inside <Resizable.Group>`)\n return controller\n}\n\nexport type GroupProps = Omit<ResizableProps, \"id\"> & { id?: string }
|
|
1
|
+
{"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/react/src/resizable.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createResizable } from \"@kirana-ui/core/resizable\"\nimport type {\n Resizable as Controller,\n ResizablePanelOptions,\n ResizableProps,\n} from \"@kirana-ui/core/resizable\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"resizable\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useResizable(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Resizable.${part}> must be inside <Resizable.Group>`)\n return controller\n}\n\nexport type GroupProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"group\"]>,\n Omit<ResizableProps, \"id\"> & { id?: string }\n>\n\nfunction Group({\n orientation,\n onSizesChange,\n keyboardStep,\n disabled,\n id,\n ...rest\n}: GroupProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<ResizableProps, Controller>(\n within(createResizable, { direction }),\n { orientation, onSizesChange, keyboardStep, disabled, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.group, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type PanelProps = PartComponentProps<\"div\", StateOf<Parts[\"panel\"]>, ResizablePanelOptions>\n\nfunction Panel({ defaultSize, minSize, maxSize, ...props }: PanelProps): ReactElement {\n const controller = useResizable(\"Panel\")\n const options = useOptions({ defaultSize, minSize, maxSize })\n const part = useMemo(() => controller.panel(() => defined(options.get())), [controller, options])\n return usePart(part, \"div\", props)\n}\n\nexport type HandleProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"handle\"]>,\n {\n /** Disables this handle: it cannot be dragged or moved with the keyboard. */\n disabled?: boolean\n }\n>\n\nfunction Handle({ disabled, ...props }: HandleProps): ReactElement {\n const controller = useResizable(\"Handle\")\n const options = useOptions({ disabled })\n const part = useMemo(() => controller.handle(() => defined(options.get())), [controller, options])\n return usePart(part, \"div\", props)\n}\n\nexport const Resizable = /* @__PURE__ */ parts(\"Resizable\", { Group, Panel, Handle })\n"],"mappings":";;;;;;;AAkBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,mCAAmC;CACvF,OAAO;AACT;AAQA,SAAS,MAAM,EACb,aACA,eACA,cACA,UACA,IACA,GAAG,QACwB;CAC3B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,iBAAiB,EAAE,UAAU,CAAC,GACrC;EAAE;EAAa;EAAe;EAAc;EAAU;CAAG,CAC3D;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,OAAO,OAAO,IAAI;CAAoB,CAAA;AAEnG;AAIA,SAAS,MAAM,EAAE,aAAa,SAAS,SAAS,GAAG,SAAmC;CACpF,MAAM,aAAa,aAAa,OAAO;CACvC,MAAM,UAAU,WAAW;EAAE;EAAa;EAAS;CAAQ,CAAC;CAC5D,MAAM,OAAO,cAAc,WAAW,YAAY,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC;CAChG,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAWA,SAAS,OAAO,EAAE,UAAU,GAAG,SAAoC;CACjE,MAAM,aAAa,aAAa,QAAQ;CACxC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,OAAO,cAAc,WAAW,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC;CACjG,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAEA,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAO;CAAO;AAAO,CAAC"}
|
package/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Part, ReadonlySignal } from "@kirana-ui/core";
|
|
2
|
-
import { ReactElement, ReactNode, Ref, useLayoutEffect } from "react";
|
|
1
|
+
import { Anchor, Part, PartEvent, PartState, PositionOptions, ReadonlySignal, Signal } from "@kirana-ui/core";
|
|
2
|
+
import { ClassAttributes, ComponentPropsWithoutRef, HTMLAttributes, JSX, ReactElement, ReactNode, Ref, RefCallback, RefObject, SyntheticEvent, useLayoutEffect } from "react";
|
|
3
3
|
/** A layout effect in the browser, an effect (which never runs) on a server. */
|
|
4
4
|
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
5
5
|
/** A core signal's value, re-rendering when it changes. */
|
|
@@ -25,25 +25,96 @@ export declare function useMount(mounted: {
|
|
|
25
25
|
}): void;
|
|
26
26
|
/** A part's own options as a core signal that follows each render, after it commits. */
|
|
27
27
|
export declare function useOptions<T extends Record<string, unknown>>(options: T): ReadonlySignal<T>;
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
|
|
28
|
+
/** The elements a part is drawn as, by their tag: `"button"`, `"div"`, `"svg"`. */
|
|
29
|
+
export type PartTag = keyof JSX.IntrinsicElements;
|
|
30
|
+
/** The element a tag draws: an `HTMLButtonElement` for `"button"`. */
|
|
31
|
+
export type ElementOf<Tag extends PartTag> = JSX.IntrinsicElements[Tag] extends ClassAttributes<infer Drawn> ? Drawn : Element;
|
|
32
|
+
type Hearing<Prop> = Prop extends ((event: infer Heard) => infer Answer) ? Heard extends SyntheticEvent ? (event: PartEvent<Heard>) => Answer : Prop : Prop;
|
|
33
|
+
/**
|
|
34
|
+
* The props a `render` function is handed, to spread on what it draws: the part's attributes,
|
|
35
|
+
* its handlers and its ref, with the caller's under them. An attribute of one kind of element
|
|
36
|
+
* (`href`, `type`) is among them unnamed, as `unknown`.
|
|
37
|
+
*/
|
|
38
|
+
export type RenderedProps = HTMLAttributes<HTMLElement> & {
|
|
39
|
+
ref?: RefCallback<HTMLElement> | undefined;
|
|
40
|
+
} & Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* What `render` takes: an element, drawn with the part's props merged over its own, or a
|
|
43
|
+
* function given the part's props and its state.
|
|
44
|
+
*/
|
|
45
|
+
export type RenderProp<State = PartState> = ReactElement<Record<string, unknown>> | ((props: RenderedProps, state: State) => ReactElement);
|
|
46
|
+
/**
|
|
47
|
+
* A part's props: its element's own (`Tag`'s attributes and handlers, a `ref` to that
|
|
48
|
+
* element), `render`, and the part's own props (`Own`) in place of the element's of the same
|
|
49
|
+
* name. `State` is what a `render` function is told of the part.
|
|
50
|
+
*/
|
|
51
|
+
export type PartComponentProps<Tag extends PartTag = "div", State = PartState, Own = unknown> = { [Name in keyof ComponentPropsWithoutRef<Tag> as Name extends keyof Own ? never : Name]: Hearing<ComponentPropsWithoutRef<Tag>[Name]>; } & Own & {
|
|
52
|
+
/**
|
|
53
|
+
* Renders the part as another element or component. An element's own props lie over the
|
|
54
|
+
* props handed to the part, and the part's own (its role, its state, its handlers) over
|
|
55
|
+
* both; a function is given the part's props and its state (`open`, `side` …, read from
|
|
56
|
+
* its `data-*` attributes).
|
|
57
|
+
*/
|
|
31
58
|
render?: RenderProp<State> | undefined;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
59
|
+
ref?: Ref<ElementOf<Tag>> | undefined;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Renders a part: its element (or the caller's `render`), and the part's DOM work attached to
|
|
63
|
+
* the element. Three layers of props, lowest first: what was handed to the part, the `render`
|
|
64
|
+
* element's own, the part's. A higher layer wins an attribute; classes join; styles are merged
|
|
65
|
+
* property by property; every handler of an event runs, lowest first, and
|
|
66
|
+
* `event.preventKiranaHandler()` in a caller's stops the part's. The `render` element's own
|
|
67
|
+
* children are drawn when it has any, and both its ref and the part's `ref` get the element.
|
|
68
|
+
* `hold` is for a part that keeps something of its own in its element (a hidden input): it is
|
|
69
|
+
* given the content and returns what the element holds, whoever drew the element.
|
|
70
|
+
*/
|
|
71
|
+
export declare function usePart<Tag extends PartTag, State = PartState>(part: Part, tag: Tag, props: PartComponentProps<Tag, State>, state?: State, hold?: (content: ReactNode) => ReactNode): ReactElement;
|
|
36
72
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
73
|
+
* A component that is handed its caller's `ref` on every React the package takes, under the
|
|
74
|
+
* name DevTools shows it by. React 19 gives a component its `ref` among its props, which is
|
|
75
|
+
* where a part reads it; before, only a `forwardRef` component was given one, so there the
|
|
76
|
+
* component is drawn by one that puts the ref back among the props. Its type is its own
|
|
77
|
+
* either way, so one that is generic stays generic. One that already has a name keeps it.
|
|
39
78
|
*/
|
|
40
|
-
export declare function
|
|
79
|
+
export declare function component<Drawn extends (props: never) => ReactNode>(name: string, draw: Drawn): Drawn;
|
|
80
|
+
/**
|
|
81
|
+
* A component's parts, each one a `component` named `Name.Part`. A part that is another
|
|
82
|
+
* component's (a date picker's trigger is a popover's) is the same component there and here.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parts<const Parts extends Record<string, unknown>>(name: string, all: Parts): Parts;
|
|
85
|
+
/**
|
|
86
|
+
* A part's element as a component of its own, for a part that is not always in the page: the
|
|
87
|
+
* part decides, and draws this when it is. It takes the part's props, with the part it is the
|
|
88
|
+
* element `of`, its tag, and what the element holds of the part's own (`hold`, as `usePart`'s).
|
|
89
|
+
*/
|
|
90
|
+
export declare const PartElement: <Tag extends PartTag, State = PartState>({ of, tag, hold, ...props }: PartComponentProps<Tag, State> & {
|
|
91
|
+
of: Part;
|
|
92
|
+
tag: Tag;
|
|
93
|
+
hold?: ((content: ReactNode) => ReactNode) | undefined;
|
|
94
|
+
}) => ReactElement;
|
|
95
|
+
/** A positioner's own props: where its popup goes, and what it is placed against. */
|
|
96
|
+
export type PositionerOptions = Partial<Omit<PositionOptions, "anchor">> & {
|
|
97
|
+
/**
|
|
98
|
+
* What the popup is placed against, when that is not its trigger: an element, a ref to one,
|
|
99
|
+
* a place in the viewport (an object with `getBoundingClientRect`), or a function that gives
|
|
100
|
+
* one. It may change while the popup is open: the popup follows.
|
|
101
|
+
*/
|
|
102
|
+
anchor?: Anchor | RefObject<Element | null> | (() => Anchor | null | undefined) | null | undefined;
|
|
103
|
+
};
|
|
104
|
+
/** A positioner's props: where its popup goes and what it is placed against, and its element's. */
|
|
105
|
+
export type PositionerProps<State = PartState> = PartComponentProps<"div", State, PositionerOptions>;
|
|
106
|
+
/**
|
|
107
|
+
* A positioner's own props, written where its placement reads them: the one place they are
|
|
108
|
+
* named. Gives back what is left, for the part's element.
|
|
109
|
+
*/
|
|
110
|
+
export declare function usePositioning<Props extends PositionerOptions>(positioning: Signal<Partial<PositionOptions>>, { side, align, sideOffset, alignOffset, collisionPadding, anchor, ...rest }: Props): Omit<Props, keyof PositionerOptions>;
|
|
41
111
|
/**
|
|
42
112
|
* A text input whose text is the core's own (a combobox's, a number field's): its `value` is
|
|
43
113
|
* given to React as the input's default. To React a `value` with no `onChange` is an input
|
|
44
114
|
* that cannot be typed in; the core writes the text itself, as it changes.
|
|
45
115
|
*/
|
|
46
116
|
export declare function useOwnText(part: Part): Part;
|
|
117
|
+
/** What `PortalProvider` takes. */
|
|
47
118
|
export interface PortalProviderProps {
|
|
48
119
|
/** Where the popups inside are drawn; the end of `<body>` while it is not given. */
|
|
49
120
|
container?: HTMLElement | null | undefined;
|
|
@@ -54,8 +125,11 @@ export interface PortalProviderProps {
|
|
|
54
125
|
* the page (a shadow root's host, a full-screen element, a frame) in place of `<body>`.
|
|
55
126
|
*/
|
|
56
127
|
export declare function PortalProvider({ container, children }: PortalProviderProps): ReactElement;
|
|
57
|
-
/**
|
|
58
|
-
export
|
|
128
|
+
/** Draws no element of its own: its children at the end of `<body>`, or where a `PortalProvider` says. */
|
|
129
|
+
export interface PortalProps {
|
|
59
130
|
children?: ReactNode;
|
|
60
|
-
}
|
|
131
|
+
}
|
|
132
|
+
/** Its children in a container at the end of the page, once the page has hydrated. */
|
|
133
|
+
export declare function Portal({ children }: PortalProps): ReactElement | null;
|
|
134
|
+
export type { PartEvent };
|
|
61
135
|
//# sourceMappingURL=runtime.d.ts.map
|