@cloudflare/kumo 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/ai/component-registry.json +220 -30
- package/ai/component-registry.md +305 -19
- package/dist/.build-complete +1 -1
- package/dist/blocks-source/resource-list/resource-list.tsx +1 -1
- package/dist/chunks/{autocomplete-cs3fwy6lwzlyirpq.js → autocomplete-48aq0d244bs2e8zv.js} +3 -3
- package/dist/chunks/{autocomplete-cs3fwy6lwzlyirpq.js.map → autocomplete-48aq0d244bs2e8zv.js.map} +1 -1
- package/dist/chunks/{checkbox-eren6w2csum1xghg.js → checkbox-hvxfvhtx1qjo2mww.js} +2 -2
- package/dist/chunks/{checkbox-eren6w2csum1xghg.js.map → checkbox-hvxfvhtx1qjo2mww.js.map} +1 -1
- package/dist/chunks/{clipboard-text-f9q753udny1uyxr5.js → clipboard-text-hswydzx3iql369sd.js} +2 -2
- package/dist/chunks/{clipboard-text-f9q753udny1uyxr5.js.map → clipboard-text-hswydzx3iql369sd.js.map} +1 -1
- package/dist/chunks/{code-cz0w1y5z4h29a9eg.js → code-f9v1ikwhekqw274q.js} +4 -4
- package/dist/chunks/{code-cz0w1y5z4h29a9eg.js.map → code-f9v1ikwhekqw274q.js.map} +1 -1
- package/dist/chunks/{collapsible-k8urhi16pg90jvxa.js → collapsible-nlp2jvcyuzxmq28o.js} +12 -11
- package/dist/chunks/{collapsible-k8urhi16pg90jvxa.js.map → collapsible-nlp2jvcyuzxmq28o.js.map} +1 -1
- package/dist/chunks/{combobox-n9qht9h9ag6kh5sn.js → combobox-fq36ye0hstote16x.js} +10 -10
- package/dist/chunks/{combobox-n9qht9h9ag6kh5sn.js.map → combobox-fq36ye0hstote16x.js.map} +1 -1
- package/dist/chunks/{command-palette-gk9m34ymp2b3hfc5.js → command-palette-md65owxt5hv4rt9r.js} +142 -142
- package/dist/chunks/{command-palette-gk9m34ymp2b3hfc5.js.map → command-palette-md65owxt5hv4rt9r.js.map} +1 -1
- package/dist/chunks/{date-range-picker-c9wnx9tbwohai7jy.js → date-range-picker-o8uyril1kogvhoei.js} +19 -19
- package/dist/chunks/{date-range-picker-c9wnx9tbwohai7jy.js.map → date-range-picker-o8uyril1kogvhoei.js.map} +1 -1
- package/dist/chunks/{dialog-94v7wiz7j3in6528.js → dialog-k3f1fbam6nt96k8x.js} +2 -2
- package/dist/chunks/{dialog-94v7wiz7j3in6528.js.map → dialog-k3f1fbam6nt96k8x.js.map} +1 -1
- package/dist/chunks/{empty-kpymw59thjf2ip8g.js → empty-b82oer7npkhtkx7k.js} +6 -6
- package/dist/chunks/{empty-kpymw59thjf2ip8g.js.map → empty-b82oer7npkhtkx7k.js.map} +1 -1
- package/dist/chunks/{field-lnj619xpe8zjd26r.js → field-c0wf94plit2gci59.js} +2 -2
- package/dist/chunks/{field-lnj619xpe8zjd26r.js.map → field-c0wf94plit2gci59.js.map} +1 -1
- package/dist/chunks/{input-area-h8xbqturegdfm1mi.js → input-area-bkyzu6f7gsck479h.js} +3 -3
- package/dist/chunks/{input-area-h8xbqturegdfm1mi.js.map → input-area-bkyzu6f7gsck479h.js.map} +1 -1
- package/dist/chunks/{input-group-dh4pg8p20rh4mdi0.js → input-group-bidweffa0zyg8gt0.js} +3 -3
- package/dist/chunks/{input-group-dh4pg8p20rh4mdi0.js.map → input-group-bidweffa0zyg8gt0.js.map} +1 -1
- package/dist/chunks/{input-lpa5fc75tgrraafv.js → input-ncfowphv81yq7fyy.js} +18 -18
- package/dist/chunks/input-ncfowphv81yq7fyy.js.map +1 -0
- package/dist/chunks/{label-be8m7qzlakzig2sl.js → label-c3h9i3y4wiccelt7.js} +22 -22
- package/dist/chunks/{label-be8m7qzlakzig2sl.js.map → label-c3h9i3y4wiccelt7.js.map} +1 -1
- package/dist/chunks/{layer-card-hvivdirwwnyq88wa.js → layer-card-ikm31xemd70w3lru.js} +2 -2
- package/dist/chunks/{layer-card-hvivdirwwnyq88wa.js.map → layer-card-ikm31xemd70w3lru.js.map} +1 -1
- package/dist/chunks/{meter-bqetlujwg8gm2u7m.js → meter-n34a7yb8c3rim26i.js} +2 -2
- package/dist/chunks/{meter-bqetlujwg8gm2u7m.js.map → meter-n34a7yb8c3rim26i.js.map} +1 -1
- package/dist/chunks/{pagination-ho8zesqfyp6ckmrl.js → pagination-jb3mncivbwsoi1se.js} +40 -40
- package/dist/chunks/{pagination-ho8zesqfyp6ckmrl.js.map → pagination-jb3mncivbwsoi1se.js.map} +1 -1
- package/dist/chunks/{select-kpfbib9l8xrrmzpz.js → select-g261chvosodu22i8.js} +3 -3
- package/dist/chunks/{select-kpfbib9l8xrrmzpz.js.map → select-g261chvosodu22i8.js.map} +1 -1
- package/dist/chunks/{sensitive-input-i1upqytzaw2pus8v.js → sensitive-input-cijagk551mesdtk4.js} +3 -3
- package/dist/chunks/{sensitive-input-i1upqytzaw2pus8v.js.map → sensitive-input-cijagk551mesdtk4.js.map} +1 -1
- package/dist/chunks/{sidebar-kh37grvfxto14ek6.js → sidebar-kb9kykqfgy5yzqwr.js} +4 -4
- package/dist/chunks/{sidebar-kh37grvfxto14ek6.js.map → sidebar-kb9kykqfgy5yzqwr.js.map} +1 -1
- package/dist/chunks/{surface-o63tktyrifcjejyb.js → surface-k0e8mq1x00b7i8r6.js} +2 -2
- package/dist/chunks/{surface-o63tktyrifcjejyb.js.map → surface-k0e8mq1x00b7i8r6.js.map} +1 -1
- package/dist/chunks/{switch-lclhiplr9zqf73tj.js → switch-jdfsr3j3oa1qxegw.js} +2 -2
- package/dist/chunks/{switch-lclhiplr9zqf73tj.js.map → switch-jdfsr3j3oa1qxegw.js.map} +1 -1
- package/dist/chunks/{table-fyy8gl875yyevqs3.js → table-iudje0lva0z68jto.js} +2 -2
- package/dist/chunks/{table-fyy8gl875yyevqs3.js.map → table-iudje0lva0z68jto.js.map} +1 -1
- package/dist/chunks/{tabs-jywwt8ebjqjkux75.js → tabs-mkhf1uemgr3ij0ps.js} +3 -3
- package/dist/chunks/{tabs-jywwt8ebjqjkux75.js.map → tabs-mkhf1uemgr3ij0ps.js.map} +1 -1
- package/dist/chunks/toast-h573o0tc7tefivk2.js.map +1 -1
- package/dist/code.js +30 -30
- package/dist/code.js.map +1 -1
- package/dist/components/autocomplete.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/clipboard-text.js +1 -1
- package/dist/components/code.js +1 -1
- package/dist/components/collapsible.js +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/command-palette.js +1 -1
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/empty.js +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input.js +3 -3
- package/dist/components/label.js +1 -1
- package/dist/components/layer-card.js +1 -1
- package/dist/components/meter.js +1 -1
- package/dist/components/pagination.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/sensitive-input.js +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/surface.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/index.js +27 -27
- package/dist/scripts/theme-generator/config.js +11 -4
- package/dist/scripts/theme-generator/config.js.map +1 -1
- package/dist/src/components/code/code.d.ts +2 -2
- package/dist/src/components/collapsible/collapsible.d.ts +1 -1
- package/dist/src/components/collapsible/collapsible.d.ts.map +1 -1
- package/dist/src/components/toast/toast.d.ts +1 -1
- package/dist/src/components/toast/toast.d.ts.map +1 -1
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-kumo.css +8 -8
- package/package.json +1 -1
- package/scripts/component-registry/index.test.ts +42 -0
- package/scripts/component-registry/index.ts +18 -4
- package/scripts/component-registry/metadata.ts +222 -2
- package/scripts/theme-generator/config.ts +9 -9
- package/dist/chunks/input-lpa5fc75tgrraafv.js.map +0 -1
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as c, Fragment as f } from "react/jsx-runtime";
|
|
3
|
-
import { Info as
|
|
4
|
-
import { c as
|
|
5
|
-
import { B as
|
|
6
|
-
import { T as
|
|
3
|
+
import { Info as u } from "@phosphor-icons/react";
|
|
4
|
+
import { c as a } from "./cn-ct4n7r74mh8y0f48.js";
|
|
5
|
+
import { B as p } from "./button-6by9ntsa3nj553mq.js";
|
|
6
|
+
import { T as b } from "./tooltip-odudhkxe282wxinq.js";
|
|
7
7
|
const T = {
|
|
8
8
|
// Label currently has no variant options but structure is ready for future additions
|
|
9
|
-
},
|
|
10
|
-
function
|
|
11
|
-
return
|
|
9
|
+
}, B = {};
|
|
10
|
+
function d(n = {}) {
|
|
11
|
+
return a(
|
|
12
12
|
// Base styles - when used standalone, apply text styling
|
|
13
13
|
// When used inside Field, the parent FieldBase.Label provides these styles
|
|
14
14
|
"m-0 text-base font-medium text-kumo-default"
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
function o() {
|
|
18
|
-
return
|
|
18
|
+
return a(
|
|
19
19
|
// Content wrapper styles - always applied
|
|
20
20
|
"inline-flex items-center gap-1"
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
function x({
|
|
24
|
-
children:
|
|
24
|
+
children: n,
|
|
25
25
|
showOptional: i = !1,
|
|
26
26
|
tooltip: t,
|
|
27
|
-
className:
|
|
27
|
+
className: s,
|
|
28
28
|
htmlFor: l,
|
|
29
29
|
asContent: m = !1
|
|
30
30
|
}) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
i && /* @__PURE__ */ e("span", { className: "font-normal text-kumo-
|
|
31
|
+
const r = /* @__PURE__ */ c(f, { children: [
|
|
32
|
+
n,
|
|
33
|
+
i && /* @__PURE__ */ e("span", { className: "font-normal text-kumo-subtle", children: "(optional)" }),
|
|
34
34
|
t && /* @__PURE__ */ e(
|
|
35
|
-
|
|
35
|
+
b,
|
|
36
36
|
{
|
|
37
37
|
content: t,
|
|
38
38
|
render: /* @__PURE__ */ e(
|
|
39
|
-
|
|
39
|
+
p,
|
|
40
40
|
{
|
|
41
41
|
variant: "ghost",
|
|
42
42
|
size: "xs",
|
|
43
43
|
shape: "square",
|
|
44
44
|
"aria-label": "More information",
|
|
45
|
-
children: /* @__PURE__ */ e(
|
|
45
|
+
children: /* @__PURE__ */ e(u, { className: "size-4" })
|
|
46
46
|
}
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
49
|
)
|
|
50
50
|
] });
|
|
51
|
-
return m ? /* @__PURE__ */ e("span", { className:
|
|
51
|
+
return m ? /* @__PURE__ */ e("span", { className: a(o(), s), children: r }) : /* @__PURE__ */ e(
|
|
52
52
|
"label",
|
|
53
53
|
{
|
|
54
54
|
htmlFor: l,
|
|
55
|
-
className:
|
|
56
|
-
children:
|
|
55
|
+
className: a(d(), o(), s),
|
|
56
|
+
children: r
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
}
|
|
@@ -62,7 +62,7 @@ export {
|
|
|
62
62
|
T as K,
|
|
63
63
|
x as L,
|
|
64
64
|
o as a,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
B as b,
|
|
66
|
+
d as l
|
|
67
67
|
};
|
|
68
|
-
//# sourceMappingURL=label-
|
|
68
|
+
//# sourceMappingURL=label-c3h9i3y4wiccelt7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-
|
|
1
|
+
{"version":3,"file":"label-c3h9i3y4wiccelt7.js","sources":["../../src/components/label/label.tsx"],"sourcesContent":["import { Info } from \"@phosphor-icons/react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../button\";\nimport { Tooltip } from \"../tooltip\";\n\n/** Label variant definitions (currently empty, reserved for future additions). */\nexport const KUMO_LABEL_VARIANTS = {\n // Label currently has no variant options but structure is ready for future additions\n} as const;\n\nexport const KUMO_LABEL_DEFAULT_VARIANTS = {} as const;\n\n// Derived types from KUMO_LABEL_VARIANTS\nexport interface KumoLabelVariantsProps {}\n\nexport function labelVariants(_props: KumoLabelVariantsProps = {}) {\n return cn(\n // Base styles - when used standalone, apply text styling\n // When used inside Field, the parent FieldBase.Label provides these styles\n \"m-0 text-base font-medium text-kumo-default\",\n );\n}\n\nexport function labelContentVariants() {\n return cn(\n // Content wrapper styles - always applied\n \"inline-flex items-center gap-1\",\n );\n}\n\n/**\n * Label component props.\n *\n * @example\n * ```tsx\n * <Label>Email</Label>\n * <Label showOptional>Middle Name</Label>\n * <Label tooltip=\"We'll use this to send you updates\">Email</Label>\n * ```\n */\nexport interface LabelProps extends KumoLabelVariantsProps {\n /** The label content — can be a string or any React node. */\n children: ReactNode;\n /** When `true`, shows gray \"(optional)\" text after the label. */\n showOptional?: boolean;\n /** Tooltip content displayed next to the label via an info icon. */\n tooltip?: ReactNode;\n /** Additional CSS classes merged via `cn()`. */\n className?: string;\n /** The id of the form element this label is associated with */\n htmlFor?: string;\n /**\n * When true, only renders the inline content (indicators, tooltip) without\n * the outer label element with font styling. Useful when composed inside another\n * label element that already provides the text styling.\n * @default false\n */\n asContent?: boolean;\n}\n\n/**\n * Label component for form fields.\n *\n * Provides a standardized way to display labels with optional indicators:\n * - Optional indicator: gray \"(optional)\" text when `showOptional={true}`\n * - Tooltip: info icon with hover tooltip for additional context\n *\n * @example\n * // Basic label\n * <Label>Email</Label>\n *\n * @example\n * // Optional field with indicator\n * <Label showOptional>Middle Name</Label>\n *\n * @example\n * // With tooltip\n * <Label tooltip=\"We'll use this to send you updates\">Email</Label>\n *\n * @example\n * // With ReactNode children\n * <Label>\n * <span>Custom label with <strong>bold</strong> text</span>\n * </Label>\n */\nexport function Label({\n children,\n showOptional = false,\n tooltip,\n className,\n htmlFor,\n asContent = false,\n}: LabelProps) {\n const content = (\n <>\n {children}\n {showOptional && (\n <span className=\"font-normal text-kumo-subtle\">(optional)</span>\n )}\n {tooltip && (\n <Tooltip\n content={tooltip}\n render={\n <Button\n variant=\"ghost\"\n size=\"xs\"\n shape=\"square\"\n aria-label=\"More information\"\n >\n <Info className=\"size-4\" />\n </Button>\n }\n />\n )}\n </>\n );\n\n // When used as content inside another styled element, just render inline\n if (asContent) {\n return (\n <span className={cn(labelContentVariants(), className)}>{content}</span>\n );\n }\n\n // When used standalone, render as <label> for accessibility\n return (\n <label\n htmlFor={htmlFor}\n className={cn(labelVariants(), labelContentVariants(), className)}\n >\n {content}\n </label>\n );\n}\n\nLabel.displayName = \"Label\";\n"],"names":["KUMO_LABEL_VARIANTS","KUMO_LABEL_DEFAULT_VARIANTS","labelVariants","_props","cn","labelContentVariants","Label","children","showOptional","tooltip","className","htmlFor","asContent","content","jsxs","Fragment","jsx","Tooltip","Button","Info"],"mappings":";;;;;;AAOO,MAAMA,IAAsB;AAAA;AAEnC,GAEaC,IAA8B,CAAA;AAKpC,SAASC,EAAcC,IAAiC,IAAI;AACjE,SAAOC;AAAA;AAAA;AAAA,IAGL;AAAA,EAAA;AAEJ;AAEO,SAASC,IAAuB;AACrC,SAAOD;AAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;AAyDO,SAASE,EAAM;AAAA,EACpB,UAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC,IAAY;AACd,GAAe;AACb,QAAMC,IACJ,gBAAAC,EAAAC,GAAA,EACG,UAAA;AAAA,IAAAR;AAAA,IACAC,KACC,gBAAAQ,EAAC,QAAA,EAAK,WAAU,gCAA+B,UAAA,cAAU;AAAA,IAE1DP,KACC,gBAAAO;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,SAASR;AAAA,QACT,QACE,gBAAAO;AAAA,UAACE;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,OAAM;AAAA,YACN,cAAW;AAAA,YAEX,UAAA,gBAAAF,EAACG,GAAA,EAAK,WAAU,SAAA,CAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,IAAA;AAAA,EAEJ,GAEJ;AAIF,SAAIP,IAEA,gBAAAI,EAAC,UAAK,WAAWZ,EAAGC,KAAwBK,CAAS,GAAI,UAAAG,GAAQ,IAMnE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAAL;AAAA,MACA,WAAWP,EAAGF,EAAA,GAAiBG,EAAA,GAAwBK,CAAS;AAAA,MAE/D,UAAAG;AAAA,IAAA;AAAA,EAAA;AAGP;AAEAP,EAAM,cAAc;"}
|
|
@@ -3,7 +3,7 @@ import { jsx as s } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef as y, Children as p, isValidElement as C, Fragment as g } from "react";
|
|
4
4
|
import { c as a } from "./cn-ct4n7r74mh8y0f48.js";
|
|
5
5
|
import { aU as L, aV as S } from "./vendor-base-ui-ie71jahf0czyf58j.js";
|
|
6
|
-
const A = "overflow-hidden rounded-lg bg-kumo-base shadow-xs ring ring-kumo-line", R = "flex w-full flex-col overflow-hidden rounded-lg bg-kumo-elevated text-base ring ring-kumo-hairline", _ = "-my-2 flex items-center gap-2 bg-kumo-elevated p-4 text-base font-medium text-kumo-
|
|
6
|
+
const A = "overflow-hidden rounded-lg bg-kumo-base shadow-xs ring ring-kumo-line", R = "flex w-full flex-col overflow-hidden rounded-lg bg-kumo-elevated text-base ring ring-kumo-hairline", _ = "-my-2 flex items-center gap-2 bg-kumo-elevated p-4 text-base font-medium text-kumo-subtle", E = "relative flex flex-col gap-2 overflow-hidden rounded-lg bg-kumo-base p-4 pr-3 text-inherit no-underline ring ring-kumo-fill";
|
|
7
7
|
function x(r = {}) {
|
|
8
8
|
return a(A);
|
|
9
9
|
}
|
|
@@ -43,4 +43,4 @@ const h = Object.assign(d, {
|
|
|
43
43
|
export {
|
|
44
44
|
h as L
|
|
45
45
|
};
|
|
46
|
-
//# sourceMappingURL=layer-card-
|
|
46
|
+
//# sourceMappingURL=layer-card-ikm31xemd70w3lru.js.map
|
package/dist/chunks/{layer-card-hvivdirwwnyq88wa.js.map → layer-card-ikm31xemd70w3lru.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-card-
|
|
1
|
+
{"version":3,"file":"layer-card-ikm31xemd70w3lru.js","sources":["../../src/components/layer-card/layer-card.tsx"],"sourcesContent":["import {\n Children,\n Fragment,\n forwardRef,\n isValidElement,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cn } from \"../../utils/cn\";\n\nconst LAYER_CARD_SURFACE_CLASSES =\n \"overflow-hidden rounded-lg bg-kumo-base shadow-xs ring ring-kumo-line\";\nconst LAYER_CARD_LAYERED_ROOT_CLASSES =\n \"flex w-full flex-col overflow-hidden rounded-lg bg-kumo-elevated text-base ring ring-kumo-hairline\";\nconst LAYER_CARD_SECONDARY_CLASSES =\n \"-my-2 flex items-center gap-2 bg-kumo-elevated p-4 text-base font-medium text-kumo-subtle\";\nconst LAYER_CARD_PRIMARY_CLASSES =\n \"relative flex flex-col gap-2 overflow-hidden rounded-lg bg-kumo-base p-4 pr-3 text-inherit no-underline ring ring-kumo-fill\";\n\n/** LayerCard variant definitions (currently empty, reserved for future additions). */\nexport const KUMO_LAYER_CARD_VARIANTS = {\n // LayerCard currently has no variant options but structure is ready for future additions\n} as const;\n\nexport const KUMO_LAYER_CARD_DEFAULT_VARIANTS = {} as const;\n\n// Derived types from KUMO_LAYER_CARD_VARIANTS\nexport interface KumoLayerCardVariantsProps {}\n\nexport function layerCardVariants(_props: KumoLayerCardVariantsProps = {}) {\n return cn(LAYER_CARD_SURFACE_CLASSES);\n}\n\nfunction hasLayerCardSections(children: ReactNode): boolean {\n return Children.toArray(children).some((child): boolean => {\n if (!isValidElement(child)) {\n return false;\n }\n\n if (child.type === LayerCardPrimary || child.type === LayerCardSecondary) {\n return true;\n }\n\n if (child.type === Fragment) {\n const fragmentChild = child as ReactElement<{ children?: ReactNode }>;\n return hasLayerCardSections(fragmentChild.props.children);\n }\n\n return false;\n });\n}\n\n/**\n * LayerCard component props.\n *\n * @example\n * ```tsx\n * <LayerCard className=\"p-4\">\n * Get started with Kumo\n * </LayerCard>\n *\n * <LayerCard>\n * <LayerCard.Secondary>Next Steps</LayerCard.Secondary>\n * <LayerCard.Primary>Get started with Kumo</LayerCard.Primary>\n * </LayerCard>\n * ```\n */\nexport type LayerCardProps = useRender.ComponentProps<\"div\"> &\n KumoLayerCardVariantsProps;\n\nexport type LayerCardSectionProps = PropsWithChildren<{\n /** Additional CSS classes merged via `cn()`. */\n className?: string;\n}>;\n\n/**\n * Card container for both simple surfaces and layered layouts.\n *\n * Render children directly for a single-surface card, or use\n * `LayerCard.Secondary` and `LayerCard.Primary` for the layered card treatment.\n *\n * @example\n * ```tsx\n * <LayerCard className=\"rounded-lg p-4\">Card content</LayerCard>\n * ```\n *\n * @example\n * ```tsx\n * <LayerCard>\n * <LayerCard.Secondary>Getting Started</LayerCard.Secondary>\n * <LayerCard.Primary>Quick start guide</LayerCard.Primary>\n * </LayerCard>\n * ```\n */\nconst LayerCardRoot = forwardRef<HTMLDivElement, LayerCardProps>(function LayerCard(\n { children, className, render, ...props },\n ref,\n) {\n const hasStructuredLayers = hasLayerCardSections(children);\n\n const defaultProps: useRender.ElementProps<\"div\"> = {\n className: cn(\n hasStructuredLayers ? LAYER_CARD_LAYERED_ROOT_CLASSES : layerCardVariants(),\n className,\n ),\n };\n\n return useRender({\n defaultTagName: \"div\",\n render,\n ref,\n props: mergeProps<\"div\">(defaultProps, props, { children }),\n });\n});\n\nfunction LayerCardSecondary({\n children,\n className,\n}: LayerCardSectionProps) {\n return <div className={cn(LAYER_CARD_SECONDARY_CLASSES, className)}>{children}</div>;\n}\n\nfunction LayerCardPrimary({ children, className }: LayerCardSectionProps) {\n return <div className={cn(LAYER_CARD_PRIMARY_CLASSES, className)}>{children}</div>;\n}\n\nLayerCardRoot.displayName = \"LayerCard\";\nLayerCardSecondary.displayName = \"LayerCard.Secondary\";\nLayerCardPrimary.displayName = \"LayerCard.Primary\";\n\ntype LayerCardComponent = typeof LayerCardRoot & {\n Primary: typeof LayerCardPrimary;\n Secondary: typeof LayerCardSecondary;\n};\n\nconst LayerCard = Object.assign(LayerCardRoot, {\n Primary: LayerCardPrimary,\n Secondary: LayerCardSecondary,\n}) as LayerCardComponent;\n\nexport { LayerCard };\n"],"names":["LAYER_CARD_SURFACE_CLASSES","LAYER_CARD_LAYERED_ROOT_CLASSES","LAYER_CARD_SECONDARY_CLASSES","LAYER_CARD_PRIMARY_CLASSES","layerCardVariants","_props","cn","hasLayerCardSections","children","Children","child","isValidElement","LayerCardPrimary","LayerCardSecondary","Fragment","LayerCardRoot","forwardRef","className","render","props","ref","hasStructuredLayers","defaultProps","useRender","mergeProps","LayerCard"],"mappings":";;;;;AAaA,MAAMA,IACJ,yEACIC,IACJ,sGACIC,IACJ,6FACIC,IACJ;AAYK,SAASC,EAAkBC,IAAqC,IAAI;AACzE,SAAOC,EAAGN,CAA0B;AACtC;AAEA,SAASO,EAAqBC,GAA8B;AAC1D,SAAOC,EAAS,QAAQD,CAAQ,EAAE,KAAK,CAACE,MACjCC,EAAeD,CAAK,IAIrBA,EAAM,SAASE,KAAoBF,EAAM,SAASG,IAC7C,KAGLH,EAAM,SAASI,IAEVP,EADeG,EACoB,MAAM,QAAQ,IAGnD,KAZE,EAaV;AACH;AA4CA,MAAMK,IAAgBC,EAA2C,SAC/D,EAAE,UAAAR,GAAU,WAAAS,GAAW,QAAAC,GAAQ,GAAGC,EAAA,GAClCC,GACA;AACA,QAAMC,IAAsBd,EAAqBC,CAAQ,GAEnDc,IAA8C;AAAA,IAClD,WAAWhB;AAAA,MACTe,IAAsBpB,IAAkCG,EAAA;AAAA,MACxDa;AAAA,IAAA;AAAA,EACF;AAGF,SAAOM,EAAU;AAAA,IACf,gBAAgB;AAAA,IAChB,QAAAL;AAAA,IACA,KAAAE;AAAA,IACA,OAAOI,EAAkBF,GAAcH,GAAO,EAAE,UAAAX,GAAU;AAAA,EAAA,CAC3D;AACH,CAAC;AAED,SAASK,EAAmB;AAAA,EAC1B,UAAAL;AAAA,EACA,WAAAS;AACF,GAA0B;AACxB,2BAAQ,OAAA,EAAI,WAAWX,EAAGJ,GAA8Be,CAAS,GAAI,UAAAT,GAAS;AAChF;AAEA,SAASI,EAAiB,EAAE,UAAAJ,GAAU,WAAAS,KAAoC;AACxE,2BAAQ,OAAA,EAAI,WAAWX,EAAGH,GAA4Bc,CAAS,GAAI,UAAAT,GAAS;AAC9E;AAEAO,EAAc,cAAc;AAC5BF,EAAmB,cAAc;AACjCD,EAAiB,cAAc;AAO/B,MAAMa,IAAY,OAAO,OAAOV,GAAe;AAAA,EAC7C,SAASH;AAAA,EACT,WAAWC;AACb,CAAC;"}
|
|
@@ -20,7 +20,7 @@ function N({
|
|
|
20
20
|
className: t("flex w-full flex-col gap-2", o),
|
|
21
21
|
children: [
|
|
22
22
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-4", children: [
|
|
23
|
-
/* @__PURE__ */ e(f, { className: "text-xs text-kumo-
|
|
23
|
+
/* @__PURE__ */ e(f, { className: "text-xs text-kumo-subtle", children: s }),
|
|
24
24
|
a ? /* @__PURE__ */ e("span", { className: "text-sm font-medium text-kumo-default tabular-nums", children: a }) : /* @__PURE__ */ e(d, { children: n && /* @__PURE__ */ e(x, { className: "text-sm font-medium text-kumo-default tabular-nums" }) })
|
|
25
25
|
] }),
|
|
26
26
|
/* @__PURE__ */ e(
|
|
@@ -48,4 +48,4 @@ function N({
|
|
|
48
48
|
export {
|
|
49
49
|
N as M
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=meter-
|
|
51
|
+
//# sourceMappingURL=meter-n34a7yb8c3rim26i.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter-
|
|
1
|
+
{"version":3,"file":"meter-n34a7yb8c3rim26i.js","sources":["../../src/components/meter/meter.tsx"],"sourcesContent":["import { Meter as BaseMeter } from \"@base-ui/react/meter\";\nimport { type ComponentPropsWithoutRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Meter variant definitions (currently empty, reserved for future additions). */\nexport const KUMO_METER_VARIANTS = {\n // Meter currently has no variant options but structure is ready for future additions\n} as const;\n\nexport const KUMO_METER_DEFAULT_VARIANTS = {} as const;\n\n// Derived types from KUMO_METER_VARIANTS\nexport interface KumoMeterVariantsProps {}\n\nexport function meterVariants(_props: KumoMeterVariantsProps = {}) {\n return cn(\n // Base styles\n \"flex w-full flex-col gap-2\",\n );\n}\n\ntype RootProps = ComponentPropsWithoutRef<typeof BaseMeter.Root>;\n\n/**\n * Meter component props.\n *\n * @example\n * ```tsx\n * <Meter label=\"Storage used\" value={65} />\n * <Meter label=\"API requests\" value={75} customValue=\"750 / 1,000\" />\n * ```\n */\nexport interface MeterProps extends RootProps, KumoMeterVariantsProps {\n /** Custom formatted value text (e.g. \"750 / 1,000\") displayed instead of percentage. */\n customValue?: string;\n /** Label text displayed above the meter track. */\n label: string;\n /**\n * Whether to display the percentage value next to the label.\n * @default true\n */\n showValue?: boolean;\n /** Additional CSS classes for the track (background bar). */\n trackClassName?: string;\n /** Additional CSS classes for the indicator (filled bar). */\n indicatorClassName?: string;\n}\n\n/**\n * Progress bar showing a measured value within a known range (e.g. quota usage).\n *\n * @example\n * ```tsx\n * <Meter label=\"Storage\" value={65} />\n * ```\n */\nexport function Meter({\n value,\n customValue,\n label,\n showValue = true,\n className,\n trackClassName,\n indicatorClassName,\n ...props\n}: MeterProps) {\n return (\n <BaseMeter.Root\n value={value}\n {...props}\n className={cn(\"flex w-full flex-col gap-2\", className)}\n >\n <div className=\"flex items-center justify-between gap-4\">\n <BaseMeter.Label className=\"text-xs text-kumo-subtle\">\n {label}\n </BaseMeter.Label>\n {customValue ? (\n <span className=\"text-sm font-medium text-kumo-default tabular-nums\">\n {customValue}\n </span>\n ) : (\n <>\n {showValue && (\n <BaseMeter.Value className=\"text-sm font-medium text-kumo-default tabular-nums\" />\n )}\n </>\n )}\n </div>\n <BaseMeter.Track\n className={cn(\n \"relative h-2 w-full overflow-hidden rounded-full bg-kumo-fill\",\n trackClassName,\n )}\n >\n <BaseMeter.Indicator\n className={cn(\n \"absolute inset-y-0 left-0 rounded-full bg-linear-to-r from-kumo-brand via-kumo-brand to-kumo-brand transition-[width] duration-300 ease-out\",\n indicatorClassName,\n )}\n />\n </BaseMeter.Track>\n </BaseMeter.Root>\n );\n}\n"],"names":["Meter","value","customValue","label","showValue","className","trackClassName","indicatorClassName","props","jsxs","BaseMeter.Root","cn","jsx","BaseMeter.Label","Fragment","BaseMeter.Value","BaseMeter.Track","BaseMeter.Indicator"],"mappings":";;;;AAwDO,SAASA,EAAM;AAAA,EACpB,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,GAAGC;AACL,GAAe;AACb,SACE,gBAAAC;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,OAAAT;AAAA,MACC,GAAGO;AAAA,MACJ,WAAWG,EAAG,8BAA8BN,CAAS;AAAA,MAErD,UAAA;AAAA,QAAA,gBAAAI,EAAC,OAAA,EAAI,WAAU,2CACb,UAAA;AAAA,UAAA,gBAAAG,EAACC,GAAA,EAAgB,WAAU,4BACxB,UAAAV,GACH;AAAA,UACCD,IACC,gBAAAU,EAAC,QAAA,EAAK,WAAU,sDACb,UAAAV,EAAA,CACH,IAEA,gBAAAU,EAAAE,GAAA,EACG,UAAAV,uBACEW,GAAA,EAAgB,WAAU,sDAAqD,EAAA,CAEpF;AAAA,QAAA,GAEJ;AAAA,QACA,gBAAAH;AAAA,UAACI;AAAAA,UAAA;AAAA,YACC,WAAWL;AAAA,cACT;AAAA,cACAL;AAAA,YAAA;AAAA,YAGF,UAAA,gBAAAM;AAAA,cAACK;AAAAA,cAAA;AAAA,gBACC,WAAWN;AAAA,kBACT;AAAA,kBACAJ;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as a, jsxs as p, Fragment as E } from "react/jsx-runtime";
|
|
3
|
-
import { useState as T, useMemo as
|
|
4
|
-
import { I as m } from "./input-group-
|
|
3
|
+
import { useState as T, useMemo as N, useEffect as B, createContext as D, useContext as R } from "react";
|
|
4
|
+
import { I as m } from "./input-group-bidweffa0zyg8gt0.js";
|
|
5
5
|
import { CaretDoubleLeftIcon as F, CaretLeftIcon as V, CaretRightIcon as U, CaretDoubleRightIcon as j } from "@phosphor-icons/react";
|
|
6
6
|
import { c as d } from "./cn-ct4n7r74mh8y0f48.js";
|
|
7
|
-
import { S as P } from "./select-
|
|
8
|
-
const G = [25, 50, 100, 250], y = (n,
|
|
7
|
+
import { S as P } from "./select-g261chvosodu22i8.js";
|
|
8
|
+
const G = [25, 50, 100, 250], y = (n, l, o) => Math.min(Math.max(n, l), o), K = {
|
|
9
9
|
navigation: "Pagination",
|
|
10
10
|
firstPage: "First page",
|
|
11
11
|
previousPage: "Previous page",
|
|
@@ -13,7 +13,7 @@ const G = [25, 50, 100, 250], y = (n, r, o) => Math.min(Math.max(n, r), o), K =
|
|
|
13
13
|
lastPage: "Last page",
|
|
14
14
|
pageNumber: "Page number",
|
|
15
15
|
pageSize: "Page size"
|
|
16
|
-
},
|
|
16
|
+
}, x = {
|
|
17
17
|
controls: "full"
|
|
18
18
|
}, v = D(null);
|
|
19
19
|
function C() {
|
|
@@ -24,10 +24,10 @@ function C() {
|
|
|
24
24
|
);
|
|
25
25
|
return n;
|
|
26
26
|
}
|
|
27
|
-
function k({ children: n, className:
|
|
28
|
-
const { page: o, perPage: e, totalCount: i, pageShowingRange:
|
|
27
|
+
function k({ children: n, className: l }) {
|
|
28
|
+
const { page: o, perPage: e, totalCount: i, pageShowingRange: r } = C(), s = n ? n({ page: o, perPage: e, totalCount: i, pageShowingRange: r }) : i && i > 0 ? /* @__PURE__ */ p(E, { children: [
|
|
29
29
|
"Showing ",
|
|
30
|
-
/* @__PURE__ */ a("span", { className: "tabular-nums", children:
|
|
30
|
+
/* @__PURE__ */ a("span", { className: "tabular-nums", children: r }),
|
|
31
31
|
" of",
|
|
32
32
|
" ",
|
|
33
33
|
/* @__PURE__ */ a("span", { className: "tabular-nums", children: i })
|
|
@@ -36,7 +36,7 @@ function k({ children: n, className: r }) {
|
|
|
36
36
|
"div",
|
|
37
37
|
{
|
|
38
38
|
"data-slot": "pagination-info",
|
|
39
|
-
className: d("text-sm text-kumo-
|
|
39
|
+
className: d("text-sm text-kumo-subtle", l),
|
|
40
40
|
children: s
|
|
41
41
|
}
|
|
42
42
|
);
|
|
@@ -44,25 +44,25 @@ function k({ children: n, className: r }) {
|
|
|
44
44
|
k.displayName = "Pagination.Info";
|
|
45
45
|
function A({
|
|
46
46
|
value: n,
|
|
47
|
-
onChange:
|
|
47
|
+
onChange: l,
|
|
48
48
|
options: o = G,
|
|
49
49
|
label: e = "Per page:",
|
|
50
50
|
className: i
|
|
51
51
|
}) {
|
|
52
|
-
const { labels:
|
|
52
|
+
const { labels: r } = C();
|
|
53
53
|
return /* @__PURE__ */ p(
|
|
54
54
|
"div",
|
|
55
55
|
{
|
|
56
56
|
"data-slot": "pagination-page-size",
|
|
57
57
|
className: d("flex items-center gap-2", i),
|
|
58
58
|
children: [
|
|
59
|
-
e && /* @__PURE__ */ a("span", { className: "text-sm text-kumo-
|
|
59
|
+
e && /* @__PURE__ */ a("span", { className: "text-sm text-kumo-subtle", children: e }),
|
|
60
60
|
/* @__PURE__ */ a(
|
|
61
61
|
P,
|
|
62
62
|
{
|
|
63
|
-
"aria-label":
|
|
63
|
+
"aria-label": r.pageSize,
|
|
64
64
|
value: n,
|
|
65
|
-
onValueChange: (s) =>
|
|
65
|
+
onValueChange: (s) => l(s),
|
|
66
66
|
children: o.map((s) => /* @__PURE__ */ a(P.Option, { value: s, children: s }, s))
|
|
67
67
|
}
|
|
68
68
|
)
|
|
@@ -72,11 +72,11 @@ function A({
|
|
|
72
72
|
}
|
|
73
73
|
A.displayName = "Pagination.PageSize";
|
|
74
74
|
function S({
|
|
75
|
-
controls: n =
|
|
76
|
-
pageSelector:
|
|
75
|
+
controls: n = x.controls,
|
|
76
|
+
pageSelector: l = "input",
|
|
77
77
|
className: o
|
|
78
78
|
}) {
|
|
79
|
-
const { page: e, maxPage: i, setPage:
|
|
79
|
+
const { page: e, maxPage: i, setPage: r, editingPage: s, setEditingPage: c, labels: g } = C();
|
|
80
80
|
return /* @__PURE__ */ a(
|
|
81
81
|
"div",
|
|
82
82
|
{
|
|
@@ -90,7 +90,7 @@ function S({
|
|
|
90
90
|
"aria-label": g.firstPage,
|
|
91
91
|
disabled: e <= 1,
|
|
92
92
|
onClick: () => {
|
|
93
|
-
|
|
93
|
+
r(1), c(1);
|
|
94
94
|
},
|
|
95
95
|
children: /* @__PURE__ */ a(F, { size: 16 })
|
|
96
96
|
}
|
|
@@ -103,12 +103,12 @@ function S({
|
|
|
103
103
|
disabled: e <= 1,
|
|
104
104
|
onClick: () => {
|
|
105
105
|
const t = Math.max(e - 1, 1);
|
|
106
|
-
|
|
106
|
+
r(t), c(t);
|
|
107
107
|
},
|
|
108
108
|
children: /* @__PURE__ */ a(V, { size: 16 })
|
|
109
109
|
}
|
|
110
110
|
),
|
|
111
|
-
n === "full" && (
|
|
111
|
+
n === "full" && (l === "dropdown" ? /* @__PURE__ */ a(
|
|
112
112
|
P,
|
|
113
113
|
{
|
|
114
114
|
"aria-label": g.pageNumber,
|
|
@@ -116,7 +116,7 @@ function S({
|
|
|
116
116
|
value: e,
|
|
117
117
|
onValueChange: (t) => {
|
|
118
118
|
const u = t;
|
|
119
|
-
|
|
119
|
+
r(u), c(u);
|
|
120
120
|
},
|
|
121
121
|
children: Array.from({ length: i }, (t, u) => u + 1).map((t) => /* @__PURE__ */ a(P.Option, { value: t, children: t }, t))
|
|
122
122
|
}
|
|
@@ -132,12 +132,12 @@ function S({
|
|
|
132
132
|
},
|
|
133
133
|
onBlur: () => {
|
|
134
134
|
const t = y(s, 1, i);
|
|
135
|
-
|
|
135
|
+
r(t), c(t);
|
|
136
136
|
},
|
|
137
137
|
onKeyDown: (t) => {
|
|
138
138
|
if (t.key === "Enter") {
|
|
139
139
|
const u = y(s, 1, i);
|
|
140
|
-
|
|
140
|
+
r(u), c(u);
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
autoComplete: "off",
|
|
@@ -154,7 +154,7 @@ function S({
|
|
|
154
154
|
disabled: e === i,
|
|
155
155
|
onClick: () => {
|
|
156
156
|
const t = Math.min(e + 1, i);
|
|
157
|
-
|
|
157
|
+
r(t), c(t);
|
|
158
158
|
},
|
|
159
159
|
children: /* @__PURE__ */ a(U, { size: 16 })
|
|
160
160
|
}
|
|
@@ -166,7 +166,7 @@ function S({
|
|
|
166
166
|
"aria-label": g.lastPage,
|
|
167
167
|
disabled: e === i,
|
|
168
168
|
onClick: () => {
|
|
169
|
-
|
|
169
|
+
r(i), c(i);
|
|
170
170
|
},
|
|
171
171
|
children: /* @__PURE__ */ a(j, { size: 16 })
|
|
172
172
|
}
|
|
@@ -188,25 +188,25 @@ function z({ className: n }) {
|
|
|
188
188
|
z.displayName = "Pagination.Separator";
|
|
189
189
|
function L(n) {
|
|
190
190
|
const {
|
|
191
|
-
page:
|
|
191
|
+
page: l = 1,
|
|
192
192
|
perPage: o,
|
|
193
193
|
totalCount: e,
|
|
194
194
|
setPage: i,
|
|
195
|
-
children:
|
|
195
|
+
children: r,
|
|
196
196
|
className: s,
|
|
197
197
|
labels: c
|
|
198
|
-
} = n, g = "text" in n ? n.text : void 0, t = "controls" in n ? n.controls ??
|
|
198
|
+
} = n, g = "text" in n ? n.text : void 0, t = "controls" in n ? n.controls ?? x.controls : x.controls, [u, w] = T(1), M = N(
|
|
199
199
|
() => ({ ...K, ...c }),
|
|
200
200
|
[c]
|
|
201
201
|
);
|
|
202
202
|
B(() => {
|
|
203
|
-
w(
|
|
204
|
-
}, [
|
|
205
|
-
const f =
|
|
206
|
-
let h =
|
|
207
|
-
return Number.isNaN(h) && (h = 0), Number.isNaN(
|
|
208
|
-
}, [
|
|
209
|
-
page:
|
|
203
|
+
w(l);
|
|
204
|
+
}, [l]);
|
|
205
|
+
const f = N(() => {
|
|
206
|
+
let h = l * (o ?? 1) - (o ?? 0) + 1, b = Math.min(l * (o ?? 0), e ?? 0);
|
|
207
|
+
return Number.isNaN(h) && (h = 0), Number.isNaN(b) && (b = 0), `${h}-${b}`;
|
|
208
|
+
}, [l, o, e]), _ = N(() => Math.ceil((e ?? 1) / (o ?? 1)), [e, o]), I = {
|
|
209
|
+
page: l,
|
|
210
210
|
perPage: o,
|
|
211
211
|
totalCount: e,
|
|
212
212
|
maxPage: _,
|
|
@@ -216,16 +216,16 @@ function L(n) {
|
|
|
216
216
|
setEditingPage: w,
|
|
217
217
|
labels: M
|
|
218
218
|
};
|
|
219
|
-
if (
|
|
219
|
+
if (r)
|
|
220
220
|
return /* @__PURE__ */ a(v.Provider, { value: I, children: /* @__PURE__ */ a(
|
|
221
221
|
"div",
|
|
222
222
|
{
|
|
223
223
|
"data-slot": "pagination",
|
|
224
224
|
className: d("flex items-center gap-2 w-full", s),
|
|
225
|
-
children:
|
|
225
|
+
children: r
|
|
226
226
|
}
|
|
227
227
|
) });
|
|
228
|
-
const O = () => g ? g({ page:
|
|
228
|
+
const O = () => g ? g({ page: l, perPage: o, totalCount: e, pageShowingRange: f }) : e && e > 0 ? /* @__PURE__ */ p(E, { children: [
|
|
229
229
|
"Showing ",
|
|
230
230
|
/* @__PURE__ */ a("span", { className: "tabular-nums", children: f }),
|
|
231
231
|
" of",
|
|
@@ -244,7 +244,7 @@ function L(n) {
|
|
|
244
244
|
"aria-live": "polite",
|
|
245
245
|
"aria-atomic": "true",
|
|
246
246
|
"data-slot": "pagination-info",
|
|
247
|
-
className: "grow text-sm text-kumo-
|
|
247
|
+
className: "grow text-sm text-kumo-subtle",
|
|
248
248
|
children: O()
|
|
249
249
|
}
|
|
250
250
|
),
|
|
@@ -263,4 +263,4 @@ const W = Object.assign(L, {
|
|
|
263
263
|
export {
|
|
264
264
|
W as P
|
|
265
265
|
};
|
|
266
|
-
//# sourceMappingURL=pagination-
|
|
266
|
+
//# sourceMappingURL=pagination-jb3mncivbwsoi1se.js.map
|
package/dist/chunks/{pagination-ho8zesqfyp6ckmrl.js.map → pagination-jb3mncivbwsoi1se.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination-ho8zesqfyp6ckmrl.js","sources":["../../src/components/pagination/pagination.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\nimport { InputGroup } from \"../input-group\";\nimport {\n CaretDoubleLeftIcon,\n CaretDoubleRightIcon,\n CaretLeftIcon,\n CaretRightIcon,\n} from \"@phosphor-icons/react\";\nimport { cn } from \"../../utils/cn\";\nimport { Select } from \"../select\";\n\nconst DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100, 250] as const;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max);\n\n// ============================================================================\n// i18n Labels\n// ============================================================================\n\n/**\n * Labels for internationalization of Pagination component.\n * All labels have English defaults and can be overridden for other locales.\n *\n * Note: To customize the \"Showing X-Y of Z\" text, use the `children` render prop\n * on `Pagination.Info` instead. To customize the \"Per page:\" label, use the\n * `label` prop on `Pagination.PageSize`.\n */\nexport interface PaginationLabels {\n /** Aria label for the navigation landmark. @default \"Pagination\" */\n navigation?: string;\n /** Aria label for the first page button. @default \"First page\" */\n firstPage?: string;\n /** Aria label for the previous page button. @default \"Previous page\" */\n previousPage?: string;\n /** Aria label for the next page button. @default \"Next page\" */\n nextPage?: string;\n /** Aria label for the last page button. @default \"Last page\" */\n lastPage?: string;\n /** Aria label for the page number input/select. @default \"Page number\" */\n pageNumber?: string;\n /** Aria label for the page size select. @default \"Page size\" */\n pageSize?: string;\n}\n\nconst DEFAULT_LABELS: Required<PaginationLabels> = {\n navigation: \"Pagination\",\n firstPage: \"First page\",\n previousPage: \"Previous page\",\n nextPage: \"Next page\",\n lastPage: \"Last page\",\n pageNumber: \"Page number\",\n pageSize: \"Page size\",\n};\n\n/** Pagination controls variant definitions. */\nexport const KUMO_PAGINATION_VARIANTS = {\n controls: {\n full: {\n classes: \"\",\n description:\n \"Full pagination controls with first, previous, page input, next, and last buttons\",\n },\n simple: {\n classes: \"\",\n description:\n \"Simple pagination controls with only previous and next buttons\",\n },\n },\n} as const;\n\nexport type KumoPaginationControls =\n keyof typeof KUMO_PAGINATION_VARIANTS.controls;\n\nexport const KUMO_PAGINATION_DEFAULT_VARIANTS = {\n controls: \"full\",\n} as const;\n\nexport interface KumoPaginationVariantsProps {\n controls?: KumoPaginationControls;\n}\n\nexport function paginationVariants({\n controls = KUMO_PAGINATION_DEFAULT_VARIANTS.controls,\n}: KumoPaginationVariantsProps = {}) {\n return cn(\n \"flex items-center justify-between gap-2\",\n KUMO_PAGINATION_VARIANTS.controls[controls].classes,\n );\n}\n\n// ============================================================================\n// Pagination Context\n// ============================================================================\n\ninterface PaginationContextValue {\n page: number;\n perPage?: number;\n totalCount?: number;\n maxPage: number;\n pageShowingRange: string;\n setPage: (page: number) => void;\n editingPage: number;\n setEditingPage: (page: number) => void;\n labels: Required<PaginationLabels>;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n const context = useContext(PaginationContext);\n if (!context) {\n throw new Error(\n \"Pagination compound components must be used within a Pagination component\",\n );\n }\n return context;\n}\n\n// ============================================================================\n// Pagination.Info\n// ============================================================================\n\nexport interface PaginationInfoProps {\n /** Custom render function for the info text */\n children?: (props: {\n page: number;\n perPage?: number;\n totalCount?: number;\n pageShowingRange: string;\n }) => ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationInfo({ children, className }: PaginationInfoProps) {\n const { page, perPage, totalCount, pageShowingRange } =\n usePaginationContext();\n\n const content = children ? (\n children({ page, perPage, totalCount, pageShowingRange })\n ) : totalCount && totalCount > 0 ? (\n <>\n Showing <span className=\"tabular-nums\">{pageShowingRange}</span> of{\" \"}\n <span className=\"tabular-nums\">{totalCount}</span>\n </>\n ) : null;\n\n return (\n <div\n data-slot=\"pagination-info\"\n className={cn(\"text-sm text-kumo-strong\", className)}\n >\n {content}\n </div>\n );\n}\n\nPaginationInfo.displayName = \"Pagination.Info\";\n\n// ============================================================================\n// Pagination.PageSize\n// ============================================================================\n\nexport interface PaginationPageSizeProps {\n /** Current page size value */\n value: number;\n /** Callback when page size changes */\n onChange: (size: number) => void;\n /** Available page size options */\n options?: number[];\n /**\n * Label text shown before the selector.\n * @default \"Per page:\"\n */\n label?: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationPageSize({\n value,\n onChange,\n options = DEFAULT_PAGE_SIZE_OPTIONS as unknown as number[],\n label = \"Per page:\",\n className,\n}: PaginationPageSizeProps) {\n const { labels } = usePaginationContext();\n\n return (\n <div\n data-slot=\"pagination-page-size\"\n className={cn(\"flex items-center gap-2\", className)}\n >\n {label && <span className=\"text-sm text-kumo-strong\">{label}</span>}\n <Select\n aria-label={labels.pageSize}\n value={value}\n onValueChange={(v) => onChange(v as number)}\n >\n {options.map((size) => (\n <Select.Option key={size} value={size}>\n {size}\n </Select.Option>\n ))}\n </Select>\n </div>\n );\n}\n\nPaginationPageSize.displayName = \"Pagination.PageSize\";\n\n// ============================================================================\n// Pagination.Controls\n// ============================================================================\n\nexport interface PaginationControlsProps extends KumoPaginationVariantsProps {\n /**\n * How the page number selector is rendered in \"full\" controls mode.\n * - `\"input\"` (default): A text input where users type a page number.\n * - `\"dropdown\"`: A dropdown select with all page numbers as options.\n *\n * **Note:** `\"dropdown\"` renders an option for every page, so it is best\n * suited for small page counts. For large datasets (hundreds of pages or\n * more) prefer `\"input\"` to avoid rendering performance overhead.\n */\n pageSelector?: \"input\" | \"dropdown\";\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationControls({\n controls = KUMO_PAGINATION_DEFAULT_VARIANTS.controls,\n pageSelector = \"input\",\n className,\n}: PaginationControlsProps) {\n const { page, maxPage, setPage, editingPage, setEditingPage, labels } =\n usePaginationContext();\n\n return (\n <div\n data-slot=\"pagination-controls\"\n className={cn(\"grow flex flex-col items-end\", className)}\n >\n <nav aria-label={labels.navigation}>\n <InputGroup>\n {controls === \"full\" && (\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.firstPage}\n disabled={page <= 1}\n onClick={() => {\n setPage(1);\n setEditingPage(1);\n }}\n >\n <CaretDoubleLeftIcon size={16} />\n </InputGroup.Button>\n )}\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.previousPage}\n disabled={page <= 1}\n onClick={() => {\n const previousPage = Math.max(page - 1, 1);\n setPage(previousPage);\n setEditingPage(previousPage);\n }}\n >\n <CaretLeftIcon size={16} />\n </InputGroup.Button>\n {controls === \"full\" &&\n (pageSelector === \"dropdown\" ? (\n <Select\n aria-label={labels.pageNumber}\n className=\"rounded-none ring-kumo-hairline\"\n value={page}\n onValueChange={(value) => {\n const num = value as number;\n setPage(num);\n setEditingPage(num);\n }}\n >\n {Array.from({ length: maxPage }, (_, i) => i + 1).map((p) => (\n <Select.Option key={p} value={p}>\n {p}\n </Select.Option>\n ))}\n </Select>\n ) : (\n <InputGroup.Input\n style={{ width: 50 }}\n className=\"text-center\"\n aria-label={labels.pageNumber}\n value={editingPage}\n onValueChange={(value: string) => {\n setEditingPage(Number(value));\n }}\n onBlur={() => {\n const clamped = clamp(editingPage, 1, maxPage);\n setPage(clamped);\n setEditingPage(clamped);\n }}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === \"Enter\") {\n const clamped = clamp(editingPage, 1, maxPage);\n setPage(clamped);\n setEditingPage(clamped);\n }\n }}\n // Prevent password managers from auto-filling\n autoComplete=\"off\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-form-type=\"other\"\n />\n ))}\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.nextPage}\n disabled={page === maxPage}\n onClick={() => {\n const nextPage = Math.min(page + 1, maxPage);\n setPage(nextPage);\n setEditingPage(nextPage);\n }}\n >\n <CaretRightIcon size={16} />\n </InputGroup.Button>\n {controls === \"full\" && (\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.lastPage}\n disabled={page === maxPage}\n onClick={() => {\n setPage(maxPage);\n setEditingPage(maxPage);\n }}\n >\n <CaretDoubleRightIcon size={16} />\n </InputGroup.Button>\n )}\n </InputGroup>\n </nav>\n </div>\n );\n}\n\nPaginationControls.displayName = \"Pagination.Controls\";\n\n// ============================================================================\n// Pagination.Separator\n// ============================================================================\n\nexport interface PaginationSeparatorProps {\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationSeparator({ className }: PaginationSeparatorProps) {\n return (\n <div\n data-slot=\"pagination-separator\"\n className={cn(\"mx-2 h-6 border-l border-kumo-hairline\", className)}\n />\n );\n}\n\nPaginationSeparator.displayName = \"Pagination.Separator\";\n\n// ============================================================================\n// Pagination Root\n// ============================================================================\n\n/** Base props shared by both compound and legacy Pagination APIs */\ninterface PaginationBaseProps {\n /** Callback fired when the current page changes. */\n setPage: (page: number) => void;\n /**\n * Current page number (1-indexed).\n * @default 1\n */\n page?: number;\n /** Number of items displayed per page. */\n perPage?: number;\n /** Total number of items across all pages. */\n totalCount?: number;\n /** Additional CSS classes for the container */\n className?: string;\n /**\n * Labels for internationalization of aria-labels. All labels have English defaults.\n *\n * For visible text like \"Showing X of Y\", use render props on sub-components:\n * - `Pagination.Info` children for the info text\n * - `Pagination.PageSize` label prop for the \"Per page:\" text\n *\n * @example\n * ```tsx\n * <Pagination\n * labels={{\n * firstPage: \"Première page\",\n * previousPage: \"Page précédente\",\n * nextPage: \"Page suivante\",\n * lastPage: \"Dernière page\",\n * pageNumber: \"Numéro de page\",\n * pageSize: \"Taille de page\",\n * }}\n * // ...\n * />\n * ```\n */\n labels?: PaginationLabels;\n}\n\n/**\n * Props for the compound component API (recommended).\n *\n * @example\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.PageSize value={perPage} onChange={setPerPage} />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n */\nexport interface PaginationCompoundProps extends PaginationBaseProps {\n /**\n * Compound component children for custom layouts.\n * Use Pagination.Info, Pagination.PageSize, Pagination.Controls, and Pagination.Separator.\n */\n children: ReactNode;\n controls?: never;\n text?: never;\n}\n\n/**\n * Props for the legacy API (deprecated, use compound components instead).\n *\n * @deprecated Use the compound component API with children instead:\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n *\n * @example\n * ```tsx\n * // Legacy usage (deprecated)\n * <Pagination page={page} setPage={setPage} perPage={10} totalCount={100} />\n * ```\n */\nexport interface PaginationLegacyProps\n extends PaginationBaseProps, KumoPaginationVariantsProps {\n children?: never;\n /** @deprecated Use Pagination.Info with children prop instead */\n text?: (props: {\n page?: number;\n perPage?: number;\n totalCount?: number;\n pageShowingRange: string;\n }) => ReactNode;\n}\n\n/**\n * Pagination component props.\n *\n * Prefer the compound component API for new code:\n * @example\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.PageSize value={perPage} onChange={setPerPage} />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n */\nexport type PaginationProps = PaginationCompoundProps | PaginationLegacyProps;\n\n/**\n * Page navigation controls with page count display.\n *\n * Supports both compound component and legacy patterns. Prefer compound components for new code:\n *\n * @example\n * // Compound component (recommended)\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.Separator />\n * <Pagination.PageSize value={perPage} onChange={setPerPage} />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n *\n * @example\n * // Legacy (deprecated)\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={10} totalCount={100} />\n * ```\n */\nfunction PaginationRoot(props: PaginationProps) {\n const {\n page = 1,\n perPage,\n totalCount,\n setPage,\n children,\n className,\n labels: labelsProp,\n } = props;\n\n // Extract legacy props (only present when children is not provided)\n const text = \"text\" in props ? props.text : undefined;\n const controls =\n \"controls\" in props\n ? (props.controls ?? KUMO_PAGINATION_DEFAULT_VARIANTS.controls)\n : KUMO_PAGINATION_DEFAULT_VARIANTS.controls;\n const [editingPage, setEditingPage] = useState<number>(1);\n\n // Merge provided labels with defaults\n const labels = useMemo<Required<PaginationLabels>>(\n () => ({ ...DEFAULT_LABELS, ...labelsProp }),\n [labelsProp],\n );\n\n useEffect(() => {\n setEditingPage(page);\n }, [page]);\n\n const pageShowingRange = useMemo(() => {\n let lower = page * (perPage ?? 1) - (perPage ?? 0) + 1;\n let upper = Math.min(page * (perPage ?? 0), totalCount ?? 0);\n\n if (Number.isNaN(lower)) lower = 0;\n if (Number.isNaN(upper)) upper = 0;\n\n return `${lower}-${upper}`;\n }, [page, perPage, totalCount]);\n\n const maxPage = useMemo(() => {\n return Math.ceil((totalCount ?? 1) / (perPage ?? 1));\n }, [totalCount, perPage]);\n\n const contextValue: PaginationContextValue = {\n page,\n perPage,\n totalCount,\n maxPage,\n pageShowingRange,\n setPage,\n editingPage,\n setEditingPage,\n labels,\n };\n\n // Compound component mode: render children within context\n if (children) {\n return (\n <PaginationContext.Provider value={contextValue}>\n <div\n data-slot=\"pagination\"\n className={cn(\"flex items-center gap-2 w-full\", className)}\n >\n {children}\n </div>\n </PaginationContext.Provider>\n );\n }\n\n // Legacy mode: render default layout for backwards compatibility\n const getPaginationText = () => {\n if (text) {\n return text({ page, perPage, totalCount, pageShowingRange });\n } else if (totalCount && totalCount > 0) {\n return (\n <>\n Showing <span className=\"tabular-nums\">{pageShowingRange}</span> of{\" \"}\n <span className=\"tabular-nums\">{totalCount}</span>\n </>\n );\n }\n return null;\n };\n\n return (\n <PaginationContext.Provider value={contextValue}>\n <div\n data-slot=\"pagination\"\n className={cn(\"flex items-center gap-2 w-full\", className)}\n >\n <div\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-slot=\"pagination-info\"\n className=\"grow text-sm text-kumo-strong\"\n >\n {getPaginationText()}\n </div>\n <PaginationControls controls={controls} />\n </div>\n </PaginationContext.Provider>\n );\n}\n\nPaginationRoot.displayName = \"Pagination\";\n\n// ============================================================================\n// Compound Component Export\n// ============================================================================\n\nexport const Pagination = Object.assign(PaginationRoot, {\n Info: PaginationInfo,\n PageSize: PaginationPageSize,\n Controls: PaginationControls,\n Separator: PaginationSeparator,\n});\n\nexport {\n PaginationInfo,\n PaginationPageSize,\n PaginationControls,\n PaginationSeparator,\n};\n"],"names":["DEFAULT_PAGE_SIZE_OPTIONS","clamp","value","min","max","DEFAULT_LABELS","KUMO_PAGINATION_DEFAULT_VARIANTS","PaginationContext","createContext","usePaginationContext","context","useContext","PaginationInfo","children","className","page","perPage","totalCount","pageShowingRange","content","jsxs","Fragment","jsx","cn","PaginationPageSize","onChange","options","label","labels","Select","v","size","PaginationControls","controls","pageSelector","maxPage","setPage","editingPage","setEditingPage","InputGroup","CaretDoubleLeftIcon","previousPage","CaretLeftIcon","num","_","i","p","clamped","e","nextPage","CaretRightIcon","CaretDoubleRightIcon","PaginationSeparator","PaginationRoot","props","labelsProp","text","useState","useMemo","useEffect","lower","upper","contextValue","getPaginationText","Pagination"],"mappings":";;;;;;;AAmBA,MAAMA,IAA4B,CAAC,IAAI,IAAI,KAAK,GAAG,GAE7CC,IAAQ,CAACC,GAAeC,GAAaC,MACzC,KAAK,IAAI,KAAK,IAAIF,GAAOC,CAAG,GAAGC,CAAG,GA+B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,QACV,WAAWC,EAAG,kCAAkCT,CAAS;AAAA,QAExD,UAAAD;AAAA,MAAA;AAAA,IAAA,GAEL;AAKJ,QAAMkD,IAAoB,MACpBP,IACKA,EAAK,EAAE,MAAAzC,GAAM,SAAAC,GAAS,YAAAC,GAAY,kBAAAC,GAAkB,IAClDD,KAAcA,IAAa,IAElC,gBAAAG,EAAAC,GAAA,EAAE,UAAA;AAAA,IAAA;AAAA,IACQ,gBAAAC,EAAC,QAAA,EAAK,WAAU,gBAAgB,UAAAJ,GAAiB;AAAA,IAAO;AAAA,IAAI;AAAA,IACpE,gBAAAI,EAAC,QAAA,EAAK,WAAU,gBAAgB,UAAAL,EAAA,CAAW;AAAA,EAAA,GAC7C,IAGG;AAGT,SACE,gBAAAK,EAACf,EAAkB,UAAlB,EAA2B,OAAOuD,GACjC,UAAA,gBAAA1C;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWG,EAAG,kCAAkCT,CAAS;AAAA,MAEzD,UAAA;AAAA,QAAA,gBAAAQ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,aAAU;AAAA,YACV,eAAY;AAAA,YACZ,aAAU;AAAA,YACV,WAAU;AAAA,YAET,UAAAyC,EAAA;AAAA,UAAkB;AAAA,QAAA;AAAA,QAErB,gBAAAzC,EAACU,KAAmB,UAAAC,EAAA,CAAoB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAE5C;AAEJ;AAEAoB,EAAe,cAAc;AAMtB,MAAMW,IAAa,OAAO,OAAOX,GAAgB;AAAA,EACtD,MAAMzC;AAAA,EACN,UAAUY;AAAA,EACV,UAAUQ;AAAA,EACV,WAAWoB;AACb,CAAC;"}
|
|
1
|
+
{"version":3,"file":"pagination-jb3mncivbwsoi1se.js","sources":["../../src/components/pagination/pagination.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\nimport { InputGroup } from \"../input-group\";\nimport {\n CaretDoubleLeftIcon,\n CaretDoubleRightIcon,\n CaretLeftIcon,\n CaretRightIcon,\n} from \"@phosphor-icons/react\";\nimport { cn } from \"../../utils/cn\";\nimport { Select } from \"../select\";\n\nconst DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100, 250] as const;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max);\n\n// ============================================================================\n// i18n Labels\n// ============================================================================\n\n/**\n * Labels for internationalization of Pagination component.\n * All labels have English defaults and can be overridden for other locales.\n *\n * Note: To customize the \"Showing X-Y of Z\" text, use the `children` render prop\n * on `Pagination.Info` instead. To customize the \"Per page:\" label, use the\n * `label` prop on `Pagination.PageSize`.\n */\nexport interface PaginationLabels {\n /** Aria label for the navigation landmark. @default \"Pagination\" */\n navigation?: string;\n /** Aria label for the first page button. @default \"First page\" */\n firstPage?: string;\n /** Aria label for the previous page button. @default \"Previous page\" */\n previousPage?: string;\n /** Aria label for the next page button. @default \"Next page\" */\n nextPage?: string;\n /** Aria label for the last page button. @default \"Last page\" */\n lastPage?: string;\n /** Aria label for the page number input/select. @default \"Page number\" */\n pageNumber?: string;\n /** Aria label for the page size select. @default \"Page size\" */\n pageSize?: string;\n}\n\nconst DEFAULT_LABELS: Required<PaginationLabels> = {\n navigation: \"Pagination\",\n firstPage: \"First page\",\n previousPage: \"Previous page\",\n nextPage: \"Next page\",\n lastPage: \"Last page\",\n pageNumber: \"Page number\",\n pageSize: \"Page size\",\n};\n\n/** Pagination controls variant definitions. */\nexport const KUMO_PAGINATION_VARIANTS = {\n controls: {\n full: {\n classes: \"\",\n description:\n \"Full pagination controls with first, previous, page input, next, and last buttons\",\n },\n simple: {\n classes: \"\",\n description:\n \"Simple pagination controls with only previous and next buttons\",\n },\n },\n} as const;\n\nexport type KumoPaginationControls =\n keyof typeof KUMO_PAGINATION_VARIANTS.controls;\n\nexport const KUMO_PAGINATION_DEFAULT_VARIANTS = {\n controls: \"full\",\n} as const;\n\nexport interface KumoPaginationVariantsProps {\n controls?: KumoPaginationControls;\n}\n\nexport function paginationVariants({\n controls = KUMO_PAGINATION_DEFAULT_VARIANTS.controls,\n}: KumoPaginationVariantsProps = {}) {\n return cn(\n \"flex items-center justify-between gap-2\",\n KUMO_PAGINATION_VARIANTS.controls[controls].classes,\n );\n}\n\n// ============================================================================\n// Pagination Context\n// ============================================================================\n\ninterface PaginationContextValue {\n page: number;\n perPage?: number;\n totalCount?: number;\n maxPage: number;\n pageShowingRange: string;\n setPage: (page: number) => void;\n editingPage: number;\n setEditingPage: (page: number) => void;\n labels: Required<PaginationLabels>;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n const context = useContext(PaginationContext);\n if (!context) {\n throw new Error(\n \"Pagination compound components must be used within a Pagination component\",\n );\n }\n return context;\n}\n\n// ============================================================================\n// Pagination.Info\n// ============================================================================\n\nexport interface PaginationInfoProps {\n /** Custom render function for the info text */\n children?: (props: {\n page: number;\n perPage?: number;\n totalCount?: number;\n pageShowingRange: string;\n }) => ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationInfo({ children, className }: PaginationInfoProps) {\n const { page, perPage, totalCount, pageShowingRange } =\n usePaginationContext();\n\n const content = children ? (\n children({ page, perPage, totalCount, pageShowingRange })\n ) : totalCount && totalCount > 0 ? (\n <>\n Showing <span className=\"tabular-nums\">{pageShowingRange}</span> of{\" \"}\n <span className=\"tabular-nums\">{totalCount}</span>\n </>\n ) : null;\n\n return (\n <div\n data-slot=\"pagination-info\"\n className={cn(\"text-sm text-kumo-subtle\", className)}\n >\n {content}\n </div>\n );\n}\n\nPaginationInfo.displayName = \"Pagination.Info\";\n\n// ============================================================================\n// Pagination.PageSize\n// ============================================================================\n\nexport interface PaginationPageSizeProps {\n /** Current page size value */\n value: number;\n /** Callback when page size changes */\n onChange: (size: number) => void;\n /** Available page size options */\n options?: number[];\n /**\n * Label text shown before the selector.\n * @default \"Per page:\"\n */\n label?: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationPageSize({\n value,\n onChange,\n options = DEFAULT_PAGE_SIZE_OPTIONS as unknown as number[],\n label = \"Per page:\",\n className,\n}: PaginationPageSizeProps) {\n const { labels } = usePaginationContext();\n\n return (\n <div\n data-slot=\"pagination-page-size\"\n className={cn(\"flex items-center gap-2\", className)}\n >\n {label && <span className=\"text-sm text-kumo-subtle\">{label}</span>}\n <Select\n aria-label={labels.pageSize}\n value={value}\n onValueChange={(v) => onChange(v as number)}\n >\n {options.map((size) => (\n <Select.Option key={size} value={size}>\n {size}\n </Select.Option>\n ))}\n </Select>\n </div>\n );\n}\n\nPaginationPageSize.displayName = \"Pagination.PageSize\";\n\n// ============================================================================\n// Pagination.Controls\n// ============================================================================\n\nexport interface PaginationControlsProps extends KumoPaginationVariantsProps {\n /**\n * How the page number selector is rendered in \"full\" controls mode.\n * - `\"input\"` (default): A text input where users type a page number.\n * - `\"dropdown\"`: A dropdown select with all page numbers as options.\n *\n * **Note:** `\"dropdown\"` renders an option for every page, so it is best\n * suited for small page counts. For large datasets (hundreds of pages or\n * more) prefer `\"input\"` to avoid rendering performance overhead.\n */\n pageSelector?: \"input\" | \"dropdown\";\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationControls({\n controls = KUMO_PAGINATION_DEFAULT_VARIANTS.controls,\n pageSelector = \"input\",\n className,\n}: PaginationControlsProps) {\n const { page, maxPage, setPage, editingPage, setEditingPage, labels } =\n usePaginationContext();\n\n return (\n <div\n data-slot=\"pagination-controls\"\n className={cn(\"grow flex flex-col items-end\", className)}\n >\n <nav aria-label={labels.navigation}>\n <InputGroup>\n {controls === \"full\" && (\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.firstPage}\n disabled={page <= 1}\n onClick={() => {\n setPage(1);\n setEditingPage(1);\n }}\n >\n <CaretDoubleLeftIcon size={16} />\n </InputGroup.Button>\n )}\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.previousPage}\n disabled={page <= 1}\n onClick={() => {\n const previousPage = Math.max(page - 1, 1);\n setPage(previousPage);\n setEditingPage(previousPage);\n }}\n >\n <CaretLeftIcon size={16} />\n </InputGroup.Button>\n {controls === \"full\" &&\n (pageSelector === \"dropdown\" ? (\n <Select\n aria-label={labels.pageNumber}\n className=\"rounded-none ring-kumo-hairline\"\n value={page}\n onValueChange={(value) => {\n const num = value as number;\n setPage(num);\n setEditingPage(num);\n }}\n >\n {Array.from({ length: maxPage }, (_, i) => i + 1).map((p) => (\n <Select.Option key={p} value={p}>\n {p}\n </Select.Option>\n ))}\n </Select>\n ) : (\n <InputGroup.Input\n style={{ width: 50 }}\n className=\"text-center\"\n aria-label={labels.pageNumber}\n value={editingPage}\n onValueChange={(value: string) => {\n setEditingPage(Number(value));\n }}\n onBlur={() => {\n const clamped = clamp(editingPage, 1, maxPage);\n setPage(clamped);\n setEditingPage(clamped);\n }}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === \"Enter\") {\n const clamped = clamp(editingPage, 1, maxPage);\n setPage(clamped);\n setEditingPage(clamped);\n }\n }}\n // Prevent password managers from auto-filling\n autoComplete=\"off\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-form-type=\"other\"\n />\n ))}\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.nextPage}\n disabled={page === maxPage}\n onClick={() => {\n const nextPage = Math.min(page + 1, maxPage);\n setPage(nextPage);\n setEditingPage(nextPage);\n }}\n >\n <CaretRightIcon size={16} />\n </InputGroup.Button>\n {controls === \"full\" && (\n <InputGroup.Button\n variant=\"secondary\"\n aria-label={labels.lastPage}\n disabled={page === maxPage}\n onClick={() => {\n setPage(maxPage);\n setEditingPage(maxPage);\n }}\n >\n <CaretDoubleRightIcon size={16} />\n </InputGroup.Button>\n )}\n </InputGroup>\n </nav>\n </div>\n );\n}\n\nPaginationControls.displayName = \"Pagination.Controls\";\n\n// ============================================================================\n// Pagination.Separator\n// ============================================================================\n\nexport interface PaginationSeparatorProps {\n /** Additional CSS classes */\n className?: string;\n}\n\nfunction PaginationSeparator({ className }: PaginationSeparatorProps) {\n return (\n <div\n data-slot=\"pagination-separator\"\n className={cn(\"mx-2 h-6 border-l border-kumo-hairline\", className)}\n />\n );\n}\n\nPaginationSeparator.displayName = \"Pagination.Separator\";\n\n// ============================================================================\n// Pagination Root\n// ============================================================================\n\n/** Base props shared by both compound and legacy Pagination APIs */\ninterface PaginationBaseProps {\n /** Callback fired when the current page changes. */\n setPage: (page: number) => void;\n /**\n * Current page number (1-indexed).\n * @default 1\n */\n page?: number;\n /** Number of items displayed per page. */\n perPage?: number;\n /** Total number of items across all pages. */\n totalCount?: number;\n /** Additional CSS classes for the container */\n className?: string;\n /**\n * Labels for internationalization of aria-labels. All labels have English defaults.\n *\n * For visible text like \"Showing X of Y\", use render props on sub-components:\n * - `Pagination.Info` children for the info text\n * - `Pagination.PageSize` label prop for the \"Per page:\" text\n *\n * @example\n * ```tsx\n * <Pagination\n * labels={{\n * firstPage: \"Première page\",\n * previousPage: \"Page précédente\",\n * nextPage: \"Page suivante\",\n * lastPage: \"Dernière page\",\n * pageNumber: \"Numéro de page\",\n * pageSize: \"Taille de page\",\n * }}\n * // ...\n * />\n * ```\n */\n labels?: PaginationLabels;\n}\n\n/**\n * Props for the compound component API (recommended).\n *\n * @example\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.PageSize value={perPage} onChange={setPerPage} />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n */\nexport interface PaginationCompoundProps extends PaginationBaseProps {\n /**\n * Compound component children for custom layouts.\n * Use Pagination.Info, Pagination.PageSize, Pagination.Controls, and Pagination.Separator.\n */\n children: ReactNode;\n controls?: never;\n text?: never;\n}\n\n/**\n * Props for the legacy API (deprecated, use compound components instead).\n *\n * @deprecated Use the compound component API with children instead:\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n *\n * @example\n * ```tsx\n * // Legacy usage (deprecated)\n * <Pagination page={page} setPage={setPage} perPage={10} totalCount={100} />\n * ```\n */\nexport interface PaginationLegacyProps\n extends PaginationBaseProps, KumoPaginationVariantsProps {\n children?: never;\n /** @deprecated Use Pagination.Info with children prop instead */\n text?: (props: {\n page?: number;\n perPage?: number;\n totalCount?: number;\n pageShowingRange: string;\n }) => ReactNode;\n}\n\n/**\n * Pagination component props.\n *\n * Prefer the compound component API for new code:\n * @example\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.PageSize value={perPage} onChange={setPerPage} />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n */\nexport type PaginationProps = PaginationCompoundProps | PaginationLegacyProps;\n\n/**\n * Page navigation controls with page count display.\n *\n * Supports both compound component and legacy patterns. Prefer compound components for new code:\n *\n * @example\n * // Compound component (recommended)\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={perPage} totalCount={500}>\n * <Pagination.Info />\n * <Pagination.Separator />\n * <Pagination.PageSize value={perPage} onChange={setPerPage} />\n * <Pagination.Controls />\n * </Pagination>\n * ```\n *\n * @example\n * // Legacy (deprecated)\n * ```tsx\n * <Pagination page={page} setPage={setPage} perPage={10} totalCount={100} />\n * ```\n */\nfunction PaginationRoot(props: PaginationProps) {\n const {\n page = 1,\n perPage,\n totalCount,\n setPage,\n children,\n className,\n labels: labelsProp,\n } = props;\n\n // Extract legacy props (only present when children is not provided)\n const text = \"text\" in props ? props.text : undefined;\n const controls =\n \"controls\" in props\n ? (props.controls ?? KUMO_PAGINATION_DEFAULT_VARIANTS.controls)\n : KUMO_PAGINATION_DEFAULT_VARIANTS.controls;\n const [editingPage, setEditingPage] = useState<number>(1);\n\n // Merge provided labels with defaults\n const labels = useMemo<Required<PaginationLabels>>(\n () => ({ ...DEFAULT_LABELS, ...labelsProp }),\n [labelsProp],\n );\n\n useEffect(() => {\n setEditingPage(page);\n }, [page]);\n\n const pageShowingRange = useMemo(() => {\n let lower = page * (perPage ?? 1) - (perPage ?? 0) + 1;\n let upper = Math.min(page * (perPage ?? 0), totalCount ?? 0);\n\n if (Number.isNaN(lower)) lower = 0;\n if (Number.isNaN(upper)) upper = 0;\n\n return `${lower}-${upper}`;\n }, [page, perPage, totalCount]);\n\n const maxPage = useMemo(() => {\n return Math.ceil((totalCount ?? 1) / (perPage ?? 1));\n }, [totalCount, perPage]);\n\n const contextValue: PaginationContextValue = {\n page,\n perPage,\n totalCount,\n maxPage,\n pageShowingRange,\n setPage,\n editingPage,\n setEditingPage,\n labels,\n };\n\n // Compound component mode: render children within context\n if (children) {\n return (\n <PaginationContext.Provider value={contextValue}>\n <div\n data-slot=\"pagination\"\n className={cn(\"flex items-center gap-2 w-full\", className)}\n >\n {children}\n </div>\n </PaginationContext.Provider>\n );\n }\n\n // Legacy mode: render default layout for backwards compatibility\n const getPaginationText = () => {\n if (text) {\n return text({ page, perPage, totalCount, pageShowingRange });\n } else if (totalCount && totalCount > 0) {\n return (\n <>\n Showing <span className=\"tabular-nums\">{pageShowingRange}</span> of{\" \"}\n <span className=\"tabular-nums\">{totalCount}</span>\n </>\n );\n }\n return null;\n };\n\n return (\n <PaginationContext.Provider value={contextValue}>\n <div\n data-slot=\"pagination\"\n className={cn(\"flex items-center gap-2 w-full\", className)}\n >\n <div\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-slot=\"pagination-info\"\n className=\"grow text-sm text-kumo-subtle\"\n >\n {getPaginationText()}\n </div>\n <PaginationControls controls={controls} />\n </div>\n </PaginationContext.Provider>\n );\n}\n\nPaginationRoot.displayName = \"Pagination\";\n\n// ============================================================================\n// Compound Component Export\n// ============================================================================\n\nexport const Pagination = Object.assign(PaginationRoot, {\n Info: PaginationInfo,\n PageSize: PaginationPageSize,\n Controls: PaginationControls,\n Separator: PaginationSeparator,\n});\n\nexport {\n PaginationInfo,\n PaginationPageSize,\n PaginationControls,\n PaginationSeparator,\n};\n"],"names":["DEFAULT_PAGE_SIZE_OPTIONS","clamp","value","min","max","DEFAULT_LABELS","KUMO_PAGINATION_DEFAULT_VARIANTS","PaginationContext","createContext","usePaginationContext","context","useContext","PaginationInfo","children","className","page","perPage","totalCount","pageShowingRange","content","jsxs","Fragment","jsx","cn","PaginationPageSize","onChange","options","label","labels","Select","v","size","PaginationControls","controls","pageSelector","maxPage","setPage","editingPage","setEditingPage","InputGroup","CaretDoubleLeftIcon","previousPage","CaretLeftIcon","num","_","i","p","clamped","e","nextPage","CaretRightIcon","CaretDoubleRightIcon","PaginationSeparator","PaginationRoot","props","labelsProp","text","useState","useMemo","useEffect","lower","upper","contextValue","getPaginationText","Pagination"],"mappings":";;;;;;;AAmBA,MAAMA,IAA4B,CAAC,IAAI,IAAI,KAAK,GAAG,GAE7CC,IAAQ,CAACC,GAAeC,GAAaC,MACzC,KAAK,IAAI,KAAK,IAAIF,GAAOC,CAAG,GAAGC,CAAG,GA+B9BC,IAA6C;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AACZ,GAqBaC,IAAmC;AAAA,EAC9C,UAAU;AACZ,GA+BMC,IAAoBC,EAA6C,IAAI;AAE3E,SAASC,IAAuB;AAC9B,QAAMC,IAAUC,EAAWJ,CAAiB;AAC5C,MAAI,CAACG;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAGJ,SAAOA;AACT;AAkBA,SAASE,EAAe,EAAE,UAAAC,GAAU,WAAAC,KAAkC;AACpE,QAAM,EAAE,MAAAC,GAAM,SAAAC,GAAS,YAAAC,GAAY,kBAAAC,EAAA,IACjCT,EAAA,GAEIU,IAAUN,IACdA,EAAS,EAAE,MAAAE,GAAM,SAAAC,GAAS,YAAAC,GAAY,kBAAAC,EAAA,CAAkB,IACtDD,KAAcA,IAAa,IAC7B,gBAAA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A,MAEzD,UAAA;AAAA,QAAA,gBAAAQ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,aAAU;AAAA,YACV,eAAY;AAAA,YACZ,aAAU;AAAA,YACV,WAAU;AAAA,YAET,UAAAyC,EAAA;AAAA,UAAkB;AAAA,QAAA;AAAA,QAErB,gBAAAzC,EAACU,KAAmB,UAAAC,EAAA,CAAoB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAE5C;AAEJ;AAEAoB,EAAe,cAAc;AAMtB,MAAMW,IAAa,OAAO,OAAOX,GAAgB;AAAA,EACtD,MAAMzC;AAAA,EACN,UAAUY;AAAA,EACV,UAAUQ;AAAA,EACV,WAAWoB;AACb,CAAC;"}
|
|
@@ -4,9 +4,9 @@ import { CaretUpDownIcon as R, CheckIcon as B } from "@phosphor-icons/react";
|
|
|
4
4
|
import { useId as W, forwardRef as p } from "react";
|
|
5
5
|
import { c as o } from "./cn-ct4n7r74mh8y0f48.js";
|
|
6
6
|
import { b as q } from "./button-6by9ntsa3nj553mq.js";
|
|
7
|
-
import { K as H } from "./input-
|
|
7
|
+
import { K as H } from "./input-ncfowphv81yq7fyy.js";
|
|
8
8
|
import { S as J } from "./skeleton-line-epxenksfesr2fkcv.js";
|
|
9
|
-
import { F as Q } from "./field-
|
|
9
|
+
import { F as Q } from "./field-c0wf94plit2gci59.js";
|
|
10
10
|
import { u as X } from "./portal-provider-hwmkdmkpvct0cb76.js";
|
|
11
11
|
import { a$ as Y, b0 as Z, b1 as ee, b2 as te, b3 as ae, b4 as se, b5 as le, b6 as oe, b7 as ie, b8 as ne, b9 as re, ba as ce, bb as de, S as ue } from "./vendor-base-ui-ie71jahf0czyf58j.js";
|
|
12
12
|
H.size;
|
|
@@ -212,4 +212,4 @@ d.Option.displayName = "Select.Option";
|
|
|
212
212
|
export {
|
|
213
213
|
d as S
|
|
214
214
|
};
|
|
215
|
-
//# sourceMappingURL=select-
|
|
215
|
+
//# sourceMappingURL=select-g261chvosodu22i8.js.map
|