@astryxdesign/core 0.1.8-canary.becff91 → 0.1.8-canary.ca17ee6

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.
@@ -25,7 +25,7 @@ export function computeDayCellState(input) {
25
25
  } = input;
26
26
  return {
27
27
  effectivelyDisabled: isDisabled || isOutside,
28
- isToday: plainDateIsEqual(date, today),
28
+ isToday: !isOutside && plainDateIsEqual(date, today),
29
29
  isSelected: !!(!isOutside && mode === 'single' && selectedDate && plainDateIsEqual(date, selectedDate)),
30
30
  isInRange: !!(!isOutside && mode === 'range' && rangeStart && rangeEnd && plainDateIsInRange(date, [rangeStart, rangeEnd])),
31
31
  isRangeStart: !!(!isOutside && mode === 'range' && rangeStart && plainDateIsEqual(date, rangeStart)),
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../src/Slider/Slider.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAO9C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,SAAS,CAAC,cAAc,CAAC,EACzB,UAAU,CACX;IACC,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAA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AE,MAAM,CAAC,KAAK,IAAI,CAAC;IAChD,8CAA8C;IAC9C,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AA2M/D;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,EAAC,GAAG,EAAE,GAAG,KAAK,EAAC,EAAE,WAAW,+BA2kBlD;yBA3kBe,MAAM"}
@@ -155,7 +155,10 @@ export function Slider({
155
155
 
156
156
  // Value helpers — guard against undefined value (e.g. playground previews
157
157
  // that render the component without providing a value prop).
158
- const values = useMemo(() => isRange ? value : [value != null ? value : min], [isRange, value, min]);
158
+ const values = useMemo(() => {
159
+ const currentValues = Array.isArray(value) ? value : [value != null ? value : min];
160
+ return currentValues.map(currentValue => clamp(currentValue, min, max));
161
+ }, [value, min, max]);
159
162
  const valuesRef = useRef(values);
160
163
  valuesRef.current = values;
161
164
  const getValueFromPosition = useCallback((clientX, clientY) => {
@@ -26,6 +26,22 @@ export interface UseTableTreeDataConfig<T extends Record<string, unknown>> {
26
26
  * identically to a Table without the plugin.
27
27
  */
28
28
  hasExpandableRows: boolean;
29
+ /**
30
+ * Aggregate expansion state across every expandable row. When provided
31
+ * together with `onExpandAll`/`onCollapseAll`, the tree column header shows
32
+ * an expand-all toggle. `useTableTreeState` supplies all three.
33
+ */
34
+ isAllExpanded?: boolean | 'indeterminate';
35
+ /** Expand every expandable row. Wired to the header expand-all control. */
36
+ onExpandAll?: () => void;
37
+ /** Collapse every row. Wired to the header expand-all control. */
38
+ onCollapseAll?: () => void;
39
+ /**
40
+ * Show the expand-all/collapse-all toggle in the tree column header. Needs
41
+ * `isAllExpanded` and `onExpandAll`/`onCollapseAll` to be present.
42
+ * @default false
43
+ */
44
+ hasExpandAllControl?: boolean;
29
45
  /**
30
46
  * Indent step per level, as spacing tokens.
31
47
  * @default 'md'
@@ -1 +1 @@
1
- {"version":3,"file":"useTableTreeData.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/tree/useTableTreeData.tsx"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAC,WAAW,EAAkC,MAAM,aAAa,CAAC;AAO9E,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACvE,qEAAqE;IACrE,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,gBAAgB,GAAG,SAAS,CAAC;IACtD,gCAAgC;IAChC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC5B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAqQD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAChC,WAAW,CAAC,CAAC,CAAC,CAgJhB"}
1
+ {"version":3,"file":"useTableTreeData.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/tree/useTableTreeData.tsx"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EACV,WAAW,EAIZ,MAAM,aAAa,CAAC;AAOrB,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACvE,qEAAqE;IACrE,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,gBAAgB,GAAG,SAAS,CAAC;IACtD,gCAAgC;IAChC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IAC1C,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC5B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA2TD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAChC,WAAW,CAAC,CAAC,CAAC,CAoMhB"}
@@ -179,6 +179,52 @@ function TreeExpander({
179
179
  })
180
180
  });
181
181
  }
182
+
183
+ /**
184
+ * Header expand-all/collapse-all toggle. Rendered in the tree column header
185
+ * when `hasExpandAllControl` is set and the state hook supplies the aggregate
186
+ * `isAllExpanded` plus `onExpandAll`/`onCollapseAll`. Shares the chevron
187
+ * affordance with the per-row expander; the chevron points down (expanded)
188
+ * only when every expandable row is expanded, matching the row expander.
189
+ */
190
+ function TreeExpandAllToggle({
191
+ isAllExpanded,
192
+ onExpandAll,
193
+ onCollapseAll
194
+ }) {
195
+ const t = useTranslator();
196
+ const allExpanded = isAllExpanded === true;
197
+ return /*#__PURE__*/_jsx("button", {
198
+ type: "button",
199
+ ...{
200
+ className: "x3nfvp2 x6s0dn4 xl56j7k xvy4d1p xxk0z11 xx3sua9 x1ypdohk xv9yike x1gbuem2 xx6bhzk x1717udv x2lah0s x1ilzqfv x1cqbx0l"
201
+ },
202
+ onClick: e => {
203
+ e.stopPropagation();
204
+ if (allExpanded) {
205
+ onCollapseAll();
206
+ } else {
207
+ onExpandAll();
208
+ }
209
+ },
210
+ "aria-label": allExpanded ? t('@astryx.tableTree.collapseAllRows') : t('@astryx.tableTree.expandAllRows'),
211
+ "aria-expanded": allExpanded,
212
+ children: /*#__PURE__*/_jsx("span", {
213
+ ...{
214
+ 0: {
215
+ className: "x3nfvp2 x11xpdln xx6bhzk x7p49u4"
216
+ },
217
+ 1: {
218
+ className: "x3nfvp2 x11xpdln xx6bhzk x1iffjtl"
219
+ }
220
+ }[!!allExpanded << 0],
221
+ children: /*#__PURE__*/_jsx(Icon, {
222
+ icon: "chevronRight",
223
+ size: "xsm"
224
+ })
225
+ })
226
+ });
227
+ }
182
228
  function TreeCellContent({
183
229
  item,
184
230
  children
@@ -255,6 +301,11 @@ export function useTableTreeData(config) {
255
301
  // react-compiler lint.
256
302
  const columnsCacheRef = useRef(null);
257
303
 
304
+ // The resolved tree column key, written by transformColumns (pipeline step 1)
305
+ // and read by transformHeaderCell (step 4) to place the expand-all toggle on
306
+ // the same column that carries the row expanders.
307
+ const treeKeyRef = useRef(undefined);
308
+
258
309
  // The plugin object is created once per store and never changes shape:
259
310
  // every transform reads the live config through the store, and
260
311
  // internally no-ops when hasExpandableRows is false. Swapping between
@@ -297,6 +348,7 @@ export function useTableTreeData(config) {
297
348
  // been hidden by columnSettings — the expander must not vanish).
298
349
  const configuredExists = treeColumnKey != null && columns.some(c => c.key === treeColumnKey);
299
350
  const treeKey = configuredExists ? treeColumnKey : columns.find(c => !c.key.startsWith('__'))?.key ?? columns[0]?.key;
351
+ treeKeyRef.current = treeKey;
300
352
 
301
353
  // Migration guarantee: flat data renders identically to a Table
302
354
  // without the plugin.
@@ -326,6 +378,41 @@ export function useTableTreeData(config) {
326
378
  };
327
379
  return output;
328
380
  },
381
+ transformHeaderCell(props, column) {
382
+ const {
383
+ hasExpandableRows,
384
+ hasExpandAllControl,
385
+ isAllExpanded,
386
+ onExpandAll,
387
+ onCollapseAll
388
+ } = store.getConfig();
389
+
390
+ // Only the tree column carries the toggle, and only when the control
391
+ // is enabled, the data is actually hierarchical, and the state hook
392
+ // supplied the aggregate state plus both handlers. Otherwise this is a
393
+ // pass-through (flat data stays a no-op).
394
+ if (!hasExpandAllControl || !hasExpandableRows || column.key !== treeKeyRef.current || isAllExpanded === undefined || !onExpandAll || !onCollapseAll) {
395
+ return props;
396
+ }
397
+
398
+ // Wrap the header label + the toggle in one inline-flex row so the
399
+ // chevron sits to the LEFT of the title on the same line. BaseTable
400
+ // only applies its own flex row for the `after` slot, so a bare
401
+ // `before` would stack above the label in the block-level <th>.
402
+ return {
403
+ ...props,
404
+ content: /*#__PURE__*/_jsxs("span", {
405
+ ...{
406
+ className: "x3nfvp2 x6s0dn4 xzye2dw xeuugli"
407
+ },
408
+ children: [/*#__PURE__*/_jsx(TreeExpandAllToggle, {
409
+ isAllExpanded: isAllExpanded,
410
+ onExpandAll: onExpandAll,
411
+ onCollapseAll: onCollapseAll
412
+ }), props.content]
413
+ })
414
+ };
415
+ },
329
416
  transformBodyRow(props, item) {
330
417
  // Attach a ref that subscribes to the store for imperative row
331
418
  // ARIA. The ref returns a cleanup so React unsubscribes on
@@ -42,6 +42,12 @@ export interface UseTableTreeStateResult<T extends Record<string, unknown>> {
42
42
  treeConfig: UseTableTreeDataConfig<T>;
43
43
  /** The current expanded row ids. */
44
44
  expandedIds: ReadonlySet<string>;
45
+ /**
46
+ * Aggregate expansion state across every expandable row: `true` when all are
47
+ * expanded, `false` when none are, `'indeterminate'` when some but not all
48
+ * are. Drives the header expand-all control. Reports `false` for flat data.
49
+ */
50
+ isAllExpanded: boolean | 'indeterminate';
45
51
  /** Expand every expandable row in the tree. */
46
52
  expandAll: () => void;
47
53
  /** Collapse every row. */
@@ -1 +1 @@
1
- {"version":3,"file":"useTableTreeState.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/tree/useTableTreeState.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAM5B,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxE,kEAAkE;IAClE,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,2EAA2E;IAC3E,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC,CAAC;IAC3D;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACzD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC5B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD,MAAM,WAAW,uBAAuB,CAAC,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OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC5B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxE,qEAAqE;IACrE,WAAW,EAAE,CAAC,EAAE,CAAC;IACjB,gDAAgD;IAChD,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACtC,oCAAoC;IACpC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC;;;;OAIG;IACH,aAAa,EAAE,OAAO,GAAG,eAAe,CAAC;IACzC,+CAA+C;IAC/C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAMD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACjC,uBAAuB,CAAC,CAAC,CAAC,CA0M5B"}
@@ -141,6 +141,23 @@ export function useTableTreeState(config) {
141
141
  return idsAcc;
142
142
  }, [data, getId, getChildren, getIsExpandable]);
143
143
  const hasExpandableRows = allExpandableIds.length > 0;
144
+
145
+ // Aggregate state for the header expand-all control. Only expandable ids
146
+ // count toward the total, so expanded ids that match a leaf or no row at
147
+ // all never skew the tally.
148
+ const isAllExpanded = useMemo(() => {
149
+ if (!hasExpandableRows) {
150
+ return false;
151
+ }
152
+ const expandedCount = allExpandableIds.filter(id => expandedIds.has(id)).length;
153
+ if (expandedCount === 0) {
154
+ return false;
155
+ }
156
+ if (expandedCount === allExpandableIds.length) {
157
+ return true;
158
+ }
159
+ return 'indeterminate';
160
+ }, [hasExpandableRows, allExpandableIds, expandedIds]);
144
161
  const onToggleItem = useCallback(item => {
145
162
  const id = getId(item);
146
163
  const next = new Set(expandedIdsRef.current);
@@ -162,13 +179,17 @@ export function useTableTreeState(config) {
162
179
  getRowMeta,
163
180
  onToggleItem,
164
181
  hasExpandableRows,
182
+ isAllExpanded,
183
+ onExpandAll: expandAll,
184
+ onCollapseAll: collapseAll,
165
185
  indent,
166
186
  treeColumnKey
167
- }), [getRowMeta, onToggleItem, hasExpandableRows, indent, treeColumnKey]);
187
+ }), [getRowMeta, onToggleItem, hasExpandableRows, isAllExpanded, expandAll, collapseAll, indent, treeColumnKey]);
168
188
  return {
169
189
  visibleData,
170
190
  treeConfig,
171
191
  expandedIds,
192
+ isAllExpanded,
172
193
  expandAll,
173
194
  collapseAll
174
195
  };