@nxgt/material 3.31.0 → 3.32.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @nxgt/material
2
2
 
3
+ ## 3.32.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1710](https://github.com/softistx/nxgt-material/pull/1710) [`d0a51eb`](https://github.com/softistx/nxgt-material/commit/d0a51eb58c63b1e8db2e47118e5b7c248ff3e1fe) Thanks [@SteveGT96](https://github.com/SteveGT96)! - Filter model: a field can declare the fields that depend on it, `resets: ['subcategory']` on `category` ([#1703](https://github.com/softistx/nxgt-material/issues/1703)). When its value changes through the bar, the phone sheet, a chip's ✕, a quick pill or a scope pill, the dependents are cleared in the same query change, so one URL write and one history entry, and the page goes back to the first page like any filter change. Chains hold (a resets b, b resets c: a clears both), a dependent with a `default` returns to it, and a scope field may reset others and be reset. A cycle, an unknown id or a field resetting itself throws in `defineFilterModel`. "Clear all", the codec, `effectiveConditions` and the loader are unchanged. Core: `applyFieldChange(query, model, fieldId, next)` and `resetFields(model, fieldId)` give an app writing the URL itself the same result.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`d0a51eb`](https://github.com/softistx/nxgt-material/commit/d0a51eb58c63b1e8db2e47118e5b7c248ff3e1fe)]:
12
+ - @nxgt/material-core@0.38.0
13
+
3
14
  ## 3.31.0
4
15
 
5
16
  ### Minor Changes
@@ -1613,6 +1613,44 @@ left out of "Add filter" and of the quick filters (also when listed in
1613
1613
  `quick`), and the phone sheet and the facets panel list its section only
1614
1614
  while the applied query holds a value. Core: `isAddableField(model, id)`.
1615
1615
 
1616
+ #### A field that resets the fields depending on it
1617
+
1618
+ A subcategory's options depend on the category: when the category changes, the
1619
+ subcategory's value may no longer exist. Declare it on the parent with `resets`:
1620
+
1621
+ ```ts
1622
+ const model = defineFilterModel({
1623
+ fields: [
1624
+ { id: 'category', type: 'select', label: 'Category', options: categories,
1625
+ quick: true, resets: ['subcategory'] },
1626
+ { id: 'subcategory', type: 'select', label: 'Subcategory', options: subcategories },
1627
+ ],
1628
+ });
1629
+ ```
1630
+
1631
+ When the category changes (the bar, the phone sheet, a chip's ✕, a quick pill
1632
+ or a scope pill) the subcategory's condition is cleared in the **same** query
1633
+ change: one URL write, one history entry (Back restores both), and the page
1634
+ param goes back to the first page like any filter change.
1635
+
1636
+ - **Chains.** a resets b and b resets c: changing a clears b and c. A cycle,
1637
+ an unknown id and a field resetting itself throw in `defineFilterModel`.
1638
+ - **Clearing the parent** clears its dependents too. Picking the value it
1639
+ already has changes nothing. "Clear all" is unchanged.
1640
+ - **A dependent with a `default`** returns to its default, not to empty. A
1641
+ `scope` field may reset others and be reset.
1642
+ - **A locked dependent** is left alone.
1643
+ - **"Add filter"**: the dependents are cleared as soon as the parent's value is
1644
+ entered; cancelling the flow (Escape, Back) restores the parent's previous
1645
+ value, not the dependents it cleared.
1646
+ - **Only writes from the UI** are shaped. The codec, `effectiveConditions`
1647
+ and the loader read a URL as it is, so `?category=b&subcategory=a1` from a
1648
+ link stays as written.
1649
+ - **Core.** An app writing the URL itself gets the same result with
1650
+ `applyFieldChange(query, model, 'category', condition)` (`null` removes the
1651
+ field), pure and returning the same query when nothing changed.
1652
+ `resetFields(model, 'category')` lists the fields a change resets.
1653
+
1616
1654
  #### A refused condition
1617
1655
 
1618
1656
  A server can refuse a value (a date span too long, an end before a start).
@@ -132,6 +132,7 @@ words in your error.
132
132
  - [A refused or reset edit stays in the filter bar](#a-refused-or-reset-edit-stays-in-the-filter-bar)
133
133
  - [`defineFilterModel: field "level" cannot use "gt" on a select field`](#definefiltermodel-field-level-cannot-use-gt-on-a-select-field)
134
134
  - [`defineFilterModel: field "x" can only set addable to false`](https://cdn.jsdelivr.net/npm/@nxgt/material-core@0/docs/troubleshooting.md#definefiltermodel-field-x-can-only-set-addable-to-false)
135
+ - [`defineFilterModel: field "x" is part of a resets cycle …`](https://cdn.jsdelivr.net/npm/@nxgt/material-core@0/docs/troubleshooting.md#definefiltermodel-field-x-is-part-of-a-resets-cycle--and-the-other-resets-errors)
135
136
  - [`defineFilterModel: field "x" default …` and `off …`](#definefiltermodel-field-x-default--and-off-)
136
137
  - [`defineFilterModel: field "period" scope needs a default operator taking one value`](#definefiltermodel-field-period-scope-needs-a-default-operator-taking-one-value)
137
138
  - [`errors` shows nothing on the filter bar](#errors-shows-nothing-on-the-filter-bar)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/material",
3
- "version": "3.31.0",
3
+ "version": "3.32.0",
4
4
  "license": "MIT",
5
5
  "bugs": {
6
6
  "email": "stevegires@gmail.com"
@@ -362,7 +362,7 @@
362
362
  "docs:previews": "rm -rf node_modules/.cache/nxgt-preview-free/missing && NXGT_PREVIEW_FREE=1 vitest run --project previews && bun .storybook/preview-free-report.ts"
363
363
  },
364
364
  "dependencies": {
365
- "@nxgt/material-core": "^0.37.0",
365
+ "@nxgt/material-core": "^0.38.0",
366
366
  "@base-ui/react": "^1.6.0",
367
367
  "@dnd-kit/core": "^6.3.1",
368
368
  "@dnd-kit/sortable": "^10.0.0",