@spark-ui/components 10.9.0 → 10.10.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/CHANGELOG.md +6 -0
- package/dist/accordion/index.d.mts +13 -25
- package/dist/accordion/index.d.ts +13 -25
- package/dist/accordion/index.js +114 -250
- package/dist/accordion/index.js.map +1 -1
- package/dist/accordion/index.mjs +92 -134
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/collapsible/index.d.mts +18 -35
- package/dist/collapsible/index.d.ts +18 -35
- package/dist/collapsible/index.js +47 -78
- package/dist/collapsible/index.js.map +1 -1
- package/dist/collapsible/index.mjs +73 -4
- package/dist/collapsible/index.mjs.map +1 -1
- package/package.json +6 -7
- package/dist/chunk-3LEFXZNI.mjs +0 -97
- package/dist/chunk-3LEFXZNI.mjs.map +0 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,27 +15,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/collapsible/index.ts
|
|
31
21
|
var collapsible_exports = {};
|
|
32
22
|
__export(collapsible_exports, {
|
|
33
|
-
Collapsible: () =>
|
|
23
|
+
Collapsible: () => Collapsible4
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(collapsible_exports);
|
|
36
26
|
|
|
37
|
-
// src/collapsible/
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var import_react3 = require("react");
|
|
27
|
+
// src/collapsible/Content.tsx
|
|
28
|
+
var import_collapsible = require("@base-ui-components/react/collapsible");
|
|
29
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
41
30
|
|
|
42
31
|
// src/slot/Slot.tsx
|
|
43
32
|
var import_radix_ui = require("radix-ui");
|
|
@@ -48,89 +37,69 @@ var Slot = ({ ref, ...props }) => {
|
|
|
48
37
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
|
|
49
38
|
};
|
|
50
39
|
|
|
51
|
-
// src/collapsible/
|
|
40
|
+
// src/collapsible/useRenderSlot.tsx
|
|
52
41
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
asChild
|
|
56
|
-
|
|
57
|
-
defaultOpen = false,
|
|
58
|
-
disabled = false,
|
|
59
|
-
onOpenChange,
|
|
60
|
-
open,
|
|
61
|
-
ids,
|
|
62
|
-
ref,
|
|
63
|
-
...props
|
|
64
|
-
}) => {
|
|
65
|
-
const service = (0, import_react2.useMachine)(collapsible.machine, {
|
|
66
|
-
open,
|
|
67
|
-
defaultOpen,
|
|
68
|
-
disabled,
|
|
69
|
-
id: (0, import_react3.useId)(),
|
|
70
|
-
ids,
|
|
71
|
-
onOpenChange(details) {
|
|
72
|
-
onOpenChange?.(details.open);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const api = collapsible.connect(service, import_react2.normalizeProps);
|
|
76
|
-
const Component = asChild ? Slot : "div";
|
|
77
|
-
const mergedProps = (0, import_react2.mergeProps)(api.getRootProps(), props);
|
|
78
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CollapsibleContext.Provider, { value: api, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { "data-spark-component": "collapsible", ref, ...mergedProps, children }) });
|
|
79
|
-
};
|
|
80
|
-
Collapsible.displayName = "Collapsible";
|
|
81
|
-
var useCollapsibleContext = () => {
|
|
82
|
-
const context = (0, import_react3.useContext)(CollapsibleContext);
|
|
83
|
-
if (!context) {
|
|
84
|
-
throw Error("useCollapsibleContext must be used within a Collapsible provider");
|
|
85
|
-
}
|
|
86
|
-
return context;
|
|
87
|
-
};
|
|
42
|
+
function useRenderSlot(asChild, defaultTag) {
|
|
43
|
+
const Component = asChild ? Slot : defaultTag;
|
|
44
|
+
return asChild ? ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { ...props }) : void 0;
|
|
45
|
+
}
|
|
88
46
|
|
|
89
|
-
// src/collapsible/
|
|
90
|
-
var import_react4 = require("@zag-js/react");
|
|
91
|
-
var import_class_variance_authority = require("class-variance-authority");
|
|
47
|
+
// src/collapsible/Content.tsx
|
|
92
48
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
93
49
|
var Content = ({
|
|
94
50
|
asChild = false,
|
|
95
51
|
className,
|
|
96
52
|
children,
|
|
97
|
-
|
|
53
|
+
hiddenUntilFound = true,
|
|
98
54
|
...props
|
|
99
55
|
}) => {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
56
|
+
const renderSlot = useRenderSlot(asChild, "div");
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
58
|
+
import_collapsible.Collapsible.Panel,
|
|
59
|
+
{
|
|
60
|
+
"data-spark-component": "collapsible-content",
|
|
61
|
+
className: (0, import_class_variance_authority.cx)(
|
|
62
|
+
"overflow-hidden",
|
|
63
|
+
"h-[var(--collapsible-panel-height)]",
|
|
64
|
+
"transition-all duration-200",
|
|
65
|
+
"motion-reduce:transition-none",
|
|
66
|
+
"data-[starting-style]:h-0",
|
|
67
|
+
"data-[ending-style]:h-0",
|
|
68
|
+
className
|
|
69
|
+
),
|
|
70
|
+
render: renderSlot,
|
|
71
|
+
hiddenUntilFound,
|
|
72
|
+
...props,
|
|
73
|
+
children
|
|
74
|
+
}
|
|
75
|
+
);
|
|
114
76
|
};
|
|
115
77
|
Content.displayName = "Collapsible.Content";
|
|
116
78
|
|
|
117
|
-
// src/collapsible/
|
|
118
|
-
var
|
|
79
|
+
// src/collapsible/Root.tsx
|
|
80
|
+
var import_collapsible2 = require("@base-ui-components/react/collapsible");
|
|
119
81
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
120
|
-
var
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
82
|
+
var Root = ({ asChild = false, children, ...props }) => {
|
|
83
|
+
const renderSlot = useRenderSlot(asChild, "div");
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_collapsible2.Collapsible.Root, { "data-spark-component": "collapsible", render: renderSlot, ...props, children });
|
|
85
|
+
};
|
|
86
|
+
Root.displayName = "Collapsible";
|
|
87
|
+
|
|
88
|
+
// src/collapsible/Trigger.tsx
|
|
89
|
+
var import_collapsible3 = require("@base-ui-components/react/collapsible");
|
|
90
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
91
|
+
var Trigger = ({ asChild = false, children, ...props }) => {
|
|
92
|
+
const renderSlot = useRenderSlot(asChild, "button");
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_collapsible3.Collapsible.Trigger, { "data-spark-component": "collapsible-trigger", render: renderSlot, ...props, children });
|
|
125
94
|
};
|
|
126
95
|
Trigger.displayName = "Collapsible.Trigger";
|
|
127
96
|
|
|
128
97
|
// src/collapsible/index.ts
|
|
129
|
-
var
|
|
98
|
+
var Collapsible4 = Object.assign(Root, {
|
|
130
99
|
Trigger,
|
|
131
100
|
Content
|
|
132
101
|
});
|
|
133
|
-
|
|
102
|
+
Collapsible4.displayName = "Collapsible";
|
|
134
103
|
Trigger.displayName = "Collapsible.Trigger";
|
|
135
104
|
Content.displayName = "Collapsible.Content";
|
|
136
105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collapsible/index.ts","../../src/collapsible/
|
|
1
|
+
{"version":3,"sources":["../../src/collapsible/index.ts","../../src/collapsible/Content.tsx","../../src/slot/Slot.tsx","../../src/collapsible/useRenderSlot.tsx","../../src/collapsible/Root.tsx","../../src/collapsible/Trigger.tsx"],"sourcesContent":["import { Content } from './Content'\nimport { Root } from './Root'\nimport { Trigger } from './Trigger'\n\nexport const Collapsible: typeof Root & {\n Trigger: typeof Trigger\n Content: typeof Content\n} = Object.assign(Root, {\n Trigger,\n Content,\n})\n\nCollapsible.displayName = 'Collapsible'\nTrigger.displayName = 'Collapsible.Trigger'\nContent.displayName = 'Collapsible.Content'\n","import { Collapsible } from '@base-ui-components/react/collapsible'\nimport { cx } from 'class-variance-authority'\nimport { type ComponentProps } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface ContentProps extends ComponentProps<typeof Collapsible.Panel> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Content = ({\n asChild = false,\n className,\n children,\n hiddenUntilFound = true,\n ...props\n}: ContentProps) => {\n const renderSlot = useRenderSlot(asChild, 'div')\n\n return (\n <Collapsible.Panel\n data-spark-component=\"collapsible-content\"\n className={cx(\n 'overflow-hidden',\n 'h-[var(--collapsible-panel-height)]',\n 'transition-all duration-200',\n 'motion-reduce:transition-none',\n 'data-[starting-style]:h-0',\n 'data-[ending-style]:h-0',\n className\n )}\n render={renderSlot}\n hiddenUntilFound={hiddenUntilFound}\n {...props}\n >\n {children}\n </Collapsible.Panel>\n )\n}\n\nContent.displayName = 'Collapsible.Content'\n","import { Slot as RadixSlot } from 'radix-ui'\nimport {\n cloneElement,\n HTMLAttributes,\n isValidElement,\n PropsWithChildren,\n ReactNode,\n Ref,\n} from 'react'\n\nexport const Slottable: typeof RadixSlot.Slottable = RadixSlot.Slottable\n\nexport type SlotProps = PropsWithChildren<HTMLAttributes<HTMLElement>> & {\n ref?: Ref<HTMLElement>\n}\n\nexport const Slot = ({ ref, ...props }: SlotProps) => {\n return <RadixSlot.Root ref={ref} {...props} />\n}\n\n/**\n * When using Radix `Slot` component, it will consider its first child to merge its props with.\n * In some cases, you might need to wrap the top child with additional markup without breaking this behaviour.\n */\nexport const wrapPolymorphicSlot = (\n asChild: boolean | undefined,\n children: ReactNode,\n callback: (children: ReactNode) => ReactNode\n) => {\n if (!asChild) return callback(children) // If polymorphic behaviour is not used, we keep the original children\n\n return isValidElement(children)\n ? cloneElement(\n children,\n undefined,\n callback((children.props as { children: ReactNode }).children)\n )\n : null\n}\n","import { Slot } from '../slot'\n\nexport function useRenderSlot(asChild: boolean, defaultTag: string) {\n const Component = asChild ? Slot : defaultTag\n\n return asChild ? ({ ...props }) => <Component {...props} /> : undefined\n}\n","import { Collapsible } from '@base-ui-components/react/collapsible'\nimport { type ComponentProps } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface RootProps extends ComponentProps<typeof Collapsible.Root> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Root = ({ asChild = false, children, ...props }: RootProps) => {\n const renderSlot = useRenderSlot(asChild, 'div')\n\n return (\n <Collapsible.Root data-spark-component=\"collapsible\" render={renderSlot} {...props}>\n {children}\n </Collapsible.Root>\n )\n}\n\nRoot.displayName = 'Collapsible'\n","import { Collapsible } from '@base-ui-components/react/collapsible'\nimport { type ComponentProps } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface TriggerProps extends ComponentProps<'button'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Trigger = ({ asChild = false, children, ...props }: TriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return (\n <Collapsible.Trigger data-spark-component=\"collapsible-trigger\" render={renderSlot} {...props}>\n {children}\n </Collapsible.Trigger>\n )\n}\n\nTrigger.displayName = 'Collapsible.Trigger'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,qBAAAA;AAAA;AAAA;;;ACAA,yBAA4B;AAC5B,sCAAmB;;;ACDnB,sBAAkC;AAClC,mBAOO;AASE;AAPF,IAAM,YAAwC,gBAAAC,KAAU;AAMxD,IAAM,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,MAAiB;AACpD,SAAO,4CAAC,gBAAAA,KAAU,MAAV,EAAe,KAAW,GAAG,OAAO;AAC9C;;;ACbqC,IAAAC,sBAAA;AAH9B,SAAS,cAAc,SAAkB,YAAoB;AAClE,QAAM,YAAY,UAAU,OAAO;AAEnC,SAAO,UAAU,CAAC,EAAE,GAAG,MAAM,MAAM,6CAAC,aAAW,GAAG,OAAO,IAAK;AAChE;;;AFiBI,IAAAC,sBAAA;AAVG,IAAM,UAAU,CAAC;AAAA,EACtB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,MAAoB;AAClB,QAAM,aAAa,cAAc,SAAS,KAAK;AAE/C,SACE;AAAA,IAAC,+BAAY;AAAA,IAAZ;AAAA,MACC,wBAAqB;AAAA,MACrB,eAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,QAAQ,cAAc;;;AG3CtB,IAAAC,sBAA4B;AAgBxB,IAAAC,sBAAA;AAJG,IAAM,OAAO,CAAC,EAAE,UAAU,OAAO,UAAU,GAAG,MAAM,MAAiB;AAC1E,QAAM,aAAa,cAAc,SAAS,KAAK;AAE/C,SACE,6CAAC,gCAAY,MAAZ,EAAiB,wBAAqB,eAAc,QAAQ,YAAa,GAAG,OAC1E,UACH;AAEJ;AAEA,KAAK,cAAc;;;ACtBnB,IAAAC,sBAA4B;AAgBxB,IAAAC,sBAAA;AAJG,IAAM,UAAU,CAAC,EAAE,UAAU,OAAO,UAAU,GAAG,MAAM,MAAoB;AAChF,QAAM,aAAa,cAAc,SAAS,QAAQ;AAElD,SACE,6CAAC,gCAAY,SAAZ,EAAoB,wBAAqB,uBAAsB,QAAQ,YAAa,GAAG,OACrF,UACH;AAEJ;AAEA,QAAQ,cAAc;;;ALlBf,IAAMC,eAGT,OAAO,OAAO,MAAM;AAAA,EACtB;AAAA,EACA;AACF,CAAC;AAEDA,aAAY,cAAc;AAC1B,QAAQ,cAAc;AACtB,QAAQ,cAAc;","names":["Collapsible","RadixSlot","import_jsx_runtime","import_jsx_runtime","import_collapsible","import_jsx_runtime","import_collapsible","import_jsx_runtime","Collapsible"]}
|
|
@@ -1,8 +1,77 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
|
|
2
|
+
Slot
|
|
3
|
+
} from "../chunk-6QCEPQ3U.mjs";
|
|
4
|
+
|
|
5
|
+
// src/collapsible/Content.tsx
|
|
6
|
+
import { Collapsible } from "@base-ui-components/react/collapsible";
|
|
7
|
+
import { cx } from "class-variance-authority";
|
|
8
|
+
|
|
9
|
+
// src/collapsible/useRenderSlot.tsx
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
function useRenderSlot(asChild, defaultTag) {
|
|
12
|
+
const Component = asChild ? Slot : defaultTag;
|
|
13
|
+
return asChild ? ({ ...props }) => /* @__PURE__ */ jsx(Component, { ...props }) : void 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/collapsible/Content.tsx
|
|
17
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
18
|
+
var Content = ({
|
|
19
|
+
asChild = false,
|
|
20
|
+
className,
|
|
21
|
+
children,
|
|
22
|
+
hiddenUntilFound = true,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
25
|
+
const renderSlot = useRenderSlot(asChild, "div");
|
|
26
|
+
return /* @__PURE__ */ jsx2(
|
|
27
|
+
Collapsible.Panel,
|
|
28
|
+
{
|
|
29
|
+
"data-spark-component": "collapsible-content",
|
|
30
|
+
className: cx(
|
|
31
|
+
"overflow-hidden",
|
|
32
|
+
"h-[var(--collapsible-panel-height)]",
|
|
33
|
+
"transition-all duration-200",
|
|
34
|
+
"motion-reduce:transition-none",
|
|
35
|
+
"data-[starting-style]:h-0",
|
|
36
|
+
"data-[ending-style]:h-0",
|
|
37
|
+
className
|
|
38
|
+
),
|
|
39
|
+
render: renderSlot,
|
|
40
|
+
hiddenUntilFound,
|
|
41
|
+
...props,
|
|
42
|
+
children
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
Content.displayName = "Collapsible.Content";
|
|
47
|
+
|
|
48
|
+
// src/collapsible/Root.tsx
|
|
49
|
+
import { Collapsible as Collapsible2 } from "@base-ui-components/react/collapsible";
|
|
50
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
51
|
+
var Root = ({ asChild = false, children, ...props }) => {
|
|
52
|
+
const renderSlot = useRenderSlot(asChild, "div");
|
|
53
|
+
return /* @__PURE__ */ jsx3(Collapsible2.Root, { "data-spark-component": "collapsible", render: renderSlot, ...props, children });
|
|
54
|
+
};
|
|
55
|
+
Root.displayName = "Collapsible";
|
|
56
|
+
|
|
57
|
+
// src/collapsible/Trigger.tsx
|
|
58
|
+
import { Collapsible as Collapsible3 } from "@base-ui-components/react/collapsible";
|
|
59
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
60
|
+
var Trigger = ({ asChild = false, children, ...props }) => {
|
|
61
|
+
const renderSlot = useRenderSlot(asChild, "button");
|
|
62
|
+
return /* @__PURE__ */ jsx4(Collapsible3.Trigger, { "data-spark-component": "collapsible-trigger", render: renderSlot, ...props, children });
|
|
63
|
+
};
|
|
64
|
+
Trigger.displayName = "Collapsible.Trigger";
|
|
65
|
+
|
|
66
|
+
// src/collapsible/index.ts
|
|
67
|
+
var Collapsible4 = Object.assign(Root, {
|
|
68
|
+
Trigger,
|
|
69
|
+
Content
|
|
70
|
+
});
|
|
71
|
+
Collapsible4.displayName = "Collapsible";
|
|
72
|
+
Trigger.displayName = "Collapsible.Trigger";
|
|
73
|
+
Content.displayName = "Collapsible.Content";
|
|
5
74
|
export {
|
|
6
|
-
Collapsible
|
|
75
|
+
Collapsible4 as Collapsible
|
|
7
76
|
};
|
|
8
77
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/collapsible/Content.tsx","../../src/collapsible/useRenderSlot.tsx","../../src/collapsible/Root.tsx","../../src/collapsible/Trigger.tsx","../../src/collapsible/index.ts"],"sourcesContent":["import { Collapsible } from '@base-ui-components/react/collapsible'\nimport { cx } from 'class-variance-authority'\nimport { type ComponentProps } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface ContentProps extends ComponentProps<typeof Collapsible.Panel> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Content = ({\n asChild = false,\n className,\n children,\n hiddenUntilFound = true,\n ...props\n}: ContentProps) => {\n const renderSlot = useRenderSlot(asChild, 'div')\n\n return (\n <Collapsible.Panel\n data-spark-component=\"collapsible-content\"\n className={cx(\n 'overflow-hidden',\n 'h-[var(--collapsible-panel-height)]',\n 'transition-all duration-200',\n 'motion-reduce:transition-none',\n 'data-[starting-style]:h-0',\n 'data-[ending-style]:h-0',\n className\n )}\n render={renderSlot}\n hiddenUntilFound={hiddenUntilFound}\n {...props}\n >\n {children}\n </Collapsible.Panel>\n )\n}\n\nContent.displayName = 'Collapsible.Content'\n","import { Slot } from '../slot'\n\nexport function useRenderSlot(asChild: boolean, defaultTag: string) {\n const Component = asChild ? Slot : defaultTag\n\n return asChild ? ({ ...props }) => <Component {...props} /> : undefined\n}\n","import { Collapsible } from '@base-ui-components/react/collapsible'\nimport { type ComponentProps } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface RootProps extends ComponentProps<typeof Collapsible.Root> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Root = ({ asChild = false, children, ...props }: RootProps) => {\n const renderSlot = useRenderSlot(asChild, 'div')\n\n return (\n <Collapsible.Root data-spark-component=\"collapsible\" render={renderSlot} {...props}>\n {children}\n </Collapsible.Root>\n )\n}\n\nRoot.displayName = 'Collapsible'\n","import { Collapsible } from '@base-ui-components/react/collapsible'\nimport { type ComponentProps } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface TriggerProps extends ComponentProps<'button'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Trigger = ({ asChild = false, children, ...props }: TriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return (\n <Collapsible.Trigger data-spark-component=\"collapsible-trigger\" render={renderSlot} {...props}>\n {children}\n </Collapsible.Trigger>\n )\n}\n\nTrigger.displayName = 'Collapsible.Trigger'\n","import { Content } from './Content'\nimport { Root } from './Root'\nimport { Trigger } from './Trigger'\n\nexport const Collapsible: typeof Root & {\n Trigger: typeof Trigger\n Content: typeof Content\n} = Object.assign(Root, {\n Trigger,\n Content,\n})\n\nCollapsible.displayName = 'Collapsible'\nTrigger.displayName = 'Collapsible.Trigger'\nContent.displayName = 'Collapsible.Content'\n"],"mappings":";;;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,UAAU;;;ACIkB;AAH9B,SAAS,cAAc,SAAkB,YAAoB;AAClE,QAAM,YAAY,UAAU,OAAO;AAEnC,SAAO,UAAU,CAAC,EAAE,GAAG,MAAM,MAAM,oBAAC,aAAW,GAAG,OAAO,IAAK;AAChE;;;ADiBI,gBAAAA,YAAA;AAVG,IAAM,UAAU,CAAC;AAAA,EACtB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,MAAoB;AAClB,QAAM,aAAa,cAAc,SAAS,KAAK;AAE/C,SACE,gBAAAA;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACC,wBAAqB;AAAA,MACrB,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,QAAQ,cAAc;;;AE3CtB,SAAS,eAAAC,oBAAmB;AAgBxB,gBAAAC,YAAA;AAJG,IAAM,OAAO,CAAC,EAAE,UAAU,OAAO,UAAU,GAAG,MAAM,MAAiB;AAC1E,QAAM,aAAa,cAAc,SAAS,KAAK;AAE/C,SACE,gBAAAA,KAACC,aAAY,MAAZ,EAAiB,wBAAqB,eAAc,QAAQ,YAAa,GAAG,OAC1E,UACH;AAEJ;AAEA,KAAK,cAAc;;;ACtBnB,SAAS,eAAAC,oBAAmB;AAgBxB,gBAAAC,YAAA;AAJG,IAAM,UAAU,CAAC,EAAE,UAAU,OAAO,UAAU,GAAG,MAAM,MAAoB;AAChF,QAAM,aAAa,cAAc,SAAS,QAAQ;AAElD,SACE,gBAAAA,KAACC,aAAY,SAAZ,EAAoB,wBAAqB,uBAAsB,QAAQ,YAAa,GAAG,OACrF,UACH;AAEJ;AAEA,QAAQ,cAAc;;;AClBf,IAAMC,eAGT,OAAO,OAAO,MAAM;AAAA,EACtB;AAAA,EACA;AACF,CAAC;AAEDA,aAAY,cAAc;AAC1B,QAAQ,cAAc;AACtB,QAAQ,cAAc;","names":["jsx","Collapsible","jsx","Collapsible","Collapsible","jsx","Collapsible","Collapsible"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-ui/components",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Spark (Leboncoin design system) components.",
|
|
6
6
|
"exports": {
|
|
@@ -44,16 +44,15 @@
|
|
|
44
44
|
"build": "NODE_OPTIONS='--max-old-space-size=8192' tsup"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@base-ui-components/react": "^1.0.0-beta.1",
|
|
47
48
|
"@react-aria/button": "3.13.0",
|
|
48
49
|
"@react-aria/numberfield": "3.11.13",
|
|
49
50
|
"@react-aria/toast": "^3.0.0-beta.18",
|
|
50
51
|
"@react-stately/numberfield": "3.9.11",
|
|
51
52
|
"@react-stately/toast": "^3.0.0-beta.7",
|
|
52
|
-
"@spark-ui/hooks": "^10.
|
|
53
|
-
"@spark-ui/icons": "^10.
|
|
54
|
-
"@spark-ui/internal-utils": "^10.
|
|
55
|
-
"@zag-js/accordion": "1.14.0",
|
|
56
|
-
"@zag-js/collapsible": "1.14.0",
|
|
53
|
+
"@spark-ui/hooks": "^10.10.0",
|
|
54
|
+
"@spark-ui/icons": "^10.10.0",
|
|
55
|
+
"@spark-ui/internal-utils": "^10.10.0",
|
|
57
56
|
"@zag-js/pagination": "1.14.0",
|
|
58
57
|
"@zag-js/react": "1.14.0",
|
|
59
58
|
"class-variance-authority": "0.7.1",
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
"url": "https://github.com/leboncoin/spark-web/issues?q=is%3Aopen+label%3A%22Component%3A+button%22"
|
|
81
80
|
},
|
|
82
81
|
"homepage": "https://sparkui.vercel.app",
|
|
83
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "15beb1b7b4c85542e622984cc8385f45e32e56d0"
|
|
84
83
|
}
|
package/dist/chunk-3LEFXZNI.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Slot
|
|
3
|
-
} from "./chunk-6QCEPQ3U.mjs";
|
|
4
|
-
|
|
5
|
-
// src/collapsible/Collapsible.tsx
|
|
6
|
-
import * as collapsible from "@zag-js/collapsible";
|
|
7
|
-
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
8
|
-
import { createContext, useContext, useId } from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
var CollapsibleContext = createContext(null);
|
|
11
|
-
var Collapsible = ({
|
|
12
|
-
asChild = false,
|
|
13
|
-
children,
|
|
14
|
-
defaultOpen = false,
|
|
15
|
-
disabled = false,
|
|
16
|
-
onOpenChange,
|
|
17
|
-
open,
|
|
18
|
-
ids,
|
|
19
|
-
ref,
|
|
20
|
-
...props
|
|
21
|
-
}) => {
|
|
22
|
-
const service = useMachine(collapsible.machine, {
|
|
23
|
-
open,
|
|
24
|
-
defaultOpen,
|
|
25
|
-
disabled,
|
|
26
|
-
id: useId(),
|
|
27
|
-
ids,
|
|
28
|
-
onOpenChange(details) {
|
|
29
|
-
onOpenChange?.(details.open);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const api = collapsible.connect(service, normalizeProps);
|
|
33
|
-
const Component = asChild ? Slot : "div";
|
|
34
|
-
const mergedProps = mergeProps(api.getRootProps(), props);
|
|
35
|
-
return /* @__PURE__ */ jsx(CollapsibleContext.Provider, { value: api, children: /* @__PURE__ */ jsx(Component, { "data-spark-component": "collapsible", ref, ...mergedProps, children }) });
|
|
36
|
-
};
|
|
37
|
-
Collapsible.displayName = "Collapsible";
|
|
38
|
-
var useCollapsibleContext = () => {
|
|
39
|
-
const context = useContext(CollapsibleContext);
|
|
40
|
-
if (!context) {
|
|
41
|
-
throw Error("useCollapsibleContext must be used within a Collapsible provider");
|
|
42
|
-
}
|
|
43
|
-
return context;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// src/collapsible/CollapsibleContent.tsx
|
|
47
|
-
import { mergeProps as mergeProps2 } from "@zag-js/react";
|
|
48
|
-
import { cx } from "class-variance-authority";
|
|
49
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
50
|
-
var Content = ({
|
|
51
|
-
asChild = false,
|
|
52
|
-
className,
|
|
53
|
-
children,
|
|
54
|
-
ref,
|
|
55
|
-
...props
|
|
56
|
-
}) => {
|
|
57
|
-
const { getContentProps } = useCollapsibleContext();
|
|
58
|
-
const Component = asChild ? Slot : "div";
|
|
59
|
-
const contentProps = getContentProps();
|
|
60
|
-
const mergedProps = mergeProps2(contentProps, {
|
|
61
|
-
className: cx(
|
|
62
|
-
"overflow-hidden",
|
|
63
|
-
"motion-reduce:animate-none!",
|
|
64
|
-
"[&[hidden]]:hidden",
|
|
65
|
-
"data-[state=open]:animate-standalone-collapse-in data-[state=closed]:animate-standalone-collapse-out",
|
|
66
|
-
className
|
|
67
|
-
),
|
|
68
|
-
...props
|
|
69
|
-
});
|
|
70
|
-
return /* @__PURE__ */ jsx2(Component, { ref, "data-spark-component": "collapsible-content", ...mergedProps, children });
|
|
71
|
-
};
|
|
72
|
-
Content.displayName = "Collapsible.Content";
|
|
73
|
-
|
|
74
|
-
// src/collapsible/CollapsibleTrigger.tsx
|
|
75
|
-
import { mergeProps as mergeProps3 } from "@zag-js/react";
|
|
76
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
77
|
-
var Trigger = ({ asChild = false, children, ref, ...props }) => {
|
|
78
|
-
const collapsibleContext = useCollapsibleContext();
|
|
79
|
-
const Component = asChild ? Slot : "button";
|
|
80
|
-
const mergedProps = mergeProps3(collapsibleContext.getTriggerProps(), props);
|
|
81
|
-
return /* @__PURE__ */ jsx3(Component, { ref, "data-spark-component": "collapsible-trigger", ...mergedProps, children });
|
|
82
|
-
};
|
|
83
|
-
Trigger.displayName = "Collapsible.Trigger";
|
|
84
|
-
|
|
85
|
-
// src/collapsible/index.ts
|
|
86
|
-
var Collapsible2 = Object.assign(Collapsible, {
|
|
87
|
-
Trigger,
|
|
88
|
-
Content
|
|
89
|
-
});
|
|
90
|
-
Collapsible2.displayName = "Collapsible";
|
|
91
|
-
Trigger.displayName = "Collapsible.Trigger";
|
|
92
|
-
Content.displayName = "Collapsible.Content";
|
|
93
|
-
|
|
94
|
-
export {
|
|
95
|
-
Collapsible2 as Collapsible
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=chunk-3LEFXZNI.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/collapsible/Collapsible.tsx","../src/collapsible/CollapsibleContent.tsx","../src/collapsible/CollapsibleTrigger.tsx","../src/collapsible/index.ts"],"sourcesContent":["import * as collapsible from '@zag-js/collapsible'\nimport { mergeProps, normalizeProps, type PropTypes, useMachine } from '@zag-js/react'\nimport { type ComponentProps, createContext, Ref, useContext, useId } from 'react'\n\nimport { Slot } from '../slot'\n\nexport interface CollapsibleProps extends ComponentProps<'div'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n /**\n * The open state of the collapsible when it is initially rendered. Use when you do not need to control its open state.\n */\n defaultOpen?: boolean\n /**\n * When `true`, prevents the user from interacting with the collapsible.\n */\n disabled?: boolean\n /**\n * Event handler called when the open state of the collapsible changes.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * The controlled open state of the collapsible. Must be used in conjunction with `onOpenChange`.\n */\n open?: boolean\n /**\n * The ids of the elements in the collapsible. Useful for composition\n */\n ids?: collapsible.Props['ids']\n ref?: Ref<HTMLDivElement>\n}\n\nconst CollapsibleContext = createContext<collapsible.Api<PropTypes> | null>(null)\n\nexport const Collapsible = ({\n asChild = false,\n children,\n defaultOpen = false,\n disabled = false,\n onOpenChange,\n open,\n ids,\n ref,\n ...props\n}: CollapsibleProps) => {\n const service = useMachine(collapsible.machine, {\n open,\n defaultOpen,\n disabled,\n id: useId(),\n ids,\n onOpenChange(details) {\n onOpenChange?.(details.open)\n },\n })\n const api = collapsible.connect(service, normalizeProps)\n const Component = asChild ? Slot : 'div'\n\n const mergedProps = mergeProps(api.getRootProps(), props)\n\n return (\n <CollapsibleContext.Provider value={api}>\n <Component data-spark-component=\"collapsible\" ref={ref} {...mergedProps}>\n {children}\n </Component>\n </CollapsibleContext.Provider>\n )\n}\n\nCollapsible.displayName = 'Collapsible'\n\nexport const useCollapsibleContext = () => {\n const context = useContext(CollapsibleContext)\n\n if (!context) {\n throw Error('useCollapsibleContext must be used within a Collapsible provider')\n }\n\n return context\n}\n","import { mergeProps } from '@zag-js/react'\nimport { cx } from 'class-variance-authority'\nimport { type ComponentPropsWithoutRef, Ref } from 'react'\n\nimport { Slot } from '../slot'\nimport { useCollapsibleContext } from './Collapsible'\n\nexport interface CollapsibleContentProps extends ComponentPropsWithoutRef<'div'> {\n asChild?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Content = ({\n asChild = false,\n className,\n children,\n ref,\n ...props\n}: CollapsibleContentProps) => {\n const { getContentProps } = useCollapsibleContext()\n\n const Component = asChild ? Slot : 'div'\n const contentProps = getContentProps()\n const mergedProps = mergeProps(contentProps, {\n className: cx(\n 'overflow-hidden',\n 'motion-reduce:animate-none!',\n '[&[hidden]]:hidden',\n 'data-[state=open]:animate-standalone-collapse-in data-[state=closed]:animate-standalone-collapse-out',\n className\n ),\n ...props,\n })\n\n return (\n <Component ref={ref} data-spark-component=\"collapsible-content\" {...mergedProps}>\n {children}\n </Component>\n )\n}\n\nContent.displayName = 'Collapsible.Content'\n","import { mergeProps } from '@zag-js/react'\nimport { type ComponentPropsWithoutRef, Ref } from 'react'\n\nimport { Slot } from '../slot'\nimport { useCollapsibleContext } from './Collapsible'\n\nexport interface CollapsibleTriggerProps extends ComponentPropsWithoutRef<'button'> {\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Trigger = ({ asChild = false, children, ref, ...props }: CollapsibleTriggerProps) => {\n const collapsibleContext = useCollapsibleContext()\n const Component = asChild ? Slot : 'button'\n const mergedProps = mergeProps(collapsibleContext.getTriggerProps(), props)\n\n return (\n <Component ref={ref} data-spark-component=\"collapsible-trigger\" {...mergedProps}>\n {children}\n </Component>\n )\n}\n\nTrigger.displayName = 'Collapsible.Trigger'\n","import { Collapsible as Root } from './Collapsible'\nimport { Content } from './CollapsibleContent'\nimport { Trigger } from './CollapsibleTrigger'\n\nexport const Collapsible: typeof Root & {\n Trigger: typeof Trigger\n Content: typeof Content\n} = Object.assign(Root, {\n Trigger,\n Content,\n})\n\nCollapsible.displayName = 'Collapsible'\nTrigger.displayName = 'Collapsible.Trigger'\nContent.displayName = 'Collapsible.Content'\n\nexport { type CollapsibleProps } from './Collapsible'\nexport { type CollapsibleContentProps } from './CollapsibleContent'\nexport { type CollapsibleTriggerProps } from './CollapsibleTrigger'\n"],"mappings":";;;;;AAAA,YAAY,iBAAiB;AAC7B,SAAS,YAAY,gBAAgC,kBAAkB;AACvE,SAA8B,eAAoB,YAAY,aAAa;AA8DrE;AA9BN,IAAM,qBAAqB,cAAiD,IAAI;AAEzE,IAAM,cAAc,CAAC;AAAA,EAC1B,UAAU;AAAA,EACV;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAwB;AACtB,QAAM,UAAU,WAAuB,qBAAS;AAAA,IAC9C;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,MAAM;AAAA,IACV;AAAA,IACA,aAAa,SAAS;AACpB,qBAAe,QAAQ,IAAI;AAAA,IAC7B;AAAA,EACF,CAAC;AACD,QAAM,MAAkB,oBAAQ,SAAS,cAAc;AACvD,QAAM,YAAY,UAAU,OAAO;AAEnC,QAAM,cAAc,WAAW,IAAI,aAAa,GAAG,KAAK;AAExD,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,KAClC,8BAAC,aAAU,wBAAqB,eAAc,KAAW,GAAG,aACzD,UACH,GACF;AAEJ;AAEA,YAAY,cAAc;AAEnB,IAAM,wBAAwB,MAAM;AACzC,QAAM,UAAU,WAAW,kBAAkB;AAE7C,MAAI,CAAC,SAAS;AACZ,UAAM,MAAM,kEAAkE;AAAA,EAChF;AAEA,SAAO;AACT;;;ACjFA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,UAAU;AAkCf,gBAAAC,YAAA;AAvBG,IAAM,UAAU,CAAC;AAAA,EACtB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA+B;AAC7B,QAAM,EAAE,gBAAgB,IAAI,sBAAsB;AAElD,QAAM,YAAY,UAAU,OAAO;AACnC,QAAM,eAAe,gBAAgB;AACrC,QAAM,cAAcC,YAAW,cAAc;AAAA,IAC3C,WAAW;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AAED,SACE,gBAAAD,KAAC,aAAU,KAAU,wBAAqB,uBAAuB,GAAG,aACjE,UACH;AAEJ;AAEA,QAAQ,cAAc;;;ACzCtB,SAAS,cAAAE,mBAAkB;AAiBvB,gBAAAC,YAAA;AANG,IAAM,UAAU,CAAC,EAAE,UAAU,OAAO,UAAU,KAAK,GAAG,MAAM,MAA+B;AAChG,QAAM,qBAAqB,sBAAsB;AACjD,QAAM,YAAY,UAAU,OAAO;AACnC,QAAM,cAAcC,YAAW,mBAAmB,gBAAgB,GAAG,KAAK;AAE1E,SACE,gBAAAD,KAAC,aAAU,KAAU,wBAAqB,uBAAuB,GAAG,aACjE,UACH;AAEJ;AAEA,QAAQ,cAAc;;;ACnBf,IAAME,eAGT,OAAO,OAAO,aAAM;AAAA,EACtB;AAAA,EACA;AACF,CAAC;AAEDA,aAAY,cAAc;AAC1B,QAAQ,cAAc;AACtB,QAAQ,cAAc;","names":["mergeProps","jsx","mergeProps","mergeProps","jsx","mergeProps","Collapsible"]}
|