@pinfold/react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +58 -2
  2. package/accordion/lazy/package.json +6 -0
  3. package/accordion/package.json +6 -0
  4. package/dist/accordion/client.cjs +474 -0
  5. package/dist/accordion/client.d.cts +31 -0
  6. package/dist/accordion/client.d.ts +31 -0
  7. package/dist/accordion/client.js +473 -0
  8. package/dist/accordion/index.cjs +48 -0
  9. package/dist/accordion/index.d.cts +52 -0
  10. package/dist/accordion/index.d.ts +52 -0
  11. package/dist/accordion/index.js +13 -0
  12. package/dist/accordion/lazy.cjs +17 -0
  13. package/dist/accordion/lazy.d.cts +15 -0
  14. package/dist/accordion/lazy.d.ts +15 -0
  15. package/dist/accordion/lazy.js +16 -0
  16. package/dist/chunk-5ZMK623A.js +61 -0
  17. package/dist/chunk-BPPCPHHU.js +70 -0
  18. package/dist/chunk-DQWSDHRY.cjs +71 -0
  19. package/dist/chunk-Q232PTPW.js +115 -0
  20. package/dist/chunk-RJPT3NTP.cjs +62 -0
  21. package/dist/chunk-VPKVOJHA.cjs +116 -0
  22. package/dist/client.cjs +30 -0
  23. package/dist/client.d.cts +121 -0
  24. package/dist/client.d.ts +121 -0
  25. package/dist/client.js +29 -0
  26. package/dist/index.cjs +52 -0
  27. package/dist/index.d.cts +123 -0
  28. package/dist/index.d.ts +123 -0
  29. package/dist/index.js +10 -0
  30. package/dist/types-BZqk8btE.d.cts +278 -0
  31. package/dist/types-BZqk8btE.d.ts +278 -0
  32. package/dist/types-x01Q5sqz.d.cts +278 -0
  33. package/dist/types-x01Q5sqz.d.ts +278 -0
  34. package/dist/validate-D3GJ2276.js +37 -0
  35. package/dist/validate-ELH6OKK3.cjs +38 -0
  36. package/llms-full.txt +133 -0
  37. package/llms.txt +26 -0
  38. package/package.json +92 -4
  39. package/registry/accordion.json +20 -0
  40. package/registry/registry.json +25 -0
  41. package/schema/accordion.json +800 -0
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import * as _pinfold_core from '@pinfold/core';
3
+ import { A as AccordionConfig } from '../types-BZqk8btE.js';
4
+
5
+ /**
6
+ * Code-split entry point. Nothing accordion-related enters the main bundle
7
+ * until the component first renders:
8
+ *
9
+ * import { Accordion } from '@pinfold/react/accordion/lazy';
10
+ */
11
+ declare const Accordion: React.ComponentType<AccordionConfig & {
12
+ lazy?: _pinfold_core.PinfoldLazy;
13
+ }>;
14
+
15
+ export { Accordion, AccordionConfig, Accordion as default };
@@ -0,0 +1,16 @@
1
+ 'use client';
2
+ import {
3
+ createLazyComponent
4
+ } from "../chunk-5ZMK623A.js";
5
+ import "../chunk-Q232PTPW.js";
6
+
7
+ // src/accordion/lazy.ts
8
+ var Accordion = createLazyComponent(
9
+ () => import("./client.js").then((m) => ({ default: m.Accordion })),
10
+ { displayName: "LazyAccordion" }
11
+ );
12
+ var lazy_default = Accordion;
13
+ export {
14
+ Accordion,
15
+ lazy_default as default
16
+ };
@@ -0,0 +1,61 @@
1
+ 'use client';
2
+ import {
3
+ usePinfold
4
+ } from "./chunk-Q232PTPW.js";
5
+
6
+ // src/lazy.tsx
7
+ import * as React from "react";
8
+ function createLazyComponent(loader, options = {}) {
9
+ var _a, _b;
10
+ const Lazy = React.lazy(loader);
11
+ const fallback = (_a = options.fallback) != null ? _a : null;
12
+ const Wrapped = (props) => {
13
+ var _a2, _b2;
14
+ const ctx = usePinfold();
15
+ const preferred = (_a2 = props.lazy) != null ? _a2 : ctx.lazy;
16
+ const strategy = preferred === "auto" ? (_b2 = options.auto) != null ? _b2 : "eager" : preferred;
17
+ const [ready, setReady] = React.useState(strategy === "eager");
18
+ const placeholder = React.useRef(null);
19
+ React.useEffect(() => {
20
+ if (ready) return;
21
+ if (strategy === "idle") {
22
+ const w = window;
23
+ if (w.requestIdleCallback) {
24
+ const id2 = w.requestIdleCallback(() => setReady(true));
25
+ return () => {
26
+ var _a3;
27
+ return (_a3 = w.cancelIdleCallback) == null ? void 0 : _a3.call(w, id2);
28
+ };
29
+ }
30
+ const id = setTimeout(() => setReady(true), 200);
31
+ return () => clearTimeout(id);
32
+ }
33
+ const el = placeholder.current;
34
+ if (!el || typeof IntersectionObserver === "undefined") {
35
+ setReady(true);
36
+ return;
37
+ }
38
+ const observer = new IntersectionObserver(
39
+ (entries) => {
40
+ if (entries.some((e) => e.isIntersecting)) {
41
+ setReady(true);
42
+ observer.disconnect();
43
+ }
44
+ },
45
+ { rootMargin: "200px" }
46
+ );
47
+ observer.observe(el);
48
+ return () => observer.disconnect();
49
+ }, [ready, strategy]);
50
+ if (!ready) {
51
+ return /* @__PURE__ */ React.createElement("div", { ref: placeholder, "data-pinfold-lazy": "", style: { minHeight: 1 } }, fallback);
52
+ }
53
+ return /* @__PURE__ */ React.createElement(React.Suspense, { fallback }, React.createElement(Lazy, props));
54
+ };
55
+ Wrapped.displayName = (_b = options.displayName) != null ? _b : "PinfoldLazy";
56
+ return Wrapped;
57
+ }
58
+
59
+ export {
60
+ createLazyComponent
61
+ };
@@ -0,0 +1,70 @@
1
+ 'use client';
2
+ import {
3
+ useIsomorphicLayoutEffect
4
+ } from "./chunk-Q232PTPW.js";
5
+
6
+ // src/slots.ts
7
+ import { cn, mergeProps } from "@pinfold/core";
8
+ function slotProps(overrides, slot, base) {
9
+ var _a, _b, _c;
10
+ if (!overrides) return base;
11
+ const extraClass = (_a = overrides.classNames) == null ? void 0 : _a[slot];
12
+ const extraStyle = (_b = overrides.styles) == null ? void 0 : _b[slot];
13
+ let next = base;
14
+ if (extraClass) next = { ...next, className: cn(next.className, extraClass) };
15
+ if (extraStyle) next = { ...next, style: { ...next.style, ...extraStyle } };
16
+ return mergeProps(next, (_c = overrides.slotProps) == null ? void 0 : _c[slot]);
17
+ }
18
+ function renderSlot(overrides, slot, props, state, children, defaultRender) {
19
+ var _a;
20
+ const custom = (_a = overrides == null ? void 0 : overrides.render) == null ? void 0 : _a[slot];
21
+ if (custom) return custom({ props, state, children });
22
+ return defaultRender(props, children);
23
+ }
24
+
25
+ // src/component.tsx
26
+ import * as React from "react";
27
+ function usePinfoldComponent(displayName, api, render, buildParts) {
28
+ const renderRef = React.useRef(render);
29
+ renderRef.current = render;
30
+ const ref = React.useRef(null);
31
+ if (ref.current === null) {
32
+ const store2 = { version: 0, listeners: /* @__PURE__ */ new Set() };
33
+ const subscribe = (listener) => {
34
+ store2.listeners.add(listener);
35
+ return () => {
36
+ store2.listeners.delete(listener);
37
+ };
38
+ };
39
+ const snapshot = () => store2.version;
40
+ const useFresh = () => React.useSyncExternalStore(subscribe, snapshot, snapshot);
41
+ const Component2 = ((props) => {
42
+ useFresh();
43
+ return renderRef.current(props);
44
+ });
45
+ Component2.displayName = displayName;
46
+ const parts = buildParts ? buildParts() : {};
47
+ for (const key of Object.keys(parts)) {
48
+ const part = parts[key];
49
+ const Live = (props) => {
50
+ useFresh();
51
+ return part(props);
52
+ };
53
+ Live.displayName = `${displayName}.${key}`;
54
+ Component2[key] = Live;
55
+ }
56
+ ref.current = { store: store2, Component: Component2 };
57
+ }
58
+ const { store, Component } = ref.current;
59
+ store.version++;
60
+ useIsomorphicLayoutEffect(() => {
61
+ store.listeners.forEach((listener) => listener());
62
+ });
63
+ return Object.assign(Component, api, { displayName });
64
+ }
65
+
66
+ export {
67
+ slotProps,
68
+ renderSlot,
69
+ usePinfoldComponent
70
+ };
@@ -0,0 +1,71 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }'use client';
3
+
4
+
5
+ var _chunkVPKVOJHAcjs = require('./chunk-VPKVOJHA.cjs');
6
+
7
+ // src/slots.ts
8
+ var _core = require('@pinfold/core');
9
+ function slotProps(overrides, slot, base) {
10
+ var _a, _b, _c;
11
+ if (!overrides) return base;
12
+ const extraClass = (_a = overrides.classNames) == null ? void 0 : _a[slot];
13
+ const extraStyle = (_b = overrides.styles) == null ? void 0 : _b[slot];
14
+ let next = base;
15
+ if (extraClass) next = { ...next, className: _core.cn.call(void 0, next.className, extraClass) };
16
+ if (extraStyle) next = { ...next, style: { ...next.style, ...extraStyle } };
17
+ return _core.mergeProps.call(void 0, next, (_c = overrides.slotProps) == null ? void 0 : _c[slot]);
18
+ }
19
+ function renderSlot(overrides, slot, props, state, children, defaultRender) {
20
+ var _a;
21
+ const custom = (_a = overrides == null ? void 0 : overrides.render) == null ? void 0 : _a[slot];
22
+ if (custom) return custom({ props, state, children });
23
+ return defaultRender(props, children);
24
+ }
25
+
26
+ // src/component.tsx
27
+ var _react = require('react'); var React = _interopRequireWildcard(_react);
28
+ function usePinfoldComponent(displayName, api, render, buildParts) {
29
+ const renderRef = React.useRef(render);
30
+ renderRef.current = render;
31
+ const ref = React.useRef(null);
32
+ if (ref.current === null) {
33
+ const store2 = { version: 0, listeners: /* @__PURE__ */ new Set() };
34
+ const subscribe = (listener) => {
35
+ store2.listeners.add(listener);
36
+ return () => {
37
+ store2.listeners.delete(listener);
38
+ };
39
+ };
40
+ const snapshot = () => store2.version;
41
+ const useFresh = () => React.useSyncExternalStore(subscribe, snapshot, snapshot);
42
+ const Component2 = ((props) => {
43
+ useFresh();
44
+ return renderRef.current(props);
45
+ });
46
+ Component2.displayName = displayName;
47
+ const parts = buildParts ? buildParts() : {};
48
+ for (const key of Object.keys(parts)) {
49
+ const part = parts[key];
50
+ const Live = (props) => {
51
+ useFresh();
52
+ return part(props);
53
+ };
54
+ Live.displayName = `${displayName}.${key}`;
55
+ Component2[key] = Live;
56
+ }
57
+ ref.current = { store: store2, Component: Component2 };
58
+ }
59
+ const { store, Component } = ref.current;
60
+ store.version++;
61
+ _chunkVPKVOJHAcjs.useIsomorphicLayoutEffect.call(void 0, () => {
62
+ store.listeners.forEach((listener) => listener());
63
+ });
64
+ return Object.assign(Component, api, { displayName });
65
+ }
66
+
67
+
68
+
69
+
70
+
71
+ exports.slotProps = slotProps; exports.renderSlot = renderSlot; exports.usePinfoldComponent = usePinfoldComponent;
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+
3
+ // src/hooks.ts
4
+ import * as React from "react";
5
+ var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
6
+ function useId2(provided) {
7
+ const generated = React.useId();
8
+ return provided || "pinfold-" + generated.replace(/[^\w-]/g, "");
9
+ }
10
+ function useEvent(fn) {
11
+ const ref = React.useRef(fn);
12
+ useIsomorphicLayoutEffect(() => {
13
+ ref.current = fn;
14
+ });
15
+ return React.useCallback(((...args) => ref.current(...args)), []);
16
+ }
17
+ function useControllableState({
18
+ value,
19
+ defaultValue,
20
+ onChange
21
+ }) {
22
+ const [uncontrolled, setUncontrolled] = React.useState(defaultValue);
23
+ const isControlled = value !== void 0;
24
+ const current = isControlled ? value : uncontrolled;
25
+ const currentRef = React.useRef(current);
26
+ currentRef.current = current;
27
+ const setValue = useEvent((next) => {
28
+ const resolved = typeof next === "function" ? next(currentRef.current) : next;
29
+ if (Object.is(resolved, currentRef.current)) return;
30
+ if (!isControlled) setUncontrolled(resolved);
31
+ onChange == null ? void 0 : onChange(resolved);
32
+ });
33
+ return [current, setValue];
34
+ }
35
+
36
+ // src/provider.tsx
37
+ import * as React2 from "react";
38
+ var DEFAULTS = {
39
+ theme: "system",
40
+ radius: "md",
41
+ dir: "ltr",
42
+ size: "md",
43
+ tone: "primary",
44
+ stylePack: "default",
45
+ lazy: "auto",
46
+ disableAnimation: false,
47
+ defaults: {}
48
+ };
49
+ var PinfoldContext = React2.createContext(DEFAULTS);
50
+ function usePinfold() {
51
+ return React2.useContext(PinfoldContext);
52
+ }
53
+ function PinfoldProvider(props) {
54
+ const { children, applyToDocument = false, className, config, ...own } = props;
55
+ const parent = React2.useContext(PinfoldContext);
56
+ const overrides = { ...stripUndefined(config != null ? config : {}), ...stripUndefined(own) };
57
+ const value = React2.useMemo(
58
+ () => ({ ...parent, ...overrides, defaults: mergeDefaults(parent.defaults, overrides.defaults) }),
59
+ // Keyed on the serialised overrides: configs are plain data, and inline objects must not bust the memo.
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ [parent, stableKey(overrides)]
62
+ );
63
+ useIsomorphicLayoutEffect(() => {
64
+ if (!applyToDocument) return;
65
+ const el = document.documentElement;
66
+ const attrs = [
67
+ ["data-pinfold-theme", value.theme === "system" ? null : value.theme],
68
+ ["data-pinfold-radius", value.radius],
69
+ ["data-pinfold-style", value.stylePack === "default" ? null : value.stylePack]
70
+ ];
71
+ const previous = attrs.map(([name]) => el.getAttribute(name));
72
+ attrs.forEach(([name, v]) => restore(el, name, v));
73
+ return () => attrs.forEach(([name], i) => restore(el, name, previous[i]));
74
+ }, [applyToDocument, value.theme, value.radius, value.stylePack]);
75
+ const body = applyToDocument ? children : /* @__PURE__ */ React2.createElement(
76
+ "div",
77
+ {
78
+ className: className ? "pinfold " + className : "pinfold",
79
+ dir: value.dir,
80
+ "data-pinfold-theme": value.theme === "system" ? void 0 : value.theme,
81
+ "data-pinfold-radius": value.radius,
82
+ "data-pinfold-style": value.stylePack === "default" ? void 0 : value.stylePack
83
+ },
84
+ children
85
+ );
86
+ return /* @__PURE__ */ React2.createElement(PinfoldContext.Provider, { value }, body);
87
+ }
88
+ function mergeDefaults(parent, own) {
89
+ if (!own) return parent;
90
+ const out = { ...parent };
91
+ for (const key in own) out[key] = { ...parent[key], ...own[key] };
92
+ return out;
93
+ }
94
+ function stableKey(obj) {
95
+ let fn = 0;
96
+ return JSON.stringify(obj, (_, v) => typeof v === "function" ? `fn${fn++}` : v);
97
+ }
98
+ function restore(el, attr, v) {
99
+ if (v == null) el.removeAttribute(attr);
100
+ else el.setAttribute(attr, v);
101
+ }
102
+ function stripUndefined(obj) {
103
+ const out = {};
104
+ for (const k in obj) if (obj[k] !== void 0) out[k] = obj[k];
105
+ return out;
106
+ }
107
+
108
+ export {
109
+ useIsomorphicLayoutEffect,
110
+ useId2 as useId,
111
+ useEvent,
112
+ useControllableState,
113
+ usePinfold,
114
+ PinfoldProvider
115
+ };
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }'use client';
3
+
4
+
5
+ var _chunkVPKVOJHAcjs = require('./chunk-VPKVOJHA.cjs');
6
+
7
+ // src/lazy.tsx
8
+ var _react = require('react'); var React = _interopRequireWildcard(_react);
9
+ function createLazyComponent(loader, options = {}) {
10
+ var _a, _b;
11
+ const Lazy = React.lazy(loader);
12
+ const fallback = (_a = options.fallback) != null ? _a : null;
13
+ const Wrapped = (props) => {
14
+ var _a2, _b2;
15
+ const ctx = _chunkVPKVOJHAcjs.usePinfold.call(void 0, );
16
+ const preferred = (_a2 = props.lazy) != null ? _a2 : ctx.lazy;
17
+ const strategy = preferred === "auto" ? (_b2 = options.auto) != null ? _b2 : "eager" : preferred;
18
+ const [ready, setReady] = React.useState(strategy === "eager");
19
+ const placeholder = React.useRef(null);
20
+ React.useEffect(() => {
21
+ if (ready) return;
22
+ if (strategy === "idle") {
23
+ const w = window;
24
+ if (w.requestIdleCallback) {
25
+ const id2 = w.requestIdleCallback(() => setReady(true));
26
+ return () => {
27
+ var _a3;
28
+ return (_a3 = w.cancelIdleCallback) == null ? void 0 : _a3.call(w, id2);
29
+ };
30
+ }
31
+ const id = setTimeout(() => setReady(true), 200);
32
+ return () => clearTimeout(id);
33
+ }
34
+ const el = placeholder.current;
35
+ if (!el || typeof IntersectionObserver === "undefined") {
36
+ setReady(true);
37
+ return;
38
+ }
39
+ const observer = new IntersectionObserver(
40
+ (entries) => {
41
+ if (entries.some((e) => e.isIntersecting)) {
42
+ setReady(true);
43
+ observer.disconnect();
44
+ }
45
+ },
46
+ { rootMargin: "200px" }
47
+ );
48
+ observer.observe(el);
49
+ return () => observer.disconnect();
50
+ }, [ready, strategy]);
51
+ if (!ready) {
52
+ return /* @__PURE__ */ React.createElement("div", { ref: placeholder, "data-pinfold-lazy": "", style: { minHeight: 1 } }, fallback);
53
+ }
54
+ return /* @__PURE__ */ React.createElement(React.Suspense, { fallback }, React.createElement(Lazy, props));
55
+ };
56
+ Wrapped.displayName = (_b = options.displayName) != null ? _b : "PinfoldLazy";
57
+ return Wrapped;
58
+ }
59
+
60
+
61
+
62
+ exports.createLazyComponent = createLazyComponent;
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }'use client';
3
+
4
+ // src/hooks.ts
5
+ var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
6
+ var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
7
+ function useId2(provided) {
8
+ const generated = React.useId();
9
+ return provided || "pinfold-" + generated.replace(/[^\w-]/g, "");
10
+ }
11
+ function useEvent(fn) {
12
+ const ref = React.useRef(fn);
13
+ useIsomorphicLayoutEffect(() => {
14
+ ref.current = fn;
15
+ });
16
+ return React.useCallback(((...args) => ref.current(...args)), []);
17
+ }
18
+ function useControllableState({
19
+ value,
20
+ defaultValue,
21
+ onChange
22
+ }) {
23
+ const [uncontrolled, setUncontrolled] = React.useState(defaultValue);
24
+ const isControlled = value !== void 0;
25
+ const current = isControlled ? value : uncontrolled;
26
+ const currentRef = React.useRef(current);
27
+ currentRef.current = current;
28
+ const setValue = useEvent((next) => {
29
+ const resolved = typeof next === "function" ? next(currentRef.current) : next;
30
+ if (Object.is(resolved, currentRef.current)) return;
31
+ if (!isControlled) setUncontrolled(resolved);
32
+ onChange == null ? void 0 : onChange(resolved);
33
+ });
34
+ return [current, setValue];
35
+ }
36
+
37
+ // src/provider.tsx
38
+
39
+ var DEFAULTS = {
40
+ theme: "system",
41
+ radius: "md",
42
+ dir: "ltr",
43
+ size: "md",
44
+ tone: "primary",
45
+ stylePack: "default",
46
+ lazy: "auto",
47
+ disableAnimation: false,
48
+ defaults: {}
49
+ };
50
+ var PinfoldContext = React2.createContext(DEFAULTS);
51
+ function usePinfold() {
52
+ return React2.useContext(PinfoldContext);
53
+ }
54
+ function PinfoldProvider(props) {
55
+ const { children, applyToDocument = false, className, config, ...own } = props;
56
+ const parent = React2.useContext(PinfoldContext);
57
+ const overrides = { ...stripUndefined(config != null ? config : {}), ...stripUndefined(own) };
58
+ const value = React2.useMemo(
59
+ () => ({ ...parent, ...overrides, defaults: mergeDefaults(parent.defaults, overrides.defaults) }),
60
+ // Keyed on the serialised overrides: configs are plain data, and inline objects must not bust the memo.
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ [parent, stableKey(overrides)]
63
+ );
64
+ useIsomorphicLayoutEffect(() => {
65
+ if (!applyToDocument) return;
66
+ const el = document.documentElement;
67
+ const attrs = [
68
+ ["data-pinfold-theme", value.theme === "system" ? null : value.theme],
69
+ ["data-pinfold-radius", value.radius],
70
+ ["data-pinfold-style", value.stylePack === "default" ? null : value.stylePack]
71
+ ];
72
+ const previous = attrs.map(([name]) => el.getAttribute(name));
73
+ attrs.forEach(([name, v]) => restore(el, name, v));
74
+ return () => attrs.forEach(([name], i) => restore(el, name, previous[i]));
75
+ }, [applyToDocument, value.theme, value.radius, value.stylePack]);
76
+ const body = applyToDocument ? children : /* @__PURE__ */ React2.createElement(
77
+ "div",
78
+ {
79
+ className: className ? "pinfold " + className : "pinfold",
80
+ dir: value.dir,
81
+ "data-pinfold-theme": value.theme === "system" ? void 0 : value.theme,
82
+ "data-pinfold-radius": value.radius,
83
+ "data-pinfold-style": value.stylePack === "default" ? void 0 : value.stylePack
84
+ },
85
+ children
86
+ );
87
+ return /* @__PURE__ */ React2.createElement(PinfoldContext.Provider, { value }, body);
88
+ }
89
+ function mergeDefaults(parent, own) {
90
+ if (!own) return parent;
91
+ const out = { ...parent };
92
+ for (const key in own) out[key] = { ...parent[key], ...own[key] };
93
+ return out;
94
+ }
95
+ function stableKey(obj) {
96
+ let fn = 0;
97
+ return JSON.stringify(obj, (_, v) => typeof v === "function" ? `fn${fn++}` : v);
98
+ }
99
+ function restore(el, attr, v) {
100
+ if (v == null) el.removeAttribute(attr);
101
+ else el.setAttribute(attr, v);
102
+ }
103
+ function stripUndefined(obj) {
104
+ const out = {};
105
+ for (const k in obj) if (obj[k] !== void 0) out[k] = obj[k];
106
+ return out;
107
+ }
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect; exports.useId = useId2; exports.useEvent = useEvent; exports.useControllableState = useControllableState; exports.usePinfold = usePinfold; exports.PinfoldProvider = PinfoldProvider;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});'use client';
3
+
4
+
5
+
6
+
7
+ var _chunkDQWSDHRYcjs = require('./chunk-DQWSDHRY.cjs');
8
+
9
+
10
+ var _chunkRJPT3NTPcjs = require('./chunk-RJPT3NTP.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ var _chunkVPKVOJHAcjs = require('./chunk-VPKVOJHA.cjs');
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ exports.PinfoldProvider = _chunkVPKVOJHAcjs.PinfoldProvider; exports.createLazyComponent = _chunkRJPT3NTPcjs.createLazyComponent; exports.renderSlot = _chunkDQWSDHRYcjs.renderSlot; exports.slotProps = _chunkDQWSDHRYcjs.slotProps; exports.useControllableState = _chunkVPKVOJHAcjs.useControllableState; exports.useEvent = _chunkVPKVOJHAcjs.useEvent; exports.useId = _chunkVPKVOJHAcjs.useId; exports.useIsomorphicLayoutEffect = _chunkVPKVOJHAcjs.useIsomorphicLayoutEffect; exports.usePinfold = _chunkVPKVOJHAcjs.usePinfold; exports.usePinfoldComponent = _chunkDQWSDHRYcjs.usePinfoldComponent;
@@ -0,0 +1,121 @@
1
+ import * as React from 'react';
2
+ import { PinfoldTheme, PinfoldRadius, PinfoldDir, PinfoldSize, PinfoldTone, PinfoldStylePack, PinfoldLazy, PropsBag } from '@pinfold/core';
3
+ import { S as SlotOverrides } from './types-BZqk8btE.cjs';
4
+ import { AccordionConfig } from './accordion/client.cjs';
5
+ export { P as PinfoldComponent, b as SlotRenderer, c as Slottable, u as usePinfoldComponent } from './types-BZqk8btE.cjs';
6
+
7
+ /** Per-component defaults. Data, state and ids never belong here, only how components look and behave. */
8
+ interface PinfoldComponentDefaults {
9
+ accordion?: Partial<Omit<AccordionConfig, 'items' | 'fields' | 'value' | 'defaultValue' | 'id'>>;
10
+ }
11
+ /**
12
+ * The global config, usually in `pinfold.config.ts` (or `.js`):
13
+ *
14
+ * export default defineConfig({ theme: 'system', radius: 'lg', defaults: { accordion: { variant: 'separated' } } });
15
+ *
16
+ * and handed to the provider once: `<PinfoldProvider config={config}>`.
17
+ * Precedence, highest first: component config, `defaults.<component>`, this
18
+ * global theme, the library defaults. A nested provider overrides its section.
19
+ */
20
+ interface PinfoldConfig {
21
+ theme?: PinfoldTheme;
22
+ radius?: PinfoldRadius;
23
+ dir?: PinfoldDir;
24
+ size?: PinfoldSize;
25
+ tone?: PinfoldTone;
26
+ /** Visual style pack (needs `@pinfold/css/packs.css`). Default `'default'`. */
27
+ stylePack?: PinfoldStylePack;
28
+ /** Default code-loading strategy for `/lazy` entries. Default `'auto'`. */
29
+ lazy?: PinfoldLazy;
30
+ /** Disable every component transition, e.g. in tests or on low-power devices. */
31
+ disableAnimation?: boolean;
32
+ defaults?: PinfoldComponentDefaults;
33
+ }
34
+
35
+ interface PinfoldContextValue {
36
+ theme: PinfoldTheme;
37
+ radius: PinfoldRadius;
38
+ dir: PinfoldDir;
39
+ size: PinfoldSize;
40
+ tone: PinfoldTone;
41
+ stylePack: PinfoldStylePack;
42
+ lazy: PinfoldLazy;
43
+ /** Disable every component transition, e.g. in tests or on low-power devices. */
44
+ disableAnimation: boolean;
45
+ defaults: PinfoldComponentDefaults;
46
+ }
47
+ /** Component-level defaults. Every component calls this; the provider is optional. */
48
+ declare function usePinfold(): PinfoldContextValue;
49
+ interface PinfoldProviderProps extends PinfoldConfig {
50
+ children?: React.ReactNode;
51
+ /** A whole config from `defineConfig()`. Individual props override it. */
52
+ config?: PinfoldConfig;
53
+ /**
54
+ * Write `data-pinfold-theme` / `data-pinfold-radius` / `data-pinfold-style`
55
+ * onto `<html>` instead of a wrapper element. Use this when portals
56
+ * (dialogs, tooltips) must inherit the theme. Default: false.
57
+ */
58
+ applyToDocument?: boolean;
59
+ className?: string;
60
+ }
61
+ declare function PinfoldProvider(props: PinfoldProviderProps): React.ReactElement;
62
+
63
+ /** SSR-safe layout effect. */
64
+ declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
65
+ /**
66
+ * Stable, SSR-safe id (React 18+ `useId`). The characters React wraps ids in
67
+ * (`:` in 18, `«»` in 19) are stripped so the id is also a valid CSS selector.
68
+ */
69
+ declare function useId(provided?: string): string;
70
+ /**
71
+ * A callback whose identity never changes but which always sees fresh props.
72
+ * Lets us hand stable handlers to consumers without re-render churn.
73
+ */
74
+ declare function useEvent<T extends (...args: any[]) => any>(fn: T): T;
75
+ interface ControllableStateOptions<T> {
76
+ value?: T;
77
+ defaultValue: T | (() => T);
78
+ onChange?: (value: T) => void;
79
+ }
80
+ /** One state hook that is controlled, uncontrolled, or both. */
81
+ declare function useControllableState<T>({ value, defaultValue, onChange, }: ControllableStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void];
82
+
83
+ /**
84
+ * Fold a slot's `classNames`, `styles` and `slotProps` overrides into the
85
+ * behaviour props a component generated. Handlers chain, classes concatenate,
86
+ * styles merge.
87
+ */
88
+ declare function slotProps<Slot extends string, State>(overrides: SlotOverrides<Slot, State> | undefined, slot: Slot, base: PropsBag): PropsBag;
89
+ /**
90
+ * Render a slot, letting the consumer swap the element while keeping every
91
+ * accessibility prop. `defaultRender` is used when no override exists.
92
+ */
93
+ declare function renderSlot<Slot extends string, State>(overrides: SlotOverrides<Slot, State> | undefined, slot: Slot, props: PropsBag, state: State, children: React.ReactNode, defaultRender: (props: PropsBag, children: React.ReactNode) => React.ReactNode): React.ReactNode;
94
+
95
+ interface LazyOptions {
96
+ /** Rendered while the chunk downloads, and in the placeholder. Default: nothing. */
97
+ fallback?: React.ReactNode;
98
+ /** Name shown in React DevTools. */
99
+ displayName?: string;
100
+ /** What `lazy: 'auto'` means for this component: `eager` when light, `visible` when heavy. Default `eager`. */
101
+ auto?: Exclude<PinfoldLazy, 'auto'>;
102
+ }
103
+ /**
104
+ * Wrap a dynamic import into a drop-in component with its own Suspense
105
+ * boundary, so consumers get code-splitting without touching their tree:
106
+ *
107
+ * const Accordion = createLazyComponent(() => import('@pinfold/react/accordion'));
108
+ * <Accordion items={items} lazy="visible" />
109
+ *
110
+ * `lazy` (prop, else the provider): `eager` loads at once, `visible` when the
111
+ * placeholder nears the viewport, `idle` when the browser is idle. Lazy entries
112
+ * render on the client; for complete server HTML use the main entry.
113
+ */
114
+ declare function createLazyComponent<P extends object>(loader: () => Promise<{
115
+ default: React.ComponentType<P>;
116
+ }>, options?: LazyOptions): React.ComponentType<P & {
117
+ lazy?: PinfoldLazy;
118
+ }>;
119
+
120
+ export { PinfoldProvider, SlotOverrides, createLazyComponent, renderSlot, slotProps, useControllableState, useEvent, useId, useIsomorphicLayoutEffect, usePinfold };
121
+ export type { ControllableStateOptions, LazyOptions, PinfoldContextValue, PinfoldProviderProps };