@osdk/react-components 0.51.0 → 0.52.0-main-47c9c8958c61ca5c8529da4223833fb13622ef9e
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/AGENTS.md +1 -1
- package/CHANGELOG.md +20 -0
- package/build/browser/filter-list/FilterInput.js +1 -3
- package/build/browser/filter-list/FilterInput.js.map +1 -1
- package/build/browser/filter-list/hooks/useFilterListState.js +18 -2
- package/build/browser/filter-list/hooks/useFilterListState.js.map +1 -1
- package/build/browser/filter-list/types/CustomRendererTypes.js.map +1 -1
- package/build/browser/filter-list/utils/getSeedFilterState.js +1 -1
- package/build/browser/filter-list/utils/getSeedFilterState.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/chunk-43CELINZ.cjs +11 -0
- package/build/cjs/{chunk-AJAA7TFX.cjs.map → chunk-43CELINZ.cjs.map} +1 -1
- package/build/cjs/{chunk-7HT2BZL6.cjs → chunk-62OSZ22J.cjs} +21 -11
- package/build/cjs/chunk-62OSZ22J.cjs.map +1 -0
- package/build/cjs/{chunk-2SVTIRY7.cjs → chunk-6T5OSLJ7.cjs} +3 -3
- package/build/cjs/chunk-6T5OSLJ7.cjs.map +1 -0
- package/build/cjs/{chunk-SW74VLMH.cjs → chunk-7KP7M3T7.cjs} +4 -4
- package/build/cjs/{chunk-SW74VLMH.cjs.map → chunk-7KP7M3T7.cjs.map} +1 -1
- package/build/cjs/{chunk-CSRMHOGO.cjs → chunk-DCUE5ND6.cjs} +4 -4
- package/build/cjs/{chunk-CSRMHOGO.cjs.map → chunk-DCUE5ND6.cjs.map} +1 -1
- package/build/cjs/{chunk-GJOH3VCA.cjs → chunk-GHNSIVJQ.cjs} +4 -4
- package/build/cjs/{chunk-GJOH3VCA.cjs.map → chunk-GHNSIVJQ.cjs.map} +1 -1
- package/build/cjs/{chunk-WJXVWWOP.cjs → chunk-GUPKEFXW.cjs} +4 -4
- package/build/cjs/{chunk-WJXVWWOP.cjs.map → chunk-GUPKEFXW.cjs.map} +1 -1
- package/build/cjs/{chunk-637TFNOZ.cjs → chunk-KZRSAAGP.cjs} +4 -4
- package/build/cjs/{chunk-637TFNOZ.cjs.map → chunk-KZRSAAGP.cjs.map} +1 -1
- package/build/cjs/chunk-PV5RHNVV.cjs +11 -0
- package/build/cjs/{chunk-ZECNHOOX.cjs.map → chunk-PV5RHNVV.cjs.map} +1 -1
- package/build/cjs/{chunk-CKJUI6JX.cjs → chunk-QTWCE5WS.cjs} +4 -4
- package/build/cjs/{chunk-CKJUI6JX.cjs.map → chunk-QTWCE5WS.cjs.map} +1 -1
- package/build/cjs/chunk-ROPW3WGM.cjs +11 -0
- package/build/cjs/{chunk-DDJZYFH6.cjs.map → chunk-ROPW3WGM.cjs.map} +1 -1
- package/build/cjs/{chunk-C44UIYJU.cjs → chunk-RPUZINJR.cjs} +4 -4
- package/build/cjs/{chunk-C44UIYJU.cjs.map → chunk-RPUZINJR.cjs.map} +1 -1
- package/build/cjs/{chunk-H3PKYA7X.cjs → chunk-YMNUBMZJ.cjs} +4 -4
- package/build/cjs/{chunk-H3PKYA7X.cjs.map → chunk-YMNUBMZJ.cjs.map} +1 -1
- package/build/cjs/chunk-ZUDMOTCX.cjs +11 -0
- package/build/cjs/{chunk-SI4ZL7RL.cjs.map → chunk-ZUDMOTCX.cjs.map} +1 -1
- package/build/cjs/public/experimental/action-form.cjs +4 -4
- package/build/cjs/public/experimental/cbac-picker.cjs +11 -11
- package/build/cjs/public/experimental/document-viewer.cjs +4 -4
- package/build/cjs/public/experimental/email-viewer.cjs +3 -3
- package/build/cjs/public/experimental/filter-list.cjs +15 -15
- package/build/cjs/public/experimental/filter-list.d.cts +1 -1
- package/build/cjs/public/experimental/image-viewer.cjs +3 -3
- package/build/cjs/public/experimental/markdown-renderer.cjs +5 -5
- package/build/cjs/public/experimental/object-table.cjs +22 -22
- package/build/cjs/public/experimental/pdf-viewer.cjs +7 -7
- package/build/cjs/public/experimental/spreadsheet-viewer.cjs +3 -3
- package/build/cjs/public/experimental/tiff-renderer.cjs +5 -5
- package/build/cjs/public/experimental/video-viewer.cjs +3 -3
- package/build/cjs/public/experimental/xml-viewer.cjs +3 -3
- package/build/cjs/public/experimental.cjs +76 -76
- package/build/esm/filter-list/FilterInput.js +1 -3
- package/build/esm/filter-list/FilterInput.js.map +1 -1
- package/build/esm/filter-list/hooks/useFilterListState.js +18 -2
- package/build/esm/filter-list/hooks/useFilterListState.js.map +1 -1
- package/build/esm/filter-list/types/CustomRendererTypes.js.map +1 -1
- package/build/esm/filter-list/utils/getSeedFilterState.js +1 -1
- package/build/esm/filter-list/utils/getSeedFilterState.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/types/filter-list/FilterInput.d.ts.map +1 -1
- package/build/types/filter-list/types/CustomRendererTypes.d.ts +1 -1
- package/docs/FilterList.md +1 -1
- package/docs/PdfViewer.md +5 -0
- package/package.json +8 -8
- package/build/cjs/chunk-2SVTIRY7.cjs.map +0 -1
- package/build/cjs/chunk-7HT2BZL6.cjs.map +0 -1
- package/build/cjs/chunk-AJAA7TFX.cjs +0 -11
- package/build/cjs/chunk-DDJZYFH6.cjs +0 -11
- package/build/cjs/chunk-SI4ZL7RL.cjs +0 -11
- package/build/cjs/chunk-ZECNHOOX.cjs +0 -11
package/AGENTS.md
CHANGED
|
@@ -62,7 +62,7 @@ Components are imported from their individual entry points under `@osdk/react-co
|
|
|
62
62
|
| **BaseForm** | OSDK-agnostic base action form — use when supplying explicit field content and submit handling. |
|
|
63
63
|
| **ColumnConfigDialog** | Dialog for managing column visibility and drag-and-drop reordering. |
|
|
64
64
|
| **PdfViewer** | PDF viewer for OSDK Media objects with toolbar, search, annotations, sidebar (thumbnails/outline), highlight mode, and form fields. |
|
|
65
|
-
| **BasePdfViewer** | OSDK-agnostic base PDF viewer —
|
|
65
|
+
| **BasePdfViewer** | OSDK-agnostic base PDF viewer — `src` takes a URL, `ArrayBuffer`, `Uint8Array`, or `Blob`. Use when building custom data fetching on top of it. |
|
|
66
66
|
| **TiffViewer** | TIFF viewer for OSDK Media objects — fetches the TIFF contents and renders them onto a canvas. |
|
|
67
67
|
| **BaseTiffViewer** | OSDK-agnostic base TIFF viewer — accepts a `Uint8Array` and renders onto a canvas with size validation and error handling. |
|
|
68
68
|
| **MarkdownViewer** | Markdown viewer for OSDK Media objects — fetches the markdown text and renders it with styled headings, code blocks, tables, and links. |
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @osdk/react-components
|
|
2
2
|
|
|
3
|
+
## 0.52.0-main-47c9c8958c61ca5c8529da4223833fb13622ef9e
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 805e7d3: FilterList: a `CUSTOM` filter's seed now filters the object set, not just the input.
|
|
8
|
+
|
|
9
|
+
`filterState` and `defaultFilterState` are now read as one chain, `defaultFilterState` winning, so renaming preserves the value.
|
|
10
|
+
|
|
11
|
+
Also fixes the active filter count for `CUSTOM` filters, which counted any custom state as active. It now counts only when its `toWhereClause` produces a clause, matching what FilterList actually applies — so a seed that filters nothing no longer inflates the count.
|
|
12
|
+
|
|
13
|
+
- 47c9c89: Document the convention for a viewer's primary input prop. `src` names the binary source to render from, in whatever forms that renderer supports (a URL, raw bytes, or both); `content` names the already-decoded payload (text, or a parsed object). `BasePdfViewer.src` is the reference for the first, `BaseXmlViewer.content` for the second.
|
|
14
|
+
|
|
15
|
+
No API changes. `BaseTiffViewer`, `BaseEmailViewer` and `BaseSpreadsheetViewer` move onto the convention in follow-up changes, each keeping a deprecated alias for its old prop name.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @osdk/api@2.57.1-main-47c9c8958c61ca5c8529da4223833fb13622ef9e
|
|
20
|
+
- @osdk/client@2.57.1-main-47c9c8958c61ca5c8529da4223833fb13622ef9e
|
|
21
|
+
- @osdk/react@2.57.1-main-47c9c8958c61ca5c8529da4223833fb13622ef9e
|
|
22
|
+
|
|
3
23
|
## 0.51.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -80,9 +80,7 @@ function FilterInputInner({
|
|
|
80
80
|
"data-unsupported": "true"
|
|
81
81
|
}, "Custom filter missing renderInput");
|
|
82
82
|
}
|
|
83
|
-
const customFilterState = filterState?.type === "custom" ? filterState :
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback
|
|
85
|
-
definition.filterState ?? EMPTY_CUSTOM_STATE;
|
|
83
|
+
const customFilterState = filterState?.type === "custom" ? filterState : EMPTY_CUSTOM_STATE;
|
|
86
84
|
return /*#__PURE__*/React.createElement(React.Fragment, null, definition.renderInput({
|
|
87
85
|
objectType,
|
|
88
86
|
objectSet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterInput.js","names":["React","memo","useCallback","FilterInputExcludeRow","ContainsTextInput","ToggleInput","LinkedPropertyInput","PropertyFilterInput","StaticValuesFilterInput","EMPTY_CUSTOM_STATE","type","customState","FilterInputInner","objectType","objectSet","definition","filterState","onFilterStateChanged","whereClause","linkedFilters","showFilteredOutValues","searchQuery","excludeRowOpen","layout","createElement","HasLinkInput","Fragment","KeywordSearchInput","placeholder","label","renderInput","customFilterState","state","FilterInput","hasLink","isExcluding","handleChange","handleClearAll","onClearAll","enabled","onChange","searchTerm","undefined","operator","newSearchTerm","value"],"sources":["FilterInput.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport React, { memo, useCallback } from \"react\";\n\nimport { FilterInputExcludeRow } from \"./base/FilterInputExcludeRow.js\";\nimport { ContainsTextInput } from \"./base/inputs/ContainsTextInput.js\";\nimport type { MultiSelectInputLayout } from \"./base/inputs/MultiSelectInput.js\";\nimport { ToggleInput } from \"./base/inputs/ToggleInput.js\";\nimport type { FilterDefinitionUnion } from \"./FilterListApi.js\";\nimport type { FilterState } from \"./FilterListItemApi.js\";\nimport { LinkedPropertyInput } from \"./inputs/LinkedPropertyInput.js\";\nimport { PropertyFilterInput } from \"./inputs/PropertyFilterInput.js\";\nimport { StaticValuesFilterInput } from \"./inputs/StaticValuesFilterInput.js\";\nimport type { CustomFilterState } from \"./types/CustomRendererTypes.js\";\nimport type { LinkedFilter } from \"./types/LinkedFilterTypes.js\";\n\n/**\n * Handed to a custom filter's `renderInput` when the definition seeds no state\n * at all, so renderers can rely on always receiving a state object.\n */\nconst EMPTY_CUSTOM_STATE: CustomFilterState = {\n type: \"custom\",\n customState: {},\n};\n\nexport interface FilterInputProps<Q extends ObjectTypeDefinition> {\n objectType: Q;\n objectSet?: ObjectSet<Q>;\n definition: FilterDefinitionUnion<Q>;\n filterState: FilterState | undefined;\n onFilterStateChanged: (state: FilterState) => void;\n /** Per-filter excluding-self where clause (direct filters only). */\n whereClause: WhereClause<Q>;\n /** Per-filter excluding-self linked-filter records. */\n linkedFilters?: ReadonlyArray<LinkedFilter<Q>>;\n showFilteredOutValues?: boolean;\n searchQuery?: string;\n excludeRowOpen?: boolean;\n /**\n * Layout for `MULTI_SELECT` filter components. Pass `\"inline\"` when this\n * input renders inside a popover (or any container where chips would feel\n * redundant) so the value list is always visible. Defaults to `\"dropdown\"`,\n * which renders chips + a portaled Combobox popup. Ignored by other\n * filter components.\n */\n layout?: MultiSelectInputLayout;\n}\n\nfunction FilterInputInner<Q extends ObjectTypeDefinition>({\n objectType,\n objectSet,\n definition,\n filterState,\n onFilterStateChanged,\n whereClause,\n linkedFilters,\n showFilteredOutValues,\n searchQuery,\n excludeRowOpen,\n layout,\n}: FilterInputProps<Q>): React.ReactElement {\n switch (definition.type) {\n case \"HAS_LINK\":\n return (\n <HasLinkInput\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n excludeRowOpen={excludeRowOpen}\n />\n );\n\n case \"LINKED_PROPERTY\": {\n if (objectSet == null) {\n return <></>;\n }\n return (\n <LinkedPropertyInput\n objectSet={objectSet}\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n linkedFilters={linkedFilters}\n showFilteredOutValues={showFilteredOutValues}\n searchQuery={searchQuery}\n excludeRowOpen={excludeRowOpen}\n layout={layout}\n />\n );\n }\n\n case \"KEYWORD_SEARCH\":\n return (\n <KeywordSearchInput\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n placeholder={definition.label ?? \"Search...\"}\n />\n );\n\n case \"CUSTOM\": {\n if (!definition.renderInput) {\n return (\n <div data-unsupported=\"true\">Custom filter missing renderInput</div>\n );\n }\n const customFilterState =\n filterState?.type === \"custom\"\n ? filterState\n : // eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback\n (definition.filterState ?? EMPTY_CUSTOM_STATE);\n return (\n <>\n {definition.renderInput({\n objectType,\n objectSet,\n filterState: customFilterState,\n onFilterStateChanged: (state) => onFilterStateChanged(state),\n })}\n </>\n );\n }\n\n case \"PROPERTY\":\n return (\n <PropertyFilterInput\n objectType={objectType}\n objectSet={objectSet}\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n linkedFilters={linkedFilters}\n showFilteredOutValues={showFilteredOutValues}\n searchQuery={searchQuery}\n excludeRowOpen={excludeRowOpen}\n layout={layout}\n />\n );\n\n case \"STATIC_VALUES\":\n return (\n <StaticValuesFilterInput\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n searchQuery={searchQuery}\n excludeRowOpen={excludeRowOpen}\n layout={layout}\n />\n );\n\n default:\n return <div data-unsupported=\"true\">Unsupported filter type</div>;\n }\n}\n\nexport const FilterInput = memo(FilterInputInner) as typeof FilterInputInner;\n\ninterface HasLinkInputProps {\n filterState: FilterState | undefined;\n onFilterStateChanged: (state: FilterState) => void;\n excludeRowOpen?: boolean;\n}\n\nconst HasLinkInput = memo(function HasLinkInput({\n filterState,\n onFilterStateChanged,\n excludeRowOpen,\n}: HasLinkInputProps): React.ReactElement {\n const hasLink = filterState?.type === \"hasLink\" ? filterState.hasLink : false;\n const isExcluding =\n filterState?.type === \"hasLink\"\n ? (filterState.isExcluding ?? false)\n : false;\n\n const handleChange = useCallback(\n (hasLink: boolean) => {\n onFilterStateChanged({ type: \"hasLink\", hasLink, isExcluding });\n },\n [onFilterStateChanged, isExcluding],\n );\n\n const handleClearAll = useCallback(() => {\n onFilterStateChanged({ type: \"hasLink\", hasLink: false, isExcluding });\n }, [onFilterStateChanged, isExcluding]);\n\n return (\n <FilterInputExcludeRow\n excludeRowOpen={excludeRowOpen}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n onClearAll={handleClearAll}\n >\n <ToggleInput enabled={hasLink} onChange={handleChange} />\n </FilterInputExcludeRow>\n );\n});\n\ninterface KeywordSearchInputProps {\n filterState: FilterState | undefined;\n onFilterStateChanged: (state: FilterState) => void;\n placeholder: string;\n}\n\nconst KeywordSearchInput = memo(function KeywordSearchInput({\n filterState,\n onFilterStateChanged,\n placeholder,\n}: KeywordSearchInputProps): React.ReactElement {\n const searchTerm =\n filterState?.type === \"keywordSearch\" ? filterState.searchTerm : undefined;\n const operator =\n filterState?.type === \"keywordSearch\" ? filterState.operator : \"AND\";\n\n const handleChange = useCallback(\n (newSearchTerm: string | undefined) => {\n onFilterStateChanged({\n type: \"keywordSearch\",\n searchTerm: newSearchTerm ?? \"\",\n operator,\n });\n },\n [onFilterStateChanged, operator],\n );\n\n return (\n <ContainsTextInput\n value={searchTerm}\n onChange={handleChange}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,WAAW,QAAQ,OAAO;AAEhD,SAASC,qBAAqB,QAAQ,iCAAiC;AACvE,SAASC,iBAAiB,QAAQ,oCAAoC;AAEtE,SAASC,WAAW,QAAQ,8BAA8B;AAG1D,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,uBAAuB,QAAQ,qCAAqC;AAI7E;AACA;AACA;AACA;AACA,MAAMC,kBAAqC,GAAG;EAC5CC,IAAI,EAAE,QAAQ;EACdC,WAAW,EAAE,CAAC;AAChB,CAAC;AAyBD,SAASC,gBAAgBA,CAAiC;EACxDC,UAAU;EACVC,SAAS;EACTC,UAAU;EACVC,WAAW;EACXC,oBAAoB;EACpBC,WAAW;EACXC,aAAa;EACbC,qBAAqB;EACrBC,WAAW;EACXC,cAAc;EACdC;AACmB,CAAC,EAAsB;EAC1C,QAAQR,UAAU,CAACL,IAAI;IACrB,KAAK,UAAU;MACb,oBACEV,KAAA,CAAAwB,aAAA,CAACC,YAAY;QACXT,WAAW,EAAEA,WAAY;QACzBC,oBAAoB,EAAEA,oBAAqB;QAC3CK,cAAc,EAAEA;MAAe,CAChC,CAAC;IAGN,KAAK,iBAAiB;MAAE;QACtB,IAAIR,SAAS,IAAI,IAAI,EAAE;UACrB,oBAAOd,KAAA,CAAAwB,aAAA,CAAAxB,KAAA,CAAA0B,QAAA,MAAI,CAAC;QACd;QACA,oBACE1B,KAAA,CAAAwB,aAAA,CAAClB,mBAAmB;UAClBQ,SAAS,EAAEA,SAAU;UACrBC,UAAU,EAAEA,UAAW;UACvBC,WAAW,EAAEA,WAAY;UACzBC,oBAAoB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B,cAAc,EAAEA,cAAe;IAC/BN,WAAW,EAAEA,WAAY;IACzBC,oBAAoB,EAAEA,oBAAqB;IAC3CqB,UAAU,EAAED;EAAe,gBAE3BrC,KAAA,CAAAwB,aAAA,CAACnB,WAAW;IAACkC,OAAO,EAAEL,OAAQ;IAACM,QAAQ,EAAEJ;EAAa,CAAE,CACnC,CAAC;AAE5B,CAAC,CAAC;AAQF,MAAMT,kBAAkB,gBAAG1B,IAAI,CAAC,UAA4B;EAC1De,WAAW;EACXC,oBAAoB;EACpBW;AACuB,CAAC,EAAsB;EAC9C,MAAMa,UAAU,GACdzB,WAAW,EAAEN,IAAI,KAAK,eAAe,GAAGM,WAAW,CAACyB,UAAU,GAAGC,SAAS;EAC5E,MAAMC,QAAQ,GACZ3B,WAAW,EAAEN,IAAI,KAAK,eAAe,GAAGM,WAAW,CAAC2B,QAAQ,GAAG,KAAK;EAEtE,MAAMP,YAAY,GAAGlC,WAAW,CAC7B0C,aAAiC,IAAK;IACrC3B,oBAAoB,CAAC;MACnBP,IAAI,EAAE,eAAe;MACrB+B,UAAU,EAAEG,aAAa,IAAI,EAAE;MAC/BD;IACF,CAAC,CAAC;EACJ,CAAC,EACD,CAAC1B,oBAAoB,EAAE0B,QAAQ,CACjC,CAAC;EAED,oBACE3C,KAAA,CAAAwB,aAAA,CAACpB,iBAAiB;IAChByC,KAAK,EAAEJ,UAAW;IAClBD,QAAQ,EAAEJ,YAAa;IACvBR,WAAW,EAAEA;EAAY,CAC1B,CAAC;AAEN,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FilterInput.js","names":["React","memo","useCallback","FilterInputExcludeRow","ContainsTextInput","ToggleInput","LinkedPropertyInput","PropertyFilterInput","StaticValuesFilterInput","EMPTY_CUSTOM_STATE","type","customState","FilterInputInner","objectType","objectSet","definition","filterState","onFilterStateChanged","whereClause","linkedFilters","showFilteredOutValues","searchQuery","excludeRowOpen","layout","createElement","HasLinkInput","Fragment","KeywordSearchInput","placeholder","label","renderInput","customFilterState","state","FilterInput","hasLink","isExcluding","handleChange","handleClearAll","onClearAll","enabled","onChange","searchTerm","undefined","operator","newSearchTerm","value"],"sources":["FilterInput.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport React, { memo, useCallback } from \"react\";\n\nimport { FilterInputExcludeRow } from \"./base/FilterInputExcludeRow.js\";\nimport { ContainsTextInput } from \"./base/inputs/ContainsTextInput.js\";\nimport type { MultiSelectInputLayout } from \"./base/inputs/MultiSelectInput.js\";\nimport { ToggleInput } from \"./base/inputs/ToggleInput.js\";\nimport type { FilterDefinitionUnion } from \"./FilterListApi.js\";\nimport type { FilterState } from \"./FilterListItemApi.js\";\nimport { LinkedPropertyInput } from \"./inputs/LinkedPropertyInput.js\";\nimport { PropertyFilterInput } from \"./inputs/PropertyFilterInput.js\";\nimport { StaticValuesFilterInput } from \"./inputs/StaticValuesFilterInput.js\";\nimport type { CustomFilterState } from \"./types/CustomRendererTypes.js\";\nimport type { LinkedFilter } from \"./types/LinkedFilterTypes.js\";\n\n/**\n * Handed to a custom filter's `renderInput` when the definition seeds no state\n * at all, so renderers can rely on always receiving a state object.\n */\nconst EMPTY_CUSTOM_STATE: CustomFilterState = {\n type: \"custom\",\n customState: {},\n};\n\nexport interface FilterInputProps<Q extends ObjectTypeDefinition> {\n objectType: Q;\n objectSet?: ObjectSet<Q>;\n definition: FilterDefinitionUnion<Q>;\n filterState: FilterState | undefined;\n onFilterStateChanged: (state: FilterState) => void;\n /** Per-filter excluding-self where clause (direct filters only). */\n whereClause: WhereClause<Q>;\n /** Per-filter excluding-self linked-filter records. */\n linkedFilters?: ReadonlyArray<LinkedFilter<Q>>;\n showFilteredOutValues?: boolean;\n searchQuery?: string;\n excludeRowOpen?: boolean;\n /**\n * Layout for `MULTI_SELECT` filter components. Pass `\"inline\"` when this\n * input renders inside a popover (or any container where chips would feel\n * redundant) so the value list is always visible. Defaults to `\"dropdown\"`,\n * which renders chips + a portaled Combobox popup. Ignored by other\n * filter components.\n */\n layout?: MultiSelectInputLayout;\n}\n\nfunction FilterInputInner<Q extends ObjectTypeDefinition>({\n objectType,\n objectSet,\n definition,\n filterState,\n onFilterStateChanged,\n whereClause,\n linkedFilters,\n showFilteredOutValues,\n searchQuery,\n excludeRowOpen,\n layout,\n}: FilterInputProps<Q>): React.ReactElement {\n switch (definition.type) {\n case \"HAS_LINK\":\n return (\n <HasLinkInput\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n excludeRowOpen={excludeRowOpen}\n />\n );\n\n case \"LINKED_PROPERTY\": {\n if (objectSet == null) {\n return <></>;\n }\n return (\n <LinkedPropertyInput\n objectSet={objectSet}\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n linkedFilters={linkedFilters}\n showFilteredOutValues={showFilteredOutValues}\n searchQuery={searchQuery}\n excludeRowOpen={excludeRowOpen}\n layout={layout}\n />\n );\n }\n\n case \"KEYWORD_SEARCH\":\n return (\n <KeywordSearchInput\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n placeholder={definition.label ?? \"Search...\"}\n />\n );\n\n case \"CUSTOM\": {\n if (!definition.renderInput) {\n return (\n <div data-unsupported=\"true\">Custom filter missing renderInput</div>\n );\n }\n const customFilterState =\n filterState?.type === \"custom\" ? filterState : EMPTY_CUSTOM_STATE;\n return (\n <>\n {definition.renderInput({\n objectType,\n objectSet,\n filterState: customFilterState,\n onFilterStateChanged: (state) => onFilterStateChanged(state),\n })}\n </>\n );\n }\n\n case \"PROPERTY\":\n return (\n <PropertyFilterInput\n objectType={objectType}\n objectSet={objectSet}\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n linkedFilters={linkedFilters}\n showFilteredOutValues={showFilteredOutValues}\n searchQuery={searchQuery}\n excludeRowOpen={excludeRowOpen}\n layout={layout}\n />\n );\n\n case \"STATIC_VALUES\":\n return (\n <StaticValuesFilterInput\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n searchQuery={searchQuery}\n excludeRowOpen={excludeRowOpen}\n layout={layout}\n />\n );\n\n default:\n return <div data-unsupported=\"true\">Unsupported filter type</div>;\n }\n}\n\nexport const FilterInput = memo(FilterInputInner) as typeof FilterInputInner;\n\ninterface HasLinkInputProps {\n filterState: FilterState | undefined;\n onFilterStateChanged: (state: FilterState) => void;\n excludeRowOpen?: boolean;\n}\n\nconst HasLinkInput = memo(function HasLinkInput({\n filterState,\n onFilterStateChanged,\n excludeRowOpen,\n}: HasLinkInputProps): React.ReactElement {\n const hasLink = filterState?.type === \"hasLink\" ? filterState.hasLink : false;\n const isExcluding =\n filterState?.type === \"hasLink\"\n ? (filterState.isExcluding ?? false)\n : false;\n\n const handleChange = useCallback(\n (hasLink: boolean) => {\n onFilterStateChanged({ type: \"hasLink\", hasLink, isExcluding });\n },\n [onFilterStateChanged, isExcluding],\n );\n\n const handleClearAll = useCallback(() => {\n onFilterStateChanged({ type: \"hasLink\", hasLink: false, isExcluding });\n }, [onFilterStateChanged, isExcluding]);\n\n return (\n <FilterInputExcludeRow\n excludeRowOpen={excludeRowOpen}\n filterState={filterState}\n onFilterStateChanged={onFilterStateChanged}\n onClearAll={handleClearAll}\n >\n <ToggleInput enabled={hasLink} onChange={handleChange} />\n </FilterInputExcludeRow>\n );\n});\n\ninterface KeywordSearchInputProps {\n filterState: FilterState | undefined;\n onFilterStateChanged: (state: FilterState) => void;\n placeholder: string;\n}\n\nconst KeywordSearchInput = memo(function KeywordSearchInput({\n filterState,\n onFilterStateChanged,\n placeholder,\n}: KeywordSearchInputProps): React.ReactElement {\n const searchTerm =\n filterState?.type === \"keywordSearch\" ? filterState.searchTerm : undefined;\n const operator =\n filterState?.type === \"keywordSearch\" ? filterState.operator : \"AND\";\n\n const handleChange = useCallback(\n (newSearchTerm: string | undefined) => {\n onFilterStateChanged({\n type: \"keywordSearch\",\n searchTerm: newSearchTerm ?? \"\",\n operator,\n });\n },\n [onFilterStateChanged, operator],\n );\n\n return (\n <ContainsTextInput\n value={searchTerm}\n onChange={handleChange}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,WAAW,QAAQ,OAAO;AAEhD,SAASC,qBAAqB,QAAQ,iCAAiC;AACvE,SAASC,iBAAiB,QAAQ,oCAAoC;AAEtE,SAASC,WAAW,QAAQ,8BAA8B;AAG1D,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,uBAAuB,QAAQ,qCAAqC;AAI7E;AACA;AACA;AACA;AACA,MAAMC,kBAAqC,GAAG;EAC5CC,IAAI,EAAE,QAAQ;EACdC,WAAW,EAAE,CAAC;AAChB,CAAC;AAyBD,SAASC,gBAAgBA,CAAiC;EACxDC,UAAU;EACVC,SAAS;EACTC,UAAU;EACVC,WAAW;EACXC,oBAAoB;EACpBC,WAAW;EACXC,aAAa;EACbC,qBAAqB;EACrBC,WAAW;EACXC,cAAc;EACdC;AACmB,CAAC,EAAsB;EAC1C,QAAQR,UAAU,CAACL,IAAI;IACrB,KAAK,UAAU;MACb,oBACEV,KAAA,CAAAwB,aAAA,CAACC,YAAY;QACXT,WAAW,EAAEA,WAAY;QACzBC,oBAAoB,EAAEA,oBAAqB;QA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AAC,CAAC","ignoreList":[]}
|
|
@@ -137,13 +137,29 @@ export function useFilterListState(props) {
|
|
|
137
137
|
}, [filterDefinitions, filterStates]));
|
|
138
138
|
const activeFilterCount = useMemo(() => {
|
|
139
139
|
let count = 0;
|
|
140
|
-
for (const
|
|
140
|
+
for (const definition of filterDefinitions ?? []) {
|
|
141
|
+
const state = filterStates.get(getFilterKey(definition));
|
|
142
|
+
if (state == null) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
// A custom filter's state is opaque, so `filterHasActiveState` can only
|
|
146
|
+
// say "some state exists". Only its own `toWhereClause` knows whether
|
|
147
|
+
// that state filters anything, so match what `buildWhereClause` keeps.
|
|
148
|
+
if (definition.type === "CUSTOM") {
|
|
149
|
+
if (state.type === "custom") {
|
|
150
|
+
const clause = definition.toWhereClause(state);
|
|
151
|
+
if (clause != null && Object.keys(clause).length > 0) {
|
|
152
|
+
count++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
141
157
|
if (filterHasActiveState(state)) {
|
|
142
158
|
count++;
|
|
143
159
|
}
|
|
144
160
|
}
|
|
145
161
|
return count;
|
|
146
|
-
}, [filterStates]);
|
|
162
|
+
}, [filterDefinitions, filterStates]);
|
|
147
163
|
const hasChangesFromInitial = useMemo(() => !isEqual(filterStates, initialFilterStatesSnapshot), [filterStates, initialFilterStatesSnapshot]);
|
|
148
164
|
return useMemo(() => ({
|
|
149
165
|
filterStates,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterListState.js","names":["useOsdkMetadata","isEqual","useCallback","useEffect","useMemo","useRef","useState","buildWhereClause","getActiveLinkedFilters","filterHasActiveState","getFilterKey","getSeedFilterState","narrowObjectSet","useStableMapEntries","buildInitialStates","definitions","states","Map","definition","state","set","useFilterListState","props","objectType","objectSet","filterDefinitions","onFilterStateChanged","onFilterClauseChanged","onEffectiveObjectSet","defaultFilterStates","initialFilterStates","seededFilterStates","metadata","onFilterClauseChangedRef","current","onEffectiveObjectSetRef","filterDefinitionsRef","propertyTypes","map","properties","key","prop","Object","entries","type","multiplicity","initialFilterStatesSnapshot","snapshot","filterStates","setFilterStates","setFilterState","filterKey","prev","next","find","d","clearFilterState","delete","reset","whereClause","linkedFilters","effectiveObjectSet","undefined","perFilterWhereClauses","perFilterLinkedFilters","activeFilterCount","count","values","hasChangesFromInitial"],"sources":["useFilterListState.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport { useOsdkMetadata } from \"@osdk/react\";\nimport { isEqual } from \"lodash-es\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { FilterListProps } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport type { LinkedFilter } from \"../types/LinkedFilterTypes.js\";\nimport {\n buildWhereClause,\n getActiveLinkedFilters,\n type PropertyTypeInfo,\n} from \"../utils/filterStateToWhereClause.js\";\nimport { filterHasActiveState } from \"../utils/filterValues.js\";\nimport { getFilterKey } from \"../utils/getFilterKey.js\";\nimport { getSeedFilterState } from \"../utils/getSeedFilterState.js\";\nimport { narrowObjectSet } from \"../utils/narrowObjectSet.js\";\nimport { useStableMapEntries } from \"./useStableMapEntries.js\";\n\nexport interface UseFilterListStateResult<Q extends ObjectTypeDefinition> {\n filterStates: Map<string, FilterState>;\n setFilterState: (filterKey: string, state: FilterState) => void;\n clearFilterState: (filterKey: string) => void;\n /** Direct (non-link-traversing) filters combined into a `WhereClause<Q>`. */\n whereClause: WhereClause<Q>;\n /** Active linked-property records; apply via `narrowObjectSet`. */\n linkedFilters: ReadonlyArray<LinkedFilter<Q>>;\n /** Per-filter excluding-self where clauses keyed by `getFilterKey`. */\n perFilterWhereClauses: Map<string, WhereClause<Q>>;\n /** Per-filter excluding-self linked filters keyed by `getFilterKey`. */\n perFilterLinkedFilters: Map<string, ReadonlyArray<LinkedFilter<Q>>>;\n activeFilterCount: number;\n hasChangesFromInitial: boolean;\n reset: () => void;\n}\n\nfunction buildInitialStates<Q extends ObjectTypeDefinition>(\n definitions: FilterListProps<Q>[\"filterDefinitions\"],\n): Map<string, FilterState> {\n const states = new Map<string, FilterState>();\n\n if (!definitions) {\n return states;\n }\n\n for (const definition of definitions) {\n const state = getSeedFilterState(definition);\n if (state) {\n states.set(getFilterKey(definition), state);\n }\n }\n\n return states;\n}\n\nexport function useFilterListState<Q extends ObjectTypeDefinition>(\n props: FilterListProps<Q>,\n): UseFilterListStateResult<Q> {\n const {\n objectType,\n objectSet,\n filterDefinitions,\n onFilterStateChanged,\n onFilterClauseChanged,\n onEffectiveObjectSet,\n defaultFilterStates,\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- back-compat fallback for the pre-rename prop\n initialFilterStates,\n } = props;\n const seededFilterStates = defaultFilterStates ?? initialFilterStates;\n const { metadata } = useOsdkMetadata(objectType);\n const onFilterClauseChangedRef = useRef(onFilterClauseChanged);\n onFilterClauseChangedRef.current = onFilterClauseChanged;\n const onEffectiveObjectSetRef = useRef(onEffectiveObjectSet);\n onEffectiveObjectSetRef.current = onEffectiveObjectSet;\n const filterDefinitionsRef = useRef(filterDefinitions);\n filterDefinitionsRef.current = filterDefinitions;\n\n const propertyTypes = useMemo(() => {\n const map = new Map<string, PropertyTypeInfo>();\n if (metadata?.properties) {\n for (const [key, prop] of Object.entries(metadata.properties)) {\n if (typeof prop.type === \"string\") {\n map.set(key, {\n type: prop.type,\n multiplicity: prop.multiplicity === true,\n });\n }\n }\n }\n return map;\n }, [metadata?.properties]);\n\n // Captured once on first render to provide a stable baseline for the reset\n // button's enabled state. `useState`'s lazy initializer pins the value for\n // the lifetime of the component (unlike `useMemo`, which React may discard).\n const [initialFilterStatesSnapshot] = useState<Map<string, FilterState>>(\n () => {\n const snapshot = buildInitialStates(filterDefinitions);\n if (seededFilterStates) {\n for (const [key, state] of seededFilterStates) {\n snapshot.set(key, state);\n }\n }\n return snapshot;\n },\n );\n\n const [filterStates, setFilterStates] = useState<Map<string, FilterState>>(\n () => new Map(initialFilterStatesSnapshot),\n );\n\n const setFilterState = useCallback(\n (filterKey: string, state: FilterState) => {\n setFilterStates((prev) => {\n const next = new Map(prev);\n next.set(filterKey, state);\n return next;\n });\n\n const definition = filterDefinitionsRef.current?.find(\n (d) => getFilterKey(d) === filterKey,\n );\n if (definition) {\n onFilterStateChanged?.(definition, state);\n }\n },\n [onFilterStateChanged],\n );\n\n const clearFilterState = useCallback((filterKey: string) => {\n setFilterStates((prev) => {\n const next = new Map(prev);\n next.delete(filterKey);\n return next;\n });\n }, []);\n\n const reset = useCallback(() => {\n setFilterStates(new Map(initialFilterStatesSnapshot));\n }, [initialFilterStatesSnapshot]);\n\n const whereClause = useMemo(\n () => buildWhereClause(filterDefinitions, filterStates, propertyTypes),\n [filterDefinitions, filterStates, propertyTypes],\n );\n\n const linkedFilters = useMemo(\n () => getActiveLinkedFilters(filterDefinitions, filterStates),\n [filterDefinitions, filterStates],\n );\n\n const effectiveObjectSet = useMemo<ObjectSet<Q> | undefined>(\n () =>\n objectSet == null\n ? undefined\n : narrowObjectSet(objectSet, whereClause, linkedFilters),\n [objectSet, whereClause, linkedFilters],\n );\n\n useEffect(() => {\n onFilterClauseChangedRef.current?.(whereClause);\n }, [whereClause]);\n\n useEffect(() => {\n if (effectiveObjectSet == null) {\n return;\n }\n onEffectiveObjectSetRef.current?.(effectiveObjectSet);\n }, [effectiveObjectSet]);\n\n const perFilterWhereClauses = useStableMapEntries(\n useMemo(() => {\n const map = new Map<string, WhereClause<Q>>();\n for (const definition of filterDefinitions ?? []) {\n const key = getFilterKey(definition);\n map.set(\n key,\n buildWhereClause(filterDefinitions, filterStates, propertyTypes, key),\n );\n }\n return map;\n }, [filterDefinitions, filterStates, propertyTypes]),\n );\n\n const perFilterLinkedFilters = useStableMapEntries(\n useMemo(() => {\n const map = new Map<string, ReadonlyArray<LinkedFilter<Q>>>();\n for (const definition of filterDefinitions ?? []) {\n const key = getFilterKey(definition);\n map.set(\n key,\n getActiveLinkedFilters(filterDefinitions, filterStates, key),\n );\n }\n return map;\n }, [filterDefinitions, filterStates]),\n );\n\n const activeFilterCount = useMemo(() => {\n let count = 0;\n for (const state of filterStates.values()) {\n if (filterHasActiveState(state)) {\n count++;\n }\n }\n return count;\n }, [filterStates]);\n\n const hasChangesFromInitial = useMemo(\n () => !isEqual(filterStates, initialFilterStatesSnapshot),\n [filterStates, initialFilterStatesSnapshot],\n );\n\n return useMemo(\n () => ({\n filterStates,\n setFilterState,\n clearFilterState,\n whereClause,\n linkedFilters,\n perFilterWhereClauses,\n perFilterLinkedFilters,\n activeFilterCount,\n hasChangesFromInitial,\n reset,\n }),\n [\n filterStates,\n setFilterState,\n clearFilterState,\n whereClause,\n linkedFilters,\n perFilterWhereClauses,\n perFilterLinkedFilters,\n activeFilterCount,\n hasChangesFromInitial,\n reset,\n ],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,eAAe,QAAQ,aAAa;AAC7C,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAKzE,SACEC,gBAAgB,EAChBC,sBAAsB,QAEjB,sCAAsC;AAC7C,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAAS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AK,CAAC,EAAE;QAC/B+C,KAAK,EAAE;MACT;IACF;IACA,OAAOA,KAAK;EACd,CAAC,EAAE,CAAClB,YAAY,CAAC,CAAC;EAElB,MAAMoB,qBAAqB,GAAGhE,OAAO,CACnC,MAAM,CAACH,OAAO,CAAC+C,YAAY,EAAEF,2BAA2B,CAAC,EACzD,CAACE,YAAY,EAAEF,2BAA2B,CAC5C,CAAC;EAED,OAAO1C,OAAO,CACZ,OAAO;IACL4C,YAAY;IACZE,cAAc;IACdM,gBAAgB;IAChBG,WAAW;IACXC,aAAa;IACbG,qBAAqB;IACrBC,sBAAsB;IACtBC,iBAAiB;IACjBG,qBAAqB;IACrBV;EACF,CAAC,CAAC,EACF,CACEV,YAAY,EACZE,cAAc,EACdM,gBAAgB,EAChBG,WAAW,EACXC,aAAa,EACbG,qBAAqB,EACrBC,sBAAsB,EACtBC,iBAAiB,EACjBG,qBAAqB,EACrBV,KAAK,CAET,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useFilterListState.js","names":["useOsdkMetadata","isEqual","useCallback","useEffect","useMemo","useRef","useState","buildWhereClause","getActiveLinkedFilters","filterHasActiveState","getFilterKey","getSeedFilterState","narrowObjectSet","useStableMapEntries","buildInitialStates","definitions","states","Map","definition","state","set","useFilterListState","props","objectType","objectSet","filterDefinitions","onFilterStateChanged","onFilterClauseChanged","onEffectiveObjectSet","defaultFilterStates","initialFilterStates","seededFilterStates","metadata","onFilterClauseChangedRef","current","onEffectiveObjectSetRef","filterDefinitionsRef","propertyTypes","map","properties","key","prop","Object","entries","type","multiplicity","initialFilterStatesSnapshot","snapshot","filterStates","setFilterStates","setFilterState","filterKey","prev","next","find","d","clearFilterState","delete","reset","whereClause","linkedFilters","effectiveObjectSet","undefined","perFilterWhereClauses","perFilterLinkedFilters","activeFilterCount","count","get","clause","toWhereClause","keys","length","hasChangesFromInitial"],"sources":["useFilterListState.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport { useOsdkMetadata } from \"@osdk/react\";\nimport { isEqual } from \"lodash-es\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { FilterListProps } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport type { LinkedFilter } from \"../types/LinkedFilterTypes.js\";\nimport {\n buildWhereClause,\n getActiveLinkedFilters,\n type PropertyTypeInfo,\n} from \"../utils/filterStateToWhereClause.js\";\nimport { filterHasActiveState } from \"../utils/filterValues.js\";\nimport { getFilterKey } from \"../utils/getFilterKey.js\";\nimport { getSeedFilterState } from \"../utils/getSeedFilterState.js\";\nimport { narrowObjectSet } from \"../utils/narrowObjectSet.js\";\nimport { useStableMapEntries } from \"./useStableMapEntries.js\";\n\nexport interface UseFilterListStateResult<Q extends ObjectTypeDefinition> {\n filterStates: Map<string, FilterState>;\n setFilterState: (filterKey: string, state: FilterState) => void;\n clearFilterState: (filterKey: string) => void;\n /** Direct (non-link-traversing) filters combined into a `WhereClause<Q>`. */\n whereClause: WhereClause<Q>;\n /** Active linked-property records; apply via `narrowObjectSet`. */\n linkedFilters: ReadonlyArray<LinkedFilter<Q>>;\n /** Per-filter excluding-self where clauses keyed by `getFilterKey`. */\n perFilterWhereClauses: Map<string, WhereClause<Q>>;\n /** Per-filter excluding-self linked filters keyed by `getFilterKey`. */\n perFilterLinkedFilters: Map<string, ReadonlyArray<LinkedFilter<Q>>>;\n activeFilterCount: number;\n hasChangesFromInitial: boolean;\n reset: () => void;\n}\n\nfunction buildInitialStates<Q extends ObjectTypeDefinition>(\n definitions: FilterListProps<Q>[\"filterDefinitions\"],\n): Map<string, FilterState> {\n const states = new Map<string, FilterState>();\n\n if (!definitions) {\n return states;\n }\n\n for (const definition of definitions) {\n const state = getSeedFilterState(definition);\n if (state) {\n states.set(getFilterKey(definition), state);\n }\n }\n\n return states;\n}\n\nexport function useFilterListState<Q extends ObjectTypeDefinition>(\n props: FilterListProps<Q>,\n): UseFilterListStateResult<Q> {\n const {\n objectType,\n objectSet,\n filterDefinitions,\n onFilterStateChanged,\n onFilterClauseChanged,\n onEffectiveObjectSet,\n defaultFilterStates,\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- back-compat fallback for the pre-rename prop\n initialFilterStates,\n } = props;\n const seededFilterStates = defaultFilterStates ?? initialFilterStates;\n const { metadata } = useOsdkMetadata(objectType);\n const onFilterClauseChangedRef = useRef(onFilterClauseChanged);\n onFilterClauseChangedRef.current = onFilterClauseChanged;\n const onEffectiveObjectSetRef = useRef(onEffectiveObjectSet);\n onEffectiveObjectSetRef.current = onEffectiveObjectSet;\n const filterDefinitionsRef = useRef(filterDefinitions);\n filterDefinitionsRef.current = filterDefinitions;\n\n const propertyTypes = useMemo(() => {\n const map = new Map<string, PropertyTypeInfo>();\n if (metadata?.properties) {\n for (const [key, prop] of Object.entries(metadata.properties)) {\n if (typeof prop.type === \"string\") {\n map.set(key, {\n type: prop.type,\n multiplicity: prop.multiplicity === true,\n });\n }\n }\n }\n return map;\n }, [metadata?.properties]);\n\n // Captured once on first render to provide a stable baseline for the reset\n // button's enabled state. `useState`'s lazy initializer pins the value for\n // the lifetime of the component (unlike `useMemo`, which React may discard).\n const [initialFilterStatesSnapshot] = useState<Map<string, FilterState>>(\n () => {\n const snapshot = buildInitialStates(filterDefinitions);\n if (seededFilterStates) {\n for (const [key, state] of seededFilterStates) {\n snapshot.set(key, state);\n }\n }\n return snapshot;\n },\n );\n\n const [filterStates, setFilterStates] = useState<Map<string, FilterState>>(\n () => new Map(initialFilterStatesSnapshot),\n );\n\n const setFilterState = useCallback(\n (filterKey: string, state: FilterState) => {\n setFilterStates((prev) => {\n const next = new Map(prev);\n next.set(filterKey, state);\n return next;\n });\n\n const definition = filterDefinitionsRef.current?.find(\n (d) => getFilterKey(d) === filterKey,\n );\n if (definition) {\n onFilterStateChanged?.(definition, state);\n }\n },\n [onFilterStateChanged],\n );\n\n const clearFilterState = useCallback((filterKey: string) => {\n setFilterStates((prev) => {\n const next = new Map(prev);\n next.delete(filterKey);\n return next;\n });\n }, []);\n\n const reset = useCallback(() => {\n setFilterStates(new Map(initialFilterStatesSnapshot));\n }, [initialFilterStatesSnapshot]);\n\n const whereClause = useMemo(\n () => buildWhereClause(filterDefinitions, filterStates, propertyTypes),\n [filterDefinitions, filterStates, propertyTypes],\n );\n\n const linkedFilters = useMemo(\n () => getActiveLinkedFilters(filterDefinitions, filterStates),\n [filterDefinitions, filterStates],\n );\n\n const effectiveObjectSet = useMemo<ObjectSet<Q> | undefined>(\n () =>\n objectSet == null\n ? undefined\n : narrowObjectSet(objectSet, whereClause, linkedFilters),\n [objectSet, whereClause, linkedFilters],\n );\n\n useEffect(() => {\n onFilterClauseChangedRef.current?.(whereClause);\n }, [whereClause]);\n\n useEffect(() => {\n if (effectiveObjectSet == null) {\n return;\n }\n onEffectiveObjectSetRef.current?.(effectiveObjectSet);\n }, [effectiveObjectSet]);\n\n const perFilterWhereClauses = useStableMapEntries(\n useMemo(() => {\n const map = new Map<string, WhereClause<Q>>();\n for (const definition of filterDefinitions ?? []) {\n const key = getFilterKey(definition);\n map.set(\n key,\n buildWhereClause(filterDefinitions, filterStates, propertyTypes, key),\n );\n }\n return map;\n }, [filterDefinitions, filterStates, propertyTypes]),\n );\n\n const perFilterLinkedFilters = useStableMapEntries(\n useMemo(() => {\n const map = new Map<string, ReadonlyArray<LinkedFilter<Q>>>();\n for (const definition of filterDefinitions ?? []) {\n const key = getFilterKey(definition);\n map.set(\n key,\n getActiveLinkedFilters(filterDefinitions, filterStates, key),\n );\n }\n return map;\n }, [filterDefinitions, filterStates]),\n );\n\n const activeFilterCount = useMemo(() => {\n let count = 0;\n for (const definition of filterDefinitions ?? []) {\n const state = filterStates.get(getFilterKey(definition));\n if (state == null) {\n continue;\n }\n // A custom filter's state is opaque, so `filterHasActiveState` can only\n // say \"some state exists\". Only its own `toWhereClause` knows whether\n // that state filters anything, so match what `buildWhereClause` keeps.\n if (definition.type === \"CUSTOM\") {\n if (state.type === \"custom\") {\n const clause = definition.toWhereClause(state);\n if (clause != null && Object.keys(clause).length > 0) {\n count++;\n }\n }\n continue;\n }\n if (filterHasActiveState(state)) {\n count++;\n }\n }\n return count;\n }, [filterDefinitions, filterStates]);\n\n const hasChangesFromInitial = useMemo(\n () => !isEqual(filterStates, initialFilterStatesSnapshot),\n [filterStates, initialFilterStatesSnapshot],\n );\n\n return useMemo(\n () => ({\n filterStates,\n setFilterState,\n clearFilterState,\n whereClause,\n linkedFilters,\n perFilterWhereClauses,\n perFilterLinkedFilters,\n activeFilterCount,\n hasChangesFromInitial,\n reset,\n }),\n [\n filterStates,\n setFilterState,\n clearFilterState,\n whereClause,\n linkedFilters,\n perFilterWhereClauses,\n perFilterLinkedFilters,\n activeFilterCount,\n hasChangesFromInitial,\n reset,\n ],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,eAAe,QAAQ,aAAa;AAC7C,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAKzE,SACEC,gBAAgB,EAChBC,sBAAsB,QAEjB,sCAAsC;AAC7C,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,eAAe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ACxD,IAAIC,KAAK,IAAI,IAAI,EAAE;QACjB;MACF;MACA;MACA;MACA;MACA,IAAID,UAAU,CAAC0B,IAAI,KAAK,QAAQ,EAAE;QAChC,IAAIzB,KAAK,CAACyB,IAAI,KAAK,QAAQ,EAAE;UAC3B,MAAMwB,MAAM,GAAGlD,UAAU,CAACmD,aAAa,CAAClD,KAAK,CAAC;UAC9C,IAAIiD,MAAM,IAAI,IAAI,IAAI1B,MAAM,CAAC4B,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,GAAG,CAAC,EAAE;YACpDL,KAAK,EAAE;UACT;QACF;QACA;MACF;MACA,IAAIzD,oBAAoB,CAACU,KAAK,CAAC,EAAE;QAC/B+C,KAAK,EAAE;MACT;IACF;IACA,OAAOA,KAAK;EACd,CAAC,EAAE,CAACzC,iBAAiB,EAAEuB,YAAY,CAAC,CAAC;EAErC,MAAMwB,qBAAqB,GAAGpE,OAAO,CACnC,MAAM,CAACH,OAAO,CAAC+C,YAAY,EAAEF,2BAA2B,CAAC,EACzD,CAACE,YAAY,EAAEF,2BAA2B,CAC5C,CAAC;EAED,OAAO1C,OAAO,CACZ,OAAO;IACL4C,YAAY;IACZE,cAAc;IACdM,gBAAgB;IAChBG,WAAW;IACXC,aAAa;IACbG,qBAAqB;IACrBC,sBAAsB;IACtBC,iBAAiB;IACjBO,qBAAqB;IACrBd;EACF,CAAC,CAAC,EACF,CACEV,YAAY,EACZE,cAAc,EACdM,gBAAgB,EAChBG,WAAW,EACXC,aAAa,EACbG,qBAAqB,EACrBC,sBAAsB,EACtBC,iBAAiB,EACjBO,qBAAqB,EACrBd,KAAK,CAET,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomRendererTypes.js","names":[],"sources":["CustomRendererTypes.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport type { ReactNode } from \"react\";\n\nimport type {\n BaseFilterState,\n FilterDefinitionControls,\n} from \"../FilterListItemApi.js\";\n\n/**\n * State for custom filter\n */\nexport interface CustomFilterState<\n T = Record<string, unknown>,\n> extends BaseFilterState {\n type: \"custom\";\n customState: T;\n}\n\n/**\n * Props passed to custom filter input renderer\n */\nexport interface CustomFilterInputRendererProps<\n Q extends ObjectTypeDefinition,\n State extends BaseFilterState,\n> {\n objectType: Q;\n objectSet?: ObjectSet<Q>;\n filterState: State;\n onFilterStateChanged: (newState: State) => void;\n}\n\n/**\n * Props passed to custom filter item renderer\n * Includes full item context in addition to input renderer props\n */\nexport interface CustomFilterItemRendererProps<\n Q extends ObjectTypeDefinition,\n State extends BaseFilterState,\n> extends CustomFilterInputRendererProps<Q, State> {\n label: string;\n onRemove?: () => void;\n}\n\n/**\n * Filter definition for custom filters\n * Provides full control over rendering and filter logic\n */\nexport interface CustomFilterDefinition<\n Q extends ObjectTypeDefinition,\n State extends BaseFilterState = CustomFilterState,\n> extends FilterDefinitionControls {\n type: \"CUSTOM\";\n /**\n * Unique key for this custom filter\n */\n key: string;\n label?: string;\n filterComponent: \"CUSTOM\";\n\n /**\n * Seeds the filter's state on mount, FilterList owns the state from then on\n *\n * @default undefined (filter starts empty)\n */\n defaultFilterState?: State;\n\n /**\n * @deprecated
|
|
1
|
+
{"version":3,"file":"CustomRendererTypes.js","names":[],"sources":["CustomRendererTypes.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport type { ReactNode } from \"react\";\n\nimport type {\n BaseFilterState,\n FilterDefinitionControls,\n} from \"../FilterListItemApi.js\";\n\n/**\n * State for custom filter\n */\nexport interface CustomFilterState<\n T = Record<string, unknown>,\n> extends BaseFilterState {\n type: \"custom\";\n customState: T;\n}\n\n/**\n * Props passed to custom filter input renderer\n */\nexport interface CustomFilterInputRendererProps<\n Q extends ObjectTypeDefinition,\n State extends BaseFilterState,\n> {\n objectType: Q;\n objectSet?: ObjectSet<Q>;\n filterState: State;\n onFilterStateChanged: (newState: State) => void;\n}\n\n/**\n * Props passed to custom filter item renderer\n * Includes full item context in addition to input renderer props\n */\nexport interface CustomFilterItemRendererProps<\n Q extends ObjectTypeDefinition,\n State extends BaseFilterState,\n> extends CustomFilterInputRendererProps<Q, State> {\n label: string;\n onRemove?: () => void;\n}\n\n/**\n * Filter definition for custom filters\n * Provides full control over rendering and filter logic\n */\nexport interface CustomFilterDefinition<\n Q extends ObjectTypeDefinition,\n State extends BaseFilterState = CustomFilterState,\n> extends FilterDefinitionControls {\n type: \"CUSTOM\";\n /**\n * Unique key for this custom filter\n */\n key: string;\n label?: string;\n filterComponent: \"CUSTOM\";\n\n /**\n * Seeds the filter's state on mount, FilterList owns the state from then on\n *\n * @default undefined (filter starts empty)\n */\n defaultFilterState?: State;\n\n /**\n * @deprecated Rename to `defaultFilterState`.\n */\n filterState?: State;\n /**\n * Render the input portion of the filter\n * Used when rendering within a filter item wrapper\n */\n renderInput?: (props: CustomFilterInputRendererProps<Q, State>) => ReactNode;\n /**\n * Render the complete filter item\n * Used when you need full control over the item appearance\n */\n renderItem?: (props: CustomFilterItemRendererProps<Q, State>) => ReactNode;\n /**\n * Convert filter state to a WhereClause for filtering\n * Required for the filter to affect the object set\n */\n toWhereClause: (state: State) => WhereClause<Q> | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -33,6 +33,7 @@ export function getSeedFilterState(definition) {
|
|
|
33
33
|
// `filterState` is the pre-rename seed here.
|
|
34
34
|
case "PROPERTY":
|
|
35
35
|
case "STATIC_VALUES":
|
|
36
|
+
case "CUSTOM":
|
|
36
37
|
return definition.defaultFilterState ??
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback
|
|
38
39
|
definition.filterState;
|
|
@@ -42,7 +43,6 @@ export function getSeedFilterState(definition) {
|
|
|
42
43
|
// nobody asked for.
|
|
43
44
|
case "HAS_LINK":
|
|
44
45
|
case "KEYWORD_SEARCH":
|
|
45
|
-
case "CUSTOM":
|
|
46
46
|
return definition.defaultFilterState;
|
|
47
47
|
|
|
48
48
|
// Definition holds the inner state; the map holds a `linkedProperty` wrapper.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeedFilterState.js","names":["assertUnreachable","getLinkedFilterComponent","getSeedFilterState","definition","type","defaultFilterState","filterState","undefined","innerState","defaultLinkedFilterState","linkedFilterState"],"sources":["getSeedFilterState.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition } from \"@osdk/api\";\n\nimport { assertUnreachable } from \"../../shared/assertUnreachable.js\";\nimport type { FilterDefinitionUnion } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport type { LinkedPropertyFilterState } from \"../types/LinkedFilterTypes.js\";\nimport { getLinkedFilterComponent } from \"./getLinkedFilterComponent.js\";\n\n/**\n * Resolves the state a definition seeds its filter with, preferring\n * `defaultFilterState` over the deprecated spellings, which differ per kind.\n *\n * The other two deprecation fallbacks live in `useFilterListState`\n * (`initialFilterStates`) and `getLinkedFilterComponent`; all three go together.\n *\n * TODO: without the deprecated spellings this collapses to\n * `definition.defaultFilterState` everywhere but LINKED_PROPERTY, which keeps\n * the wrapper — a real shape difference, not a deprecation artifact.\n */\nexport function getSeedFilterState<Q extends ObjectTypeDefinition>(\n definition: FilterDefinitionUnion<Q>,\n): FilterState | undefined {\n switch (definition.type) {\n // `filterState` is the pre-rename seed here.\n case \"PROPERTY\":\n case \"STATIC_VALUES\":\n return (\n definition.defaultFilterState ??\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback\n definition.filterState\n );\n\n // `filterState` has never seeded these, and must not start: it is set on\n // nearly every existing definition, so reading it would activate filters\n // nobody asked for.\n case \"HAS_LINK\":\n case \"KEYWORD_SEARCH\":\n
|
|
1
|
+
{"version":3,"file":"getSeedFilterState.js","names":["assertUnreachable","getLinkedFilterComponent","getSeedFilterState","definition","type","defaultFilterState","filterState","undefined","innerState","defaultLinkedFilterState","linkedFilterState"],"sources":["getSeedFilterState.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition } from \"@osdk/api\";\n\nimport { assertUnreachable } from \"../../shared/assertUnreachable.js\";\nimport type { FilterDefinitionUnion } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport type { LinkedPropertyFilterState } from \"../types/LinkedFilterTypes.js\";\nimport { getLinkedFilterComponent } from \"./getLinkedFilterComponent.js\";\n\n/**\n * Resolves the state a definition seeds its filter with, preferring\n * `defaultFilterState` over the deprecated spellings, which differ per kind.\n *\n * The other two deprecation fallbacks live in `useFilterListState`\n * (`initialFilterStates`) and `getLinkedFilterComponent`; all three go together.\n *\n * TODO: without the deprecated spellings this collapses to\n * `definition.defaultFilterState` everywhere but LINKED_PROPERTY, which keeps\n * the wrapper — a real shape difference, not a deprecation artifact.\n */\nexport function getSeedFilterState<Q extends ObjectTypeDefinition>(\n definition: FilterDefinitionUnion<Q>,\n): FilterState | undefined {\n switch (definition.type) {\n // `filterState` is the pre-rename seed here.\n case \"PROPERTY\":\n case \"STATIC_VALUES\":\n case \"CUSTOM\":\n return (\n definition.defaultFilterState ??\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback\n definition.filterState\n );\n\n // `filterState` has never seeded these, and must not start: it is set on\n // nearly every existing definition, so reading it would activate filters\n // nobody asked for.\n case \"HAS_LINK\":\n case \"KEYWORD_SEARCH\":\n return definition.defaultFilterState;\n\n // Definition holds the inner state; the map holds a `linkedProperty` wrapper.\n case \"LINKED_PROPERTY\": {\n // No component renders as unsupported, so seeding would narrow\n // `objectSet` off a filter the user can neither see nor clear.\n if (getLinkedFilterComponent(definition) == null) {\n return undefined;\n }\n const innerState =\n definition.defaultFilterState ??\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback\n definition.defaultLinkedFilterState;\n return innerState == null\n ? undefined\n : ({\n type: \"linkedProperty\",\n linkedFilterState: innerState,\n } satisfies LinkedPropertyFilterState);\n }\n\n default:\n return assertUnreachable(definition);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,iBAAiB,QAAQ,mCAAmC;AAIrE,SAASC,wBAAwB,QAAQ,+BAA+B;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCC,UAAoC,EACX;EACzB,QAAQA,UAAU,CAACC,IAAI;IACrB;IACA,KAAK,UAAU;IACf,KAAK,eAAe;IACpB,KAAK,QAAQ;MACX,OACED,UAAU,CAACE,kBAAkB;MAC7B;MACAF,UAAU,CAACG,WAAW;;IAG1B;IACA;IACA;IACA,KAAK,UAAU;IACf,KAAK,gBAAgB;MACnB,OAAOH,UAAU,CAACE,kBAAkB;;IAEtC;IACA,KAAK,iBAAiB;MAAE;QACtB;QACA;QACA,IAAIJ,wBAAwB,CAACE,UAAU,CAAC,IAAI,IAAI,EAAE;UAChD,OAAOI,SAAS;QAClB;QACA,MAAMC,UAAU,GACdL,UAAU,CAACE,kBAAkB;QAC7B;QACAF,UAAU,CAACM,wBAAwB;QACrC,OAAOD,UAAU,IAAI,IAAI,GACrBD,SAAS,GACR;UACCH,IAAI,EAAE,gBAAgB;UACtBM,iBAAiB,EAAEF;QACrB,CAAsC;MAC5C;IAEA;MACE,OAAOR,iBAAiB,CAACG,UAAU,CAAC;EACxC;AACF","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.
|
|
17
|
+
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.52.0-main-47c9c8958c61ca5c8529da4223833fb13622ef9e"}`;
|
|
18
18
|
export function componentUserAgent(componentName) {
|
|
19
19
|
return `${PACKAGE_USER_AGENT}/${componentName}`;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,iFAAsD;AAEjF,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVOROB7KJ_cjs = require('./chunk-VOROB7KJ.cjs');
|
|
4
|
+
var chunk6T5OSLJ7_cjs = require('./chunk-6T5OSLJ7.cjs');
|
|
5
|
+
|
|
6
|
+
// src/public/experimental/image-viewer.ts
|
|
7
|
+
var ImageViewer2 = chunk6T5OSLJ7_cjs.withOsdkMetrics(chunkVOROB7KJ_cjs.ImageViewer, "ImageViewer");
|
|
8
|
+
|
|
9
|
+
exports.ImageViewer = ImageViewer2;
|
|
10
|
+
//# sourceMappingURL=chunk-43CELINZ.cjs.map
|
|
11
|
+
//# sourceMappingURL=chunk-43CELINZ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/public/experimental/image-viewer.ts"],"names":["ImageViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/public/experimental/image-viewer.ts"],"names":["ImageViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-43CELINZ.cjs","sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// BaseImageViewer\nexport { BaseImageViewer } from \"../../images/image-viewer/BaseImageViewer.js\";\n// ImageViewer (Media wrapper)\nimport { ImageViewer as _ImageViewer } from \"../../images/image-viewer/ImageViewer.js\";\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nexport const ImageViewer = withOsdkMetrics(_ImageViewer, \"ImageViewer\");"]}
|
|
@@ -6,7 +6,7 @@ var chunk3KMJ6NKF_cjs = require('./chunk-3KMJ6NKF.cjs');
|
|
|
6
6
|
var chunkYE4F6HIR_cjs = require('./chunk-YE4F6HIR.cjs');
|
|
7
7
|
var chunk7LXS66DW_cjs = require('./chunk-7LXS66DW.cjs');
|
|
8
8
|
var chunkUCTQICPR_cjs = require('./chunk-UCTQICPR.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunk6T5OSLJ7_cjs = require('./chunk-6T5OSLJ7.cjs');
|
|
10
10
|
var button = require('@base-ui/react/button');
|
|
11
11
|
var classnames3 = require('classnames');
|
|
12
12
|
var React15 = require('react');
|
|
@@ -4434,10 +4434,7 @@ function FilterInputInner({
|
|
|
4434
4434
|
"data-unsupported": "true"
|
|
4435
4435
|
}, "Custom filter missing renderInput");
|
|
4436
4436
|
}
|
|
4437
|
-
const customFilterState = filterState?.type === "custom" ? filterState :
|
|
4438
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback
|
|
4439
|
-
definition.filterState ?? EMPTY_CUSTOM_STATE
|
|
4440
|
-
);
|
|
4437
|
+
const customFilterState = filterState?.type === "custom" ? filterState : EMPTY_CUSTOM_STATE;
|
|
4441
4438
|
return /* @__PURE__ */ React15__default.default.createElement(React15__default.default.Fragment, null, definition.renderInput({
|
|
4442
4439
|
objectType,
|
|
4443
4440
|
objectSet,
|
|
@@ -4945,6 +4942,7 @@ function getSeedFilterState(definition) {
|
|
|
4945
4942
|
// `filterState` is the pre-rename seed here.
|
|
4946
4943
|
case "PROPERTY":
|
|
4947
4944
|
case "STATIC_VALUES":
|
|
4945
|
+
case "CUSTOM":
|
|
4948
4946
|
return definition.defaultFilterState ?? // eslint-disable-next-line @typescript-eslint/no-deprecated -- pre-rename fallback
|
|
4949
4947
|
definition.filterState;
|
|
4950
4948
|
// `filterState` has never seeded these, and must not start: it is set on
|
|
@@ -4952,7 +4950,6 @@ function getSeedFilterState(definition) {
|
|
|
4952
4950
|
// nobody asked for.
|
|
4953
4951
|
case "HAS_LINK":
|
|
4954
4952
|
case "KEYWORD_SEARCH":
|
|
4955
|
-
case "CUSTOM":
|
|
4956
4953
|
return definition.defaultFilterState;
|
|
4957
4954
|
// Definition holds the inner state; the map holds a `linkedProperty` wrapper.
|
|
4958
4955
|
case "LINKED_PROPERTY": {
|
|
@@ -5092,13 +5089,26 @@ function useFilterListState(props) {
|
|
|
5092
5089
|
}, [filterDefinitions, filterStates]));
|
|
5093
5090
|
const activeFilterCount = React15.useMemo(() => {
|
|
5094
5091
|
let count = 0;
|
|
5095
|
-
for (const
|
|
5092
|
+
for (const definition of filterDefinitions ?? []) {
|
|
5093
|
+
const state = filterStates.get(getFilterKey(definition));
|
|
5094
|
+
if (state == null) {
|
|
5095
|
+
continue;
|
|
5096
|
+
}
|
|
5097
|
+
if (definition.type === "CUSTOM") {
|
|
5098
|
+
if (state.type === "custom") {
|
|
5099
|
+
const clause = definition.toWhereClause(state);
|
|
5100
|
+
if (clause != null && Object.keys(clause).length > 0) {
|
|
5101
|
+
count++;
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
continue;
|
|
5105
|
+
}
|
|
5096
5106
|
if (filterHasActiveState(state)) {
|
|
5097
5107
|
count++;
|
|
5098
5108
|
}
|
|
5099
5109
|
}
|
|
5100
5110
|
return count;
|
|
5101
|
-
}, [filterStates]);
|
|
5111
|
+
}, [filterDefinitions, filterStates]);
|
|
5102
5112
|
const hasChangesFromInitial = React15.useMemo(() => !lodashEs.isEqual(filterStates, initialFilterStatesSnapshot), [filterStates, initialFilterStatesSnapshot]);
|
|
5103
5113
|
return React15.useMemo(() => ({
|
|
5104
5114
|
filterStates,
|
|
@@ -5613,7 +5623,7 @@ function summarizeFilterValue(definition, state) {
|
|
|
5613
5623
|
}
|
|
5614
5624
|
|
|
5615
5625
|
// src/public/experimental/filter-list.ts
|
|
5616
|
-
var FilterList2 =
|
|
5626
|
+
var FilterList2 = chunk6T5OSLJ7_cjs.withOsdkMetrics(FilterList, "FilterList");
|
|
5617
5627
|
|
|
5618
5628
|
exports.BaseFilterList = BaseFilterList;
|
|
5619
5629
|
exports.FilterInput = FilterInput;
|
|
@@ -5628,5 +5638,5 @@ exports.narrowObjectSet = narrowObjectSet;
|
|
|
5628
5638
|
exports.serializeFilterStates = serializeFilterStates;
|
|
5629
5639
|
exports.summarizeFilterValue = summarizeFilterValue;
|
|
5630
5640
|
exports.useFilterListState = useFilterListState;
|
|
5631
|
-
//# sourceMappingURL=chunk-
|
|
5632
|
-
//# sourceMappingURL=chunk-
|
|
5641
|
+
//# sourceMappingURL=chunk-62OSZ22J.cjs.map
|
|
5642
|
+
//# sourceMappingURL=chunk-62OSZ22J.cjs.map
|