@pinfold/react 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,11 @@ var _core = require('@pinfold/core');
34
34
 
35
35
 
36
36
  var B = "pinfold-accordion";
37
+ var RADIUS_SCALE = { none: 0, sm: 0.6, md: 1, lg: 1.5, full: 2.4 };
38
+ var GAP = { none: "0px", sm: "var(--pinfold-space-2)", md: "var(--pinfold-space-3)", lg: "var(--pinfold-space-5)" };
39
+ var own = (map, key) => typeof key === "string" && Object.prototype.hasOwnProperty.call(map, key);
40
+ var radiusValue = (r) => own(RADIUS_SCALE, r) ? `calc(var(--pinfold-acc-radius-unit) * ${RADIUS_SCALE[r]})` : r;
41
+ var gapValue = (g) => own(GAP, g) ? GAP[g] : g;
37
42
  var GLYPHS = {
38
43
  chevron: /* @__PURE__ */ React.createElement("path", { d: "M4 6.5 8 10.5 12 6.5" }),
39
44
  caret: /* @__PURE__ */ React.createElement("path", { d: "M6 4l5 4-5 4z", fill: "currentColor", stroke: "none" }),
@@ -58,18 +63,25 @@ function slot(ctx, name, base, item) {
58
63
  function renderRoot(ctx, rootProps) {
59
64
  var _a, _b;
60
65
  const { api, config, a } = ctx;
66
+ const dimensions = {
67
+ radius: radiusValue(config.radius),
68
+ itemRadius: radiusValue(config.itemRadius),
69
+ gap: gapValue(config.gap),
70
+ ...config.dimensions
71
+ };
61
72
  const props = api.getRootProps(
62
73
  _core.mergeProps.call(void 0,
63
74
  slot(ctx, "root", {
64
75
  className: a.unstyled ? config.className : _core.cn.call(void 0, "pinfold", B, config.className),
65
- style: { ..._core.dimensionVars.call(void 0, "accordion", config.dimensions), ...config.style },
76
+ style: { ..._core.dimensionVars.call(void 0, "accordion", dimensions), ...config.style },
66
77
  "data-variant": a.variant,
67
78
  "data-size": a.size,
68
79
  "data-tone": a.tone,
69
- // Only an explicit radius; otherwise the provider's preset or a style pack reaches the root by inheritance.
70
- "data-pinfold-radius": config.radius,
71
80
  "data-indicator-position": a.indicatorPosition,
81
+ "data-static-indicator": a.animateIndicator ? void 0 : "",
72
82
  "data-dividers": a.dividers ? "" : void 0,
83
+ // Separated or filled rows with no gap join into one group (cards and ghost always touch).
84
+ "data-joined": (a.variant === "separated" || a.variant === "filled") && _core.accordionRowsJoined.call(void 0, a.variant, dimensions.gap) ? "" : void 0,
73
85
  "data-animate": a.animate ? "" : void 0,
74
86
  "data-unstyled": a.unstyled ? "" : void 0,
75
87
  "data-scroll": ((_a = config.dimensions) == null ? void 0 : _a.panelMaxHeight) != null ? "" : void 0,
@@ -117,23 +129,24 @@ function renderHeader(ctx, item, extra, children) {
117
129
  ));
118
130
  }
119
131
  function TriggerContent({ ctx, item }) {
120
- var _a, _b;
121
- const { icon, title, description, badge } = item.config;
122
- const iconNode = _core.resolveNode.call(void 0, icon, item);
132
+ var _a, _b, _c, _d;
133
+ const { title, description, badge } = item.config;
134
+ const iconNode = _core.resolveNode.call(void 0, (_a = item.config.icon) != null ? _a : ctx.config.icon, item);
135
+ const endIconNode = _core.resolveNode.call(void 0, (_b = item.config.endIcon) != null ? _b : ctx.config.endIcon, item);
123
136
  const descriptionNode = _core.resolveNode.call(void 0, description, item);
124
137
  const badgeNode = _core.resolveNode.call(void 0, badge, item);
125
- return /* @__PURE__ */ React.createElement(React.Fragment, null, iconNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "icon", { className: cls(ctx, `${B}__icon`), "aria-hidden": "true" }, item) }, iconNode) : null, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "label", { className: cls(ctx, `${B}__label`) }, item) }, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "title", { className: cls(ctx, `${B}__title`), ...overflowProps((_a = ctx.config.overflow) == null ? void 0 : _a.title, "wrap") }, item) }, _core.resolveNode.call(void 0, title, item)), descriptionNode ? /* @__PURE__ */ React.createElement(
138
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, iconNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "icon", { className: cls(ctx, `${B}__icon`), "aria-hidden": "true" }, item) }, iconNode) : null, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "label", { className: cls(ctx, `${B}__label`) }, item) }, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "title", { className: cls(ctx, `${B}__title`), ...overflowProps((_c = ctx.config.overflow) == null ? void 0 : _c.title, "wrap") }, item) }, _core.resolveNode.call(void 0, title, item)), descriptionNode ? /* @__PURE__ */ React.createElement(
126
139
  "span",
127
140
  {
128
141
  ...slot(
129
142
  ctx,
130
143
  "description",
131
- { className: cls(ctx, `${B}__description`), ...overflowProps((_b = ctx.config.overflow) == null ? void 0 : _b.description, { lines: 2 }) },
144
+ { className: cls(ctx, `${B}__description`), ...overflowProps((_d = ctx.config.overflow) == null ? void 0 : _d.description, { lines: 2 }) },
132
145
  item
133
146
  )
134
147
  },
135
148
  descriptionNode
136
- ) : null), badgeNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "badge", { className: cls(ctx, `${B}__badge`) }, item) }, badgeNode) : null, renderIndicator(ctx, item));
149
+ ) : null), badgeNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "badge", { className: cls(ctx, `${B}__badge`) }, item) }, badgeNode) : null, endIconNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "endIcon", { className: cls(ctx, `${B}__end-icon`), "aria-hidden": "true" }, item) }, endIconNode) : null, renderIndicator(ctx, item));
137
150
  }
138
151
  function renderIndicator(ctx, item, extra) {
139
152
  var _a;
@@ -184,7 +197,7 @@ var cls = (ctx, name) => ctx.a.unstyled ? void 0 : name;
184
197
 
185
198
  // src/accordion/useAccordion.tsx
186
199
  function useAccordion(input) {
187
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
200
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
188
201
  const ctx = _chunkVPKVOJHAcjs.usePinfold.call(void 0, );
189
202
  const config = ctx.defaults.accordion ? { ...ctx.defaults.accordion, ...defined(input) } : input;
190
203
  const {
@@ -203,7 +216,7 @@ function useAccordion(input) {
203
216
  id: idProp
204
217
  } = config;
205
218
  if (process.env.NODE_ENV !== "production") {
206
- void Promise.resolve().then(() => _interopRequireWildcard(require("../validate-ELH6OKK3.cjs"))).then((m) => m.validateAccordion(input, config));
219
+ void Promise.resolve().then(() => _interopRequireWildcard(require("../validate-EQHBH4NH.cjs"))).then((m) => m.validateAccordion(input, config));
207
220
  }
208
221
  const appearance = {
209
222
  variant: (_a = config.variant) != null ? _a : "solid",
@@ -211,12 +224,13 @@ function useAccordion(input) {
211
224
  tone: (_c = config.tone) != null ? _c : ctx.tone,
212
225
  indicator: (_d = config.indicator) != null ? _d : "chevron",
213
226
  indicatorPosition: (_e = config.indicatorPosition) != null ? _e : "end",
214
- headingLevel: (_f = config.headingLevel) != null ? _f : 3,
215
- animate: (_g = config.animate) != null ? _g : !ctx.disableAnimation,
216
- dividers: (_h = config.dividers) != null ? _h : true,
217
- mountPanels: (_i = config.mountPanels) != null ? _i : config.unmountClosed ? "open" : "always",
218
- hiddenUntilFound: (_j = config.hiddenUntilFound) != null ? _j : true,
219
- unstyled: (_k = config.unstyled) != null ? _k : false
227
+ animateIndicator: (_f = config.animateIndicator) != null ? _f : true,
228
+ headingLevel: (_g = config.headingLevel) != null ? _g : 3,
229
+ animate: (_h = config.animate) != null ? _h : !ctx.disableAnimation,
230
+ dividers: (_i = config.dividers) != null ? _i : true,
231
+ mountPanels: (_j = config.mountPanels) != null ? _j : config.unmountClosed ? "open" : "always",
232
+ hiddenUntilFound: (_k = config.hiddenUntilFound) != null ? _k : true,
233
+ unstyled: (_l = config.unstyled) != null ? _l : false
220
234
  };
221
235
  const headingLevel = appearance.headingLevel;
222
236
  const baseId = _chunkVPKVOJHAcjs.useId.call(void 0, idProp);
@@ -229,10 +243,13 @@ function useAccordion(input) {
229
243
  );
230
244
  const items = React2.useMemo(
231
245
  () => itemConfigs.map((item, index) => {
246
+ var _a2, _b2;
232
247
  const id = _core.accordionRowId.call(void 0, item, index);
233
- return { id, index, disabled: allDisabled || !!item.disabled, config: item, ..._core.accordionPartIds.call(void 0, baseId, id) };
248
+ const disabled = allDisabled || !!item.disabled || ((_b2 = (_a2 = config.disabledIds) == null ? void 0 : _a2.indexOf(id)) != null ? _b2 : -1) !== -1;
249
+ return { id, index, disabled, config: item, ..._core.accordionPartIds.call(void 0, baseId, id) };
234
250
  }),
235
- [itemConfigs, baseId, allDisabled]
251
+ // eslint-disable-next-line react-hooks/exhaustive-deps
252
+ [itemConfigs, baseId, allDisabled, JSON.stringify(config.disabledIds)]
236
253
  );
237
254
  const [value, setValue] = _chunkVPKVOJHAcjs.useControllableState.call(void 0, {
238
255
  value: controlled,
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
- import { A as AccordionConfig, a as AccordionApi } from '../types-BZqk8btE.cjs';
2
+ import { A as AccordionConfig, a as AccordionMappedConfig, b as AccordionApi } from '../types-CkcgnWwL.cjs';
3
3
  import '@pinfold/core';
4
4
 
5
5
  /**
6
6
  * Thin JSX wrapper over `useAccordion()`, for one-off accordions that never
7
7
  * need the controller. It adds nothing the hook does not already do.
8
8
  */
9
- declare function Accordion(config: AccordionConfig): React.ReactElement;
9
+ declare function Accordion<Id extends string = string>(config: AccordionConfig<Id>): React.ReactElement;
10
+ declare function Accordion<Row extends object>(config: AccordionMappedConfig<Row>): React.ReactElement;
10
11
  declare namespace Accordion {
11
12
  var displayName: string;
12
13
  }
@@ -26,6 +27,8 @@ declare namespace Accordion {
26
27
  * Arrow/Home/End navigation between headers. Behaviour rules live in
27
28
  * `@pinfold/core` (accordion.logic.ts); this hook wires them to React.
28
29
  */
29
- declare function useAccordion(input: AccordionConfig): AccordionApi;
30
+ declare function useAccordion<Id extends string = string>(config: AccordionConfig<Id>): AccordionApi<Id>;
31
+ /** Raw records, mapped onto rows by `fields`. Ids come from the data, so they are `string`. */
32
+ declare function useAccordion<Row extends object>(config: AccordionMappedConfig<Row>): AccordionApi;
30
33
 
31
- export { Accordion, AccordionApi, AccordionConfig, useAccordion };
34
+ export { Accordion, AccordionApi, AccordionConfig, AccordionMappedConfig, useAccordion };
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
- import { A as AccordionConfig, a as AccordionApi } from '../types-BZqk8btE.js';
2
+ import { A as AccordionConfig, a as AccordionMappedConfig, b as AccordionApi } from '../types-CkcgnWwL.js';
3
3
  import '@pinfold/core';
4
4
 
5
5
  /**
6
6
  * Thin JSX wrapper over `useAccordion()`, for one-off accordions that never
7
7
  * need the controller. It adds nothing the hook does not already do.
8
8
  */
9
- declare function Accordion(config: AccordionConfig): React.ReactElement;
9
+ declare function Accordion<Id extends string = string>(config: AccordionConfig<Id>): React.ReactElement;
10
+ declare function Accordion<Row extends object>(config: AccordionMappedConfig<Row>): React.ReactElement;
10
11
  declare namespace Accordion {
11
12
  var displayName: string;
12
13
  }
@@ -26,6 +27,8 @@ declare namespace Accordion {
26
27
  * Arrow/Home/End navigation between headers. Behaviour rules live in
27
28
  * `@pinfold/core` (accordion.logic.ts); this hook wires them to React.
28
29
  */
29
- declare function useAccordion(input: AccordionConfig): AccordionApi;
30
+ declare function useAccordion<Id extends string = string>(config: AccordionConfig<Id>): AccordionApi<Id>;
31
+ /** Raw records, mapped onto rows by `fields`. Ids come from the data, so they are `string`. */
32
+ declare function useAccordion<Row extends object>(config: AccordionMappedConfig<Row>): AccordionApi;
30
33
 
31
- export { Accordion, AccordionApi, AccordionConfig, useAccordion };
34
+ export { Accordion, AccordionApi, AccordionConfig, AccordionMappedConfig, useAccordion };
@@ -31,8 +31,13 @@ import {
31
31
 
32
32
  // src/accordion/AccordionView.tsx
33
33
  import * as React from "react";
34
- import { cn, dimensionVars, mergeProps, resolveNode, shouldMountPanel } from "@pinfold/core";
34
+ import { accordionRowsJoined, cn, dimensionVars, mergeProps, resolveNode, shouldMountPanel } from "@pinfold/core";
35
35
  var B = "pinfold-accordion";
36
+ var RADIUS_SCALE = { none: 0, sm: 0.6, md: 1, lg: 1.5, full: 2.4 };
37
+ var GAP = { none: "0px", sm: "var(--pinfold-space-2)", md: "var(--pinfold-space-3)", lg: "var(--pinfold-space-5)" };
38
+ var own = (map, key) => typeof key === "string" && Object.prototype.hasOwnProperty.call(map, key);
39
+ var radiusValue = (r) => own(RADIUS_SCALE, r) ? `calc(var(--pinfold-acc-radius-unit) * ${RADIUS_SCALE[r]})` : r;
40
+ var gapValue = (g) => own(GAP, g) ? GAP[g] : g;
36
41
  var GLYPHS = {
37
42
  chevron: /* @__PURE__ */ React.createElement("path", { d: "M4 6.5 8 10.5 12 6.5" }),
38
43
  caret: /* @__PURE__ */ React.createElement("path", { d: "M6 4l5 4-5 4z", fill: "currentColor", stroke: "none" }),
@@ -57,18 +62,25 @@ function slot(ctx, name, base, item) {
57
62
  function renderRoot(ctx, rootProps) {
58
63
  var _a, _b;
59
64
  const { api, config, a } = ctx;
65
+ const dimensions = {
66
+ radius: radiusValue(config.radius),
67
+ itemRadius: radiusValue(config.itemRadius),
68
+ gap: gapValue(config.gap),
69
+ ...config.dimensions
70
+ };
60
71
  const props = api.getRootProps(
61
72
  mergeProps(
62
73
  slot(ctx, "root", {
63
74
  className: a.unstyled ? config.className : cn("pinfold", B, config.className),
64
- style: { ...dimensionVars("accordion", config.dimensions), ...config.style },
75
+ style: { ...dimensionVars("accordion", dimensions), ...config.style },
65
76
  "data-variant": a.variant,
66
77
  "data-size": a.size,
67
78
  "data-tone": a.tone,
68
- // Only an explicit radius; otherwise the provider's preset or a style pack reaches the root by inheritance.
69
- "data-pinfold-radius": config.radius,
70
79
  "data-indicator-position": a.indicatorPosition,
80
+ "data-static-indicator": a.animateIndicator ? void 0 : "",
71
81
  "data-dividers": a.dividers ? "" : void 0,
82
+ // Separated or filled rows with no gap join into one group (cards and ghost always touch).
83
+ "data-joined": (a.variant === "separated" || a.variant === "filled") && accordionRowsJoined(a.variant, dimensions.gap) ? "" : void 0,
72
84
  "data-animate": a.animate ? "" : void 0,
73
85
  "data-unstyled": a.unstyled ? "" : void 0,
74
86
  "data-scroll": ((_a = config.dimensions) == null ? void 0 : _a.panelMaxHeight) != null ? "" : void 0,
@@ -116,23 +128,24 @@ function renderHeader(ctx, item, extra, children) {
116
128
  ));
117
129
  }
118
130
  function TriggerContent({ ctx, item }) {
119
- var _a, _b;
120
- const { icon, title, description, badge } = item.config;
121
- const iconNode = resolveNode(icon, item);
131
+ var _a, _b, _c, _d;
132
+ const { title, description, badge } = item.config;
133
+ const iconNode = resolveNode((_a = item.config.icon) != null ? _a : ctx.config.icon, item);
134
+ const endIconNode = resolveNode((_b = item.config.endIcon) != null ? _b : ctx.config.endIcon, item);
122
135
  const descriptionNode = resolveNode(description, item);
123
136
  const badgeNode = resolveNode(badge, item);
124
- return /* @__PURE__ */ React.createElement(React.Fragment, null, iconNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "icon", { className: cls(ctx, `${B}__icon`), "aria-hidden": "true" }, item) }, iconNode) : null, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "label", { className: cls(ctx, `${B}__label`) }, item) }, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "title", { className: cls(ctx, `${B}__title`), ...overflowProps((_a = ctx.config.overflow) == null ? void 0 : _a.title, "wrap") }, item) }, resolveNode(title, item)), descriptionNode ? /* @__PURE__ */ React.createElement(
137
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, iconNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "icon", { className: cls(ctx, `${B}__icon`), "aria-hidden": "true" }, item) }, iconNode) : null, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "label", { className: cls(ctx, `${B}__label`) }, item) }, /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "title", { className: cls(ctx, `${B}__title`), ...overflowProps((_c = ctx.config.overflow) == null ? void 0 : _c.title, "wrap") }, item) }, resolveNode(title, item)), descriptionNode ? /* @__PURE__ */ React.createElement(
125
138
  "span",
126
139
  {
127
140
  ...slot(
128
141
  ctx,
129
142
  "description",
130
- { className: cls(ctx, `${B}__description`), ...overflowProps((_b = ctx.config.overflow) == null ? void 0 : _b.description, { lines: 2 }) },
143
+ { className: cls(ctx, `${B}__description`), ...overflowProps((_d = ctx.config.overflow) == null ? void 0 : _d.description, { lines: 2 }) },
131
144
  item
132
145
  )
133
146
  },
134
147
  descriptionNode
135
- ) : null), badgeNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "badge", { className: cls(ctx, `${B}__badge`) }, item) }, badgeNode) : null, renderIndicator(ctx, item));
148
+ ) : null), badgeNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "badge", { className: cls(ctx, `${B}__badge`) }, item) }, badgeNode) : null, endIconNode ? /* @__PURE__ */ React.createElement("span", { ...slot(ctx, "endIcon", { className: cls(ctx, `${B}__end-icon`), "aria-hidden": "true" }, item) }, endIconNode) : null, renderIndicator(ctx, item));
136
149
  }
137
150
  function renderIndicator(ctx, item, extra) {
138
151
  var _a;
@@ -183,7 +196,7 @@ var cls = (ctx, name) => ctx.a.unstyled ? void 0 : name;
183
196
 
184
197
  // src/accordion/useAccordion.tsx
185
198
  function useAccordion(input) {
186
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
199
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
187
200
  const ctx = usePinfold();
188
201
  const config = ctx.defaults.accordion ? { ...ctx.defaults.accordion, ...defined(input) } : input;
189
202
  const {
@@ -202,7 +215,7 @@ function useAccordion(input) {
202
215
  id: idProp
203
216
  } = config;
204
217
  if (process.env.NODE_ENV !== "production") {
205
- void import("../validate-D3GJ2276.js").then((m) => m.validateAccordion(input, config));
218
+ void import("../validate-WKHQNNGD.js").then((m) => m.validateAccordion(input, config));
206
219
  }
207
220
  const appearance = {
208
221
  variant: (_a = config.variant) != null ? _a : "solid",
@@ -210,12 +223,13 @@ function useAccordion(input) {
210
223
  tone: (_c = config.tone) != null ? _c : ctx.tone,
211
224
  indicator: (_d = config.indicator) != null ? _d : "chevron",
212
225
  indicatorPosition: (_e = config.indicatorPosition) != null ? _e : "end",
213
- headingLevel: (_f = config.headingLevel) != null ? _f : 3,
214
- animate: (_g = config.animate) != null ? _g : !ctx.disableAnimation,
215
- dividers: (_h = config.dividers) != null ? _h : true,
216
- mountPanels: (_i = config.mountPanels) != null ? _i : config.unmountClosed ? "open" : "always",
217
- hiddenUntilFound: (_j = config.hiddenUntilFound) != null ? _j : true,
218
- unstyled: (_k = config.unstyled) != null ? _k : false
226
+ animateIndicator: (_f = config.animateIndicator) != null ? _f : true,
227
+ headingLevel: (_g = config.headingLevel) != null ? _g : 3,
228
+ animate: (_h = config.animate) != null ? _h : !ctx.disableAnimation,
229
+ dividers: (_i = config.dividers) != null ? _i : true,
230
+ mountPanels: (_j = config.mountPanels) != null ? _j : config.unmountClosed ? "open" : "always",
231
+ hiddenUntilFound: (_k = config.hiddenUntilFound) != null ? _k : true,
232
+ unstyled: (_l = config.unstyled) != null ? _l : false
219
233
  };
220
234
  const headingLevel = appearance.headingLevel;
221
235
  const baseId = useId(idProp);
@@ -228,10 +242,13 @@ function useAccordion(input) {
228
242
  );
229
243
  const items = React2.useMemo(
230
244
  () => itemConfigs.map((item, index) => {
245
+ var _a2, _b2;
231
246
  const id = accordionRowId(item, index);
232
- return { id, index, disabled: allDisabled || !!item.disabled, config: item, ...accordionPartIds(baseId, id) };
247
+ const disabled = allDisabled || !!item.disabled || ((_b2 = (_a2 = config.disabledIds) == null ? void 0 : _a2.indexOf(id)) != null ? _b2 : -1) !== -1;
248
+ return { id, index, disabled, config: item, ...accordionPartIds(baseId, id) };
233
249
  }),
234
- [itemConfigs, baseId, allDisabled]
250
+ // eslint-disable-next-line react-hooks/exhaustive-deps
251
+ [itemConfigs, baseId, allDisabled, JSON.stringify(config.disabledIds)]
235
252
  );
236
253
  const [value, setValue] = useControllableState({
237
254
  value: controlled,
@@ -27,7 +27,8 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
27
 
28
28
  // src/accordion/index.ts
29
29
  function defineAccordion(config) {
30
- const Defined = ((props) => React__namespace.createElement(client_cjs.Accordion, { ...config, ...props }));
30
+ const Tag = client_cjs.Accordion;
31
+ const Defined = ((props) => React__namespace.createElement(Tag, { ...config, ...props }));
31
32
  Defined.config = config;
32
33
  Defined.displayName = "DefinedAccordion";
33
34
  return Defined;
@@ -1,13 +1,14 @@
1
1
  import * as React from 'react';
2
- import { A as AccordionConfig, a as AccordionApi, b as AccordionRootProps } from '../types-x01Q5sqz.cjs';
3
- export { c as AccordionAppearanceConfig, d as AccordionBehaviourConfig, e as AccordionDimensions, f as AccordionIndicator, g as AccordionItemConfig, h as AccordionItemState, i as AccordionNode, j as AccordionOverflow, k as AccordionPartProps, l as AccordionParts, m as AccordionSlot, n as AccordionState, o as AccordionValueDetails, p as AccordionVariant } from '../types-x01Q5sqz.cjs';
2
+ import { A as AccordionConfig, a as AccordionMappedConfig, b as AccordionApi, c as AnyAccordionConfig, d as AccordionRootProps } from '../types-N0Yo4zGa.cjs';
3
+ export { e as AccordionAppearanceConfig, f as AccordionBehaviourConfig, g as AccordionDimensions, h as AccordionGap, i as AccordionIndicator, j as AccordionItemConfig, k as AccordionItemId, l as AccordionItemState, m as AccordionNode, n as AccordionOptions, o as AccordionOverflow, p as AccordionPartProps, q as AccordionParts, r as AccordionRadius, s as AccordionSlot, t as AccordionState, u as AccordionValueDetails, v as AccordionVariant } from '../types-N0Yo4zGa.cjs';
4
4
  import '@pinfold/core';
5
5
 
6
6
  /**
7
7
  * Thin JSX wrapper over `useAccordion()`, for one-off accordions that never
8
8
  * need the controller. It adds nothing the hook does not already do.
9
9
  */
10
- declare function Accordion(config: AccordionConfig): React.ReactElement;
10
+ declare function Accordion<Id extends string = string>(config: AccordionConfig<Id>): React.ReactElement;
11
+ declare function Accordion<Row extends object>(config: AccordionMappedConfig<Row>): React.ReactElement;
11
12
  declare namespace Accordion {
12
13
  var displayName: string;
13
14
  }
@@ -27,11 +28,13 @@ declare namespace Accordion {
27
28
  * Arrow/Home/End navigation between headers. Behaviour rules live in
28
29
  * `@pinfold/core` (accordion.logic.ts); this hook wires them to React.
29
30
  */
30
- declare function useAccordion(input: AccordionConfig): AccordionApi;
31
+ declare function useAccordion<Id extends string = string>(config: AccordionConfig<Id>): AccordionApi<Id>;
32
+ /** Raw records, mapped onto rows by `fields`. Ids come from the data, so they are `string`. */
33
+ declare function useAccordion<Row extends object>(config: AccordionMappedConfig<Row>): AccordionApi;
31
34
 
32
35
  /** What `defineAccordion` returns: a component with the config baked in. */
33
- type DefinedAccordion = ((props: AccordionRootProps) => React.ReactElement) & {
34
- config: AccordionConfig;
36
+ type DefinedAccordion<Config = AnyAccordionConfig> = ((props: AccordionRootProps) => React.ReactElement) & {
37
+ config: Config;
35
38
  displayName?: string;
36
39
  };
37
40
  /**
@@ -46,7 +49,8 @@ type DefinedAccordion = ((props: AccordionRootProps) => React.ReactElement) & {
46
49
  * data and server-rendered JSX, no functions. For a controller (`Faq.toggle`)
47
50
  * use `useAccordion` in a client component.
48
51
  */
49
- declare function defineAccordion(config: AccordionConfig): DefinedAccordion;
52
+ declare function defineAccordion<Id extends string = string>(config: AccordionConfig<Id>): DefinedAccordion<AccordionConfig<Id>>;
53
+ declare function defineAccordion<Row extends object>(config: AccordionMappedConfig<Row>): DefinedAccordion<AccordionMappedConfig<Row>>;
50
54
 
51
- export { Accordion, AccordionApi, AccordionConfig, AccordionRootProps, Accordion as default, defineAccordion, useAccordion };
55
+ export { Accordion, AccordionApi, AccordionConfig, AccordionMappedConfig, AccordionRootProps, AnyAccordionConfig, Accordion as default, defineAccordion, useAccordion };
52
56
  export type { DefinedAccordion };
@@ -1,13 +1,14 @@
1
1
  import * as React from 'react';
2
- import { A as AccordionConfig, a as AccordionApi, b as AccordionRootProps } from '../types-x01Q5sqz.js';
3
- export { c as AccordionAppearanceConfig, d as AccordionBehaviourConfig, e as AccordionDimensions, f as AccordionIndicator, g as AccordionItemConfig, h as AccordionItemState, i as AccordionNode, j as AccordionOverflow, k as AccordionPartProps, l as AccordionParts, m as AccordionSlot, n as AccordionState, o as AccordionValueDetails, p as AccordionVariant } from '../types-x01Q5sqz.js';
2
+ import { A as AccordionConfig, a as AccordionMappedConfig, b as AccordionApi, c as AnyAccordionConfig, d as AccordionRootProps } from '../types-N0Yo4zGa.js';
3
+ export { e as AccordionAppearanceConfig, f as AccordionBehaviourConfig, g as AccordionDimensions, h as AccordionGap, i as AccordionIndicator, j as AccordionItemConfig, k as AccordionItemId, l as AccordionItemState, m as AccordionNode, n as AccordionOptions, o as AccordionOverflow, p as AccordionPartProps, q as AccordionParts, r as AccordionRadius, s as AccordionSlot, t as AccordionState, u as AccordionValueDetails, v as AccordionVariant } from '../types-N0Yo4zGa.js';
4
4
  import '@pinfold/core';
5
5
 
6
6
  /**
7
7
  * Thin JSX wrapper over `useAccordion()`, for one-off accordions that never
8
8
  * need the controller. It adds nothing the hook does not already do.
9
9
  */
10
- declare function Accordion(config: AccordionConfig): React.ReactElement;
10
+ declare function Accordion<Id extends string = string>(config: AccordionConfig<Id>): React.ReactElement;
11
+ declare function Accordion<Row extends object>(config: AccordionMappedConfig<Row>): React.ReactElement;
11
12
  declare namespace Accordion {
12
13
  var displayName: string;
13
14
  }
@@ -27,11 +28,13 @@ declare namespace Accordion {
27
28
  * Arrow/Home/End navigation between headers. Behaviour rules live in
28
29
  * `@pinfold/core` (accordion.logic.ts); this hook wires them to React.
29
30
  */
30
- declare function useAccordion(input: AccordionConfig): AccordionApi;
31
+ declare function useAccordion<Id extends string = string>(config: AccordionConfig<Id>): AccordionApi<Id>;
32
+ /** Raw records, mapped onto rows by `fields`. Ids come from the data, so they are `string`. */
33
+ declare function useAccordion<Row extends object>(config: AccordionMappedConfig<Row>): AccordionApi;
31
34
 
32
35
  /** What `defineAccordion` returns: a component with the config baked in. */
33
- type DefinedAccordion = ((props: AccordionRootProps) => React.ReactElement) & {
34
- config: AccordionConfig;
36
+ type DefinedAccordion<Config = AnyAccordionConfig> = ((props: AccordionRootProps) => React.ReactElement) & {
37
+ config: Config;
35
38
  displayName?: string;
36
39
  };
37
40
  /**
@@ -46,7 +49,8 @@ type DefinedAccordion = ((props: AccordionRootProps) => React.ReactElement) & {
46
49
  * data and server-rendered JSX, no functions. For a controller (`Faq.toggle`)
47
50
  * use `useAccordion` in a client component.
48
51
  */
49
- declare function defineAccordion(config: AccordionConfig): DefinedAccordion;
52
+ declare function defineAccordion<Id extends string = string>(config: AccordionConfig<Id>): DefinedAccordion<AccordionConfig<Id>>;
53
+ declare function defineAccordion<Row extends object>(config: AccordionMappedConfig<Row>): DefinedAccordion<AccordionMappedConfig<Row>>;
50
54
 
51
- export { Accordion, AccordionApi, AccordionConfig, AccordionRootProps, Accordion as default, defineAccordion, useAccordion };
55
+ export { Accordion, AccordionApi, AccordionConfig, AccordionMappedConfig, AccordionRootProps, AnyAccordionConfig, Accordion as default, defineAccordion, useAccordion };
52
56
  export type { DefinedAccordion };
@@ -4,7 +4,8 @@ import * as React from 'react';
4
4
 
5
5
  // src/accordion/index.ts
6
6
  function defineAccordion(config) {
7
- const Defined = ((props) => React.createElement(Accordion, { ...config, ...props }));
7
+ const Tag = Accordion;
8
+ const Defined = ((props) => React.createElement(Tag, { ...config, ...props }));
8
9
  Defined.config = config;
9
10
  Defined.displayName = "DefinedAccordion";
10
11
  return Defined;
@@ -1,6 +1,7 @@
1
- import * as React from 'react';
2
1
  import * as _pinfold_core from '@pinfold/core';
3
- import { A as AccordionConfig } from '../types-BZqk8btE.cjs';
2
+ import * as React from 'react';
3
+ import { c as AnyAccordionConfig } from '../types-CkcgnWwL.cjs';
4
+ export { A as AccordionConfig, a as AccordionMappedConfig } from '../types-CkcgnWwL.cjs';
4
5
 
5
6
  /**
6
7
  * Code-split entry point. Nothing accordion-related enters the main bundle
@@ -8,8 +9,8 @@ import { A as AccordionConfig } from '../types-BZqk8btE.cjs';
8
9
  *
9
10
  * import { Accordion } from '@pinfold/react/accordion/lazy';
10
11
  */
11
- declare const Accordion: React.ComponentType<AccordionConfig & {
12
+ declare const Accordion: React.ComponentType<AnyAccordionConfig & {
12
13
  lazy?: _pinfold_core.PinfoldLazy;
13
14
  }>;
14
15
 
15
- export { Accordion, AccordionConfig, Accordion as default };
16
+ export { Accordion, Accordion as default };
@@ -1,6 +1,7 @@
1
- import * as React from 'react';
2
1
  import * as _pinfold_core from '@pinfold/core';
3
- import { A as AccordionConfig } from '../types-BZqk8btE.js';
2
+ import * as React from 'react';
3
+ import { c as AnyAccordionConfig } from '../types-CkcgnWwL.js';
4
+ export { A as AccordionConfig, a as AccordionMappedConfig } from '../types-CkcgnWwL.js';
4
5
 
5
6
  /**
6
7
  * Code-split entry point. Nothing accordion-related enters the main bundle
@@ -8,8 +9,8 @@ import { A as AccordionConfig } from '../types-BZqk8btE.js';
8
9
  *
9
10
  * import { Accordion } from '@pinfold/react/accordion/lazy';
10
11
  */
11
- declare const Accordion: React.ComponentType<AccordionConfig & {
12
+ declare const Accordion: React.ComponentType<AnyAccordionConfig & {
12
13
  lazy?: _pinfold_core.PinfoldLazy;
13
14
  }>;
14
15
 
15
- export { Accordion, AccordionConfig, Accordion as default };
16
+ export { Accordion, Accordion as default };
package/dist/client.d.cts CHANGED
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
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';
3
+ import { d as AccordionOptions, S as SlotOverrides } from './types-CkcgnWwL.cjs';
4
+ export { P as PinfoldComponent, e as SlotRenderer, f as Slottable, u as usePinfoldComponent } from './types-CkcgnWwL.cjs';
6
5
 
7
6
  /** Per-component defaults. Data, state and ids never belong here, only how components look and behave. */
8
7
  interface PinfoldComponentDefaults {
9
- accordion?: Partial<Omit<AccordionConfig, 'items' | 'fields' | 'value' | 'defaultValue' | 'id'>>;
8
+ accordion?: Omit<AccordionOptions, 'value' | 'defaultValue' | 'disabledIds' | 'id'>;
10
9
  }
11
10
  /**
12
11
  * The global config, usually in `pinfold.config.ts` (or `.js`):
package/dist/client.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { PinfoldTheme, PinfoldRadius, PinfoldDir, PinfoldSize, PinfoldTone, PinfoldStylePack, PinfoldLazy, PropsBag } from '@pinfold/core';
3
- import { S as SlotOverrides } from './types-BZqk8btE.js';
4
- import { AccordionConfig } from './accordion/client.js';
5
- export { P as PinfoldComponent, b as SlotRenderer, c as Slottable, u as usePinfoldComponent } from './types-BZqk8btE.js';
3
+ import { d as AccordionOptions, S as SlotOverrides } from './types-CkcgnWwL.js';
4
+ export { P as PinfoldComponent, e as SlotRenderer, f as Slottable, u as usePinfoldComponent } from './types-CkcgnWwL.js';
6
5
 
7
6
  /** Per-component defaults. Data, state and ids never belong here, only how components look and behave. */
8
7
  interface PinfoldComponentDefaults {
9
- accordion?: Partial<Omit<AccordionConfig, 'items' | 'fields' | 'value' | 'defaultValue' | 'id'>>;
8
+ accordion?: Omit<AccordionOptions, 'value' | 'defaultValue' | 'disabledIds' | 'id'>;
10
9
  }
11
10
  /**
12
11
  * The global config, usually in `pinfold.config.ts` (or `.js`):
package/dist/index.d.cts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { PinfoldTheme, PinfoldRadius, PinfoldDir, PinfoldSize, PinfoldTone, PinfoldStylePack, PinfoldLazy, PropsBag } from '@pinfold/core';
3
- import { S as SlotOverrides } from './types-x01Q5sqz.cjs';
4
- import { AccordionConfig } from './accordion/index.cjs';
5
- export { P as PinfoldComponent, q as SlotRenderer, r as Slottable, u as usePinfoldComponent } from './types-x01Q5sqz.cjs';
3
+ import { S as SlotOverrides } from './types-N0Yo4zGa.cjs';
4
+ import { AccordionOptions } from './accordion/index.cjs';
5
+ export { P as PinfoldComponent, w as SlotRenderer, x as Slottable, y as usePinfoldComponent } from './types-N0Yo4zGa.cjs';
6
6
 
7
7
  /** Per-component defaults. Data, state and ids never belong here, only how components look and behave. */
8
8
  interface PinfoldComponentDefaults {
9
- accordion?: Partial<Omit<AccordionConfig, 'items' | 'fields' | 'value' | 'defaultValue' | 'id'>>;
9
+ accordion?: Omit<AccordionOptions, 'value' | 'defaultValue' | 'disabledIds' | 'id'>;
10
10
  }
11
11
  /**
12
12
  * The global config, usually in `pinfold.config.ts` (or `.js`):
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { PinfoldTheme, PinfoldRadius, PinfoldDir, PinfoldSize, PinfoldTone, PinfoldStylePack, PinfoldLazy, PropsBag } from '@pinfold/core';
3
- import { S as SlotOverrides } from './types-x01Q5sqz.js';
4
- import { AccordionConfig } from './accordion/index.js';
5
- export { P as PinfoldComponent, q as SlotRenderer, r as Slottable, u as usePinfoldComponent } from './types-x01Q5sqz.js';
3
+ import { S as SlotOverrides } from './types-N0Yo4zGa.js';
4
+ import { AccordionOptions } from './accordion/index.js';
5
+ export { P as PinfoldComponent, w as SlotRenderer, x as Slottable, y as usePinfoldComponent } from './types-N0Yo4zGa.js';
6
6
 
7
7
  /** Per-component defaults. Data, state and ids never belong here, only how components look and behave. */
8
8
  interface PinfoldComponentDefaults {
9
- accordion?: Partial<Omit<AccordionConfig, 'items' | 'fields' | 'value' | 'defaultValue' | 'id'>>;
9
+ accordion?: Omit<AccordionOptions, 'value' | 'defaultValue' | 'disabledIds' | 'id'>;
10
10
  }
11
11
  /**
12
12
  * The global config, usually in `pinfold.config.ts` (or `.js`):