@osdk/react-components 0.2.0-beta.12 → 0.2.0-beta.14
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 +20 -0
- package/build/browser/base-components/draggable-list/DraggableList.module.css +2 -2
- package/build/browser/filter-list/FilterListApi.js.map +1 -1
- package/build/browser/filter-list/base/DragHandleIcon.js +51 -0
- package/build/browser/filter-list/base/DragHandleIcon.js.map +1 -0
- package/build/browser/filter-list/base/FilterList.js +3 -1
- package/build/browser/filter-list/base/FilterList.js.map +1 -1
- package/build/browser/filter-list/base/FilterListContent.js +143 -3
- package/build/browser/filter-list/base/FilterListContent.js.map +1 -1
- package/build/browser/filter-list/base/FilterListContent.module.css +6 -0
- package/build/browser/filter-list/base/FilterListContent.module.css.js +2 -1
- package/build/browser/filter-list/base/FilterListItem.js +11 -18
- package/build/browser/filter-list/base/FilterListItem.js.map +1 -1
- package/build/browser/filter-list/base/FilterListItem.module.css +32 -0
- package/build/browser/filter-list/base/FilterListItem.module.css.js +3 -1
- package/build/browser/filter-list/base/SortableFilterListItem.js +63 -0
- package/build/browser/filter-list/base/SortableFilterListItem.js.map +1 -0
- package/build/browser/filter-list/utils/getFilterLabel.js +36 -0
- package/build/browser/filter-list/utils/getFilterLabel.js.map +1 -0
- package/build/browser/object-table/EditableCell.js +1 -2
- package/build/browser/object-table/EditableCell.js.map +1 -1
- package/build/browser/object-table/ObjectTable.js +2 -1
- package/build/browser/object-table/ObjectTable.js.map +1 -1
- package/build/browser/object-table/TableRow.js +1 -2
- package/build/browser/object-table/TableRow.js.map +1 -1
- package/build/browser/styles.css +40 -2
- package/build/cjs/public/experimental.cjs +907 -678
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +34 -2
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +7 -8
- package/build/esm/base-components/draggable-list/DraggableList.module.css +2 -2
- package/build/esm/filter-list/FilterListApi.js.map +1 -1
- package/build/esm/filter-list/base/DragHandleIcon.js +51 -0
- package/build/esm/filter-list/base/DragHandleIcon.js.map +1 -0
- package/build/esm/filter-list/base/FilterList.js +3 -1
- package/build/esm/filter-list/base/FilterList.js.map +1 -1
- package/build/esm/filter-list/base/FilterListContent.js +143 -3
- package/build/esm/filter-list/base/FilterListContent.js.map +1 -1
- package/build/esm/filter-list/base/FilterListContent.module.css +6 -0
- package/build/esm/filter-list/base/FilterListItem.js +11 -18
- package/build/esm/filter-list/base/FilterListItem.js.map +1 -1
- package/build/esm/filter-list/base/FilterListItem.module.css +32 -0
- package/build/esm/filter-list/base/SortableFilterListItem.js +63 -0
- package/build/esm/filter-list/base/SortableFilterListItem.js.map +1 -0
- package/build/esm/filter-list/utils/getFilterLabel.js +36 -0
- package/build/esm/filter-list/utils/getFilterLabel.js.map +1 -0
- package/build/esm/object-table/EditableCell.js +1 -2
- package/build/esm/object-table/EditableCell.js.map +1 -1
- package/build/esm/object-table/ObjectTable.js +2 -1
- package/build/esm/object-table/ObjectTable.js.map +1 -1
- package/build/esm/object-table/TableRow.js +1 -2
- package/build/esm/object-table/TableRow.js.map +1 -1
- package/build/types/filter-list/FilterListApi.d.ts +7 -0
- package/build/types/filter-list/FilterListApi.d.ts.map +1 -1
- package/build/types/filter-list/base/DragHandleIcon.d.ts +2 -0
- package/build/types/filter-list/base/DragHandleIcon.d.ts.map +1 -0
- package/build/types/filter-list/base/FilterListContent.d.ts +2 -1
- package/build/types/filter-list/base/FilterListContent.d.ts.map +1 -1
- package/build/types/filter-list/base/FilterListItem.d.ts +4 -1
- package/build/types/filter-list/base/FilterListItem.d.ts.map +1 -1
- package/build/types/filter-list/base/SortableFilterListItem.d.ts +16 -0
- package/build/types/filter-list/base/SortableFilterListItem.d.ts.map +1 -0
- package/build/types/filter-list/utils/getFilterLabel.d.ts +3 -0
- package/build/types/filter-list/utils/getFilterLabel.d.ts.map +1 -0
- package/build/types/object-table/EditableCell.d.ts +1 -3
- package/build/types/object-table/EditableCell.d.ts.map +1 -1
- package/build/types/object-table/ObjectTable.d.ts +0 -8
- package/build/types/object-table/ObjectTable.d.ts.map +1 -1
- package/build/types/object-table/TableRow.d.ts +1 -2
- package/build/types/object-table/TableRow.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @osdk/react-components
|
|
2
2
|
|
|
3
|
+
## 0.2.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fb9383c: Fix table crashes on remount
|
|
8
|
+
|
|
9
|
+
## 0.2.0-beta.13
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 76ee40a: Fix column resize and value change ux
|
|
14
|
+
- edbe438: FilterList base components with drag-and-drop sorting and tokenized styling
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [8c30908]
|
|
19
|
+
- @osdk/client@2.8.0-beta.17
|
|
20
|
+
- @osdk/api@2.8.0-beta.17
|
|
21
|
+
- @osdk/react@0.10.0-beta.8
|
|
22
|
+
|
|
3
23
|
## 0.2.0-beta.12
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
.dragHandle {
|
|
42
42
|
display: flex;
|
|
43
|
-
cursor:
|
|
43
|
+
cursor: var(--osdk-drag-handle-cursor);
|
|
44
44
|
color: var(--osdk-draggable-item-drag-icon-color);
|
|
45
45
|
|
|
46
46
|
&:hover {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
&:active {
|
|
51
|
-
cursor:
|
|
51
|
+
cursor: var(--osdk-drag-handle-cursor-active);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
&:focus {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterListApi.js","names":[],"sources":["FilterListApi.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 {\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n WhereClause,\n} from \"@osdk/api\";\nimport type React from \"react\";\nimport type {\n FilterState as FilterStateType,\n PropertyFilterDefinition,\n} from \"./FilterListItemApi.js\";\nimport type { CustomFilterDefinition } from \"./types/CustomRendererTypes.js\";\nimport type { KeywordSearchFilterDefinition } from \"./types/KeywordSearchTypes.js\";\nimport type {\n HasLinkFilterDefinition,\n LinkedPropertyFilterDefinition,\n} from \"./types/LinkedFilterTypes.js\";\n\n/**\n * Union type of all filter definition types\n */\nexport type FilterDefinitionUnion<Q extends ObjectTypeDefinition> =\n | PropertyFilterDefinition<Q>\n | HasLinkFilterDefinition<Q>\n | LinkedPropertyFilterDefinition<Q, LinkNames<Q>>\n | KeywordSearchFilterDefinition<Q>\n | CustomFilterDefinition<Q>;\n\n/**\n * Extract the key from a filter definition union\n */\nexport type FilterKey<Q extends ObjectTypeDefinition> =\n FilterDefinitionUnion<Q> extends infer D ? D extends { key: infer K } ? K\n : D extends { linkName: infer L } ? L\n : never\n : never;\n\n/**\n * Extract the filter state from a filter definition union\n */\nexport type FilterState<Q extends ObjectTypeDefinition> =\n FilterDefinitionUnion<Q> extends infer D\n ? D extends { filterState: infer S } ? S\n : never\n : never;\n\n/**\n * Map from filter definition objects to their current state.\n * Uses object identity for keys, ensuring stable lookups across reorders.\n */\nexport type FilterStatesMap<Q extends ObjectTypeDefinition> = Map<\n FilterDefinitionUnion<Q>,\n FilterStateType\n>;\n\nexport interface FilterListProps<Q extends ObjectTypeDefinition> {\n /**\n * The set of objects to be filtered\n */\n objectSet: ObjectSet<Q>;\n\n /**\n * Optional title to display in the filter list header\n */\n title?: string;\n\n /**\n * Optional icon to display next to the title\n */\n titleIcon?: React.ReactNode;\n\n /**\n * The definition for all supported filter items in the list\n * If not supplied, all filterable properties will be available\n */\n filterDefinitions?: Array<FilterDefinitionUnion<Q>>;\n\n /**\n * The current where clause to filter the objectSet.\n * If provided, the filter clause is controlled.\n */\n filterClause?: WhereClause<Q>;\n\n /**\n * Called when the filter clause changes.\n * The filters are joined by the selected filterOperator.\n * Required in controlled mode.\n *\n * @param newClause The updated filter clause\n */\n onFilterClauseChanged?: (newClause: WhereClause<Q>) => void;\n\n /**\n * The logical operator to join multiple filters\n *\n * @default \"and\"\n */\n filterOperator?: \"and\" | \"or\";\n\n /**\n * Called when filter state changes\n *\n * @param definition The filter definition whose state changed\n * @param newState The updated filter state\n */\n onFilterStateChanged?: (\n definition: FilterDefinitionUnion<Q>,\n newState: FilterStateType,\n ) => void;\n\n /**\n * Called when a filter is added\n * If provided, user will be allowed to add filters\n *\n * @param filterKey The key of the added filter\n * @param newDefinitions The filter list with the new filter added\n */\n onFilterAdded?: (\n filterKey: FilterKey<Q>,\n newDefinitions: Array<FilterDefinitionUnion<Q>>,\n ) => void;\n\n /**\n * Called when a filter is removed\n * If provided, user will be allowed to remove filters\n *\n * @param filterKey The key of the removed filter\n */\n onFilterRemoved?: (filterKey: FilterKey<Q>) => void;\n\n /**\n * Show reset filters button in header\n */\n showResetButton?: boolean;\n\n /**\n * Called when reset button is clicked\n */\n onReset?: () => void;\n\n /**\n * Show count of active filters in header\n */\n showActiveFilterCount?: boolean;\n\n /**\n * Additional CSS class name\n */\n className?: string;\n\n /**\n * Custom render function for the \"Add filter\" button.\n * When not provided, a default button is shown if onFilterAdded is set.\n */\n renderAddFilterButton?: () => React.ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FilterListApi.js","names":[],"sources":["FilterListApi.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 {\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n WhereClause,\n} from \"@osdk/api\";\nimport type React from \"react\";\nimport type {\n FilterState as FilterStateType,\n PropertyFilterDefinition,\n} from \"./FilterListItemApi.js\";\nimport type { CustomFilterDefinition } from \"./types/CustomRendererTypes.js\";\nimport type { KeywordSearchFilterDefinition } from \"./types/KeywordSearchTypes.js\";\nimport type {\n HasLinkFilterDefinition,\n LinkedPropertyFilterDefinition,\n} from \"./types/LinkedFilterTypes.js\";\n\n/**\n * Union type of all filter definition types\n */\nexport type FilterDefinitionUnion<Q extends ObjectTypeDefinition> =\n | PropertyFilterDefinition<Q>\n | HasLinkFilterDefinition<Q>\n | LinkedPropertyFilterDefinition<Q, LinkNames<Q>>\n | KeywordSearchFilterDefinition<Q>\n | CustomFilterDefinition<Q>;\n\n/**\n * Extract the key from a filter definition union\n */\nexport type FilterKey<Q extends ObjectTypeDefinition> =\n FilterDefinitionUnion<Q> extends infer D ? D extends { key: infer K } ? K\n : D extends { linkName: infer L } ? L\n : never\n : never;\n\n/**\n * Extract the filter state from a filter definition union\n */\nexport type FilterState<Q extends ObjectTypeDefinition> =\n FilterDefinitionUnion<Q> extends infer D\n ? D extends { filterState: infer S } ? S\n : never\n : never;\n\n/**\n * Map from filter definition objects to their current state.\n * Uses object identity for keys, ensuring stable lookups across reorders.\n */\nexport type FilterStatesMap<Q extends ObjectTypeDefinition> = Map<\n FilterDefinitionUnion<Q>,\n FilterStateType\n>;\n\nexport interface FilterListProps<Q extends ObjectTypeDefinition> {\n /**\n * The set of objects to be filtered\n */\n objectSet: ObjectSet<Q>;\n\n /**\n * Optional title to display in the filter list header\n */\n title?: string;\n\n /**\n * Optional icon to display next to the title\n */\n titleIcon?: React.ReactNode;\n\n /**\n * The definition for all supported filter items in the list\n * If not supplied, all filterable properties will be available\n */\n filterDefinitions?: Array<FilterDefinitionUnion<Q>>;\n\n /**\n * The current where clause to filter the objectSet.\n * If provided, the filter clause is controlled.\n */\n filterClause?: WhereClause<Q>;\n\n /**\n * Called when the filter clause changes.\n * The filters are joined by the selected filterOperator.\n * Required in controlled mode.\n *\n * @param newClause The updated filter clause\n */\n onFilterClauseChanged?: (newClause: WhereClause<Q>) => void;\n\n /**\n * The logical operator to join multiple filters\n *\n * @default \"and\"\n */\n filterOperator?: \"and\" | \"or\";\n\n /**\n * Called when filter state changes\n *\n * @param definition The filter definition whose state changed\n * @param newState The updated filter state\n */\n onFilterStateChanged?: (\n definition: FilterDefinitionUnion<Q>,\n newState: FilterStateType,\n ) => void;\n\n /**\n * Called when a filter is added\n * If provided, user will be allowed to add filters\n *\n * @param filterKey The key of the added filter\n * @param newDefinitions The filter list with the new filter added\n */\n onFilterAdded?: (\n filterKey: FilterKey<Q>,\n newDefinitions: Array<FilterDefinitionUnion<Q>>,\n ) => void;\n\n /**\n * Called when a filter is removed\n * If provided, user will be allowed to remove filters\n *\n * @param filterKey The key of the removed filter\n */\n onFilterRemoved?: (filterKey: FilterKey<Q>) => void;\n\n /**\n * Enable drag-and-drop reordering of filters.\n * When true, drag handles are rendered and filters can be reordered.\n * Reorder state is managed internally; consumers who need to track order\n * should use controlled filterDefinitions.\n */\n enableSorting?: boolean;\n\n /**\n * Show reset filters button in header\n */\n showResetButton?: boolean;\n\n /**\n * Called when reset button is clicked\n */\n onReset?: () => void;\n\n /**\n * Show count of active filters in header\n */\n showActiveFilterCount?: boolean;\n\n /**\n * Additional CSS class name\n */\n className?: string;\n\n /**\n * Custom render function for the \"Add filter\" button.\n * When not provided, a default button is shown if onFilterAdded is set.\n */\n renderAddFilterButton?: () => React.ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from "react";
|
|
18
|
+
export function DragHandleIcon() {
|
|
19
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
20
|
+
width: "16",
|
|
21
|
+
height: "16",
|
|
22
|
+
viewBox: "0 0 16 16",
|
|
23
|
+
fill: "currentColor",
|
|
24
|
+
"aria-hidden": "true"
|
|
25
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
26
|
+
cx: "5.5",
|
|
27
|
+
cy: "3.5",
|
|
28
|
+
r: "1.5"
|
|
29
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
30
|
+
cx: "10.5",
|
|
31
|
+
cy: "3.5",
|
|
32
|
+
r: "1.5"
|
|
33
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
34
|
+
cx: "5.5",
|
|
35
|
+
cy: "8",
|
|
36
|
+
r: "1.5"
|
|
37
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
38
|
+
cx: "10.5",
|
|
39
|
+
cy: "8",
|
|
40
|
+
r: "1.5"
|
|
41
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
42
|
+
cx: "5.5",
|
|
43
|
+
cy: "12.5",
|
|
44
|
+
r: "1.5"
|
|
45
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
46
|
+
cx: "10.5",
|
|
47
|
+
cy: "12.5",
|
|
48
|
+
r: "1.5"
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=DragHandleIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragHandleIcon.js","names":["React","DragHandleIcon","createElement","width","height","viewBox","fill","cx","cy","r"],"sources":["DragHandleIcon.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 React from \"react\";\n\nexport function DragHandleIcon(): React.ReactElement {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <circle cx=\"5.5\" cy=\"3.5\" r=\"1.5\" />\n <circle cx=\"10.5\" cy=\"3.5\" r=\"1.5\" />\n <circle cx=\"5.5\" cy=\"8\" r=\"1.5\" />\n <circle cx=\"10.5\" cy=\"8\" r=\"1.5\" />\n <circle cx=\"5.5\" cy=\"12.5\" r=\"1.5\" />\n <circle cx=\"10.5\" cy=\"12.5\" r=\"1.5\" />\n </svg>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,SAASC,cAAcA,CAAA,EAAuB;EACnD,oBACED,KAAA,CAAAE,aAAA;IACEC,KAAK,EAAC,IAAI;IACVC,MAAM,EAAC,IAAI;IACXC,OAAO,EAAC,WAAW;IACnBC,IAAI,EAAC,cAAc;IACnB,eAAY;EAAM,gBAElBN,KAAA,CAAAE,aAAA;IAAQK,EAAE,EAAC,KAAK;IAACC,EAAE,EAAC,KAAK;IAACC,CAAC,EAAC;EAAK,CAAE,CAAC,eACpCT,KAAA,CAAAE,aAAA;IAAQK,EAAE,EAAC,MAAM;IAACC,EAAE,EAAC,KAAK;IAACC,CAAC,EAAC;EAAK,CAAE,CAAC,eACrCT,KAAA,CAAAE,aAAA;IAAQK,EAAE,EAAC,KAAK;IAACC,EAAE,EAAC,GAAG;IAACC,CAAC,EAAC;EAAK,CAAE,CAAC,eAClCT,KAAA,CAAAE,aAAA;IAAQK,EAAE,EAAC,MAAM;IAACC,EAAE,EAAC,GAAG;IAACC,CAAC,EAAC;EAAK,CAAE,CAAC,eACnCT,KAAA,CAAAE,aAAA;IAAQK,EAAE,EAAC,KAAK;IAACC,EAAE,EAAC,MAAM;IAACC,CAAC,EAAC;EAAK,CAAE,CAAC,eACrCT,KAAA,CAAAE,aAAA;IAAQK,EAAE,EAAC,MAAM;IAACC,EAAE,EAAC,MAAM;IAACC,CAAC,EAAC;EAAK,CAAE,CAClC,CAAC;AAEV","ignoreList":[]}
|
|
@@ -31,6 +31,7 @@ export function FilterList(props) {
|
|
|
31
31
|
onReset,
|
|
32
32
|
onFilterAdded,
|
|
33
33
|
showActiveFilterCount = false,
|
|
34
|
+
enableSorting,
|
|
34
35
|
className,
|
|
35
36
|
renderAddFilterButton
|
|
36
37
|
} = props;
|
|
@@ -66,7 +67,8 @@ export function FilterList(props) {
|
|
|
66
67
|
filterDefinitions: visibleFilterDefinitions,
|
|
67
68
|
filterStates: filterStates,
|
|
68
69
|
onFilterStateChanged: setFilterState,
|
|
69
|
-
whereClause: whereClause
|
|
70
|
+
whereClause: whereClause,
|
|
71
|
+
enableSorting: enableSorting
|
|
70
72
|
}), (renderAddFilterButton != null || onFilterAdded != null) && /*#__PURE__*/React.createElement("div", {
|
|
71
73
|
className: styles.addButtonContainer
|
|
72
74
|
}, renderAddFilterButton ? renderAddFilterButton() : /*#__PURE__*/React.createElement(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterList.js","names":["Button","classnames","React","useCallback","useMemo","useFilterListState","styles","FilterListContent","FilterListHeader","FilterList","props","objectSet","title","titleIcon","filterDefinitions","showResetButton","onReset","onFilterAdded","showActiveFilterCount","className","renderAddFilterButton","objectType","$objectSetInternals","def","filterStates","setFilterState","whereClause","activeFilterCount","reset","handleReset","visibleFilterDefinitions","undefined","filter","isVisible","createElement","filterList","onFilterStateChanged","addButtonContainer","type","addButton"],"sources":["FilterList.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 { Button } from \"@base-ui/react/button\";\nimport type { ObjectTypeDefinition } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../FilterListApi.js\";\nimport { useFilterListState } from \"../hooks/useFilterListState.js\";\nimport styles from \"./FilterList.module.css\";\nimport { FilterListContent } from \"./FilterListContent.js\";\nimport { FilterListHeader } from \"./FilterListHeader.js\";\n\nexport function FilterList<Q extends ObjectTypeDefinition>(\n props: FilterListProps<Q>,\n): React.ReactElement {\n const {\n objectSet,\n title,\n titleIcon,\n filterDefinitions,\n showResetButton = false,\n onReset,\n onFilterAdded,\n showActiveFilterCount = false,\n className,\n renderAddFilterButton,\n } = props;\n\n const objectType = objectSet.$objectSetInternals.def;\n\n const {\n filterStates,\n setFilterState,\n whereClause,\n activeFilterCount,\n reset,\n } = useFilterListState(props);\n\n const handleReset = useCallback(() => {\n reset();\n onReset?.();\n }, [reset, onReset]);\n\n const visibleFilterDefinitions = useMemo(() => {\n if (!filterDefinitions) return undefined;\n return filterDefinitions.filter(\n (def: FilterDefinitionUnion<Q>) => def.isVisible !== false,\n );\n }, [filterDefinitions]);\n\n const showHeader = title || titleIcon || showResetButton\n || showActiveFilterCount;\n\n const showAddButton = renderAddFilterButton != null || onFilterAdded != null;\n\n return (\n <div\n className={classnames(styles.filterList, className)}\n data-active-count={activeFilterCount}\n >\n {showHeader && (\n <FilterListHeader\n title={title}\n titleIcon={titleIcon}\n showResetButton={showResetButton}\n onReset={handleReset}\n showActiveFilterCount={showActiveFilterCount}\n activeFilterCount={activeFilterCount}\n />\n )}\n\n <FilterListContent\n objectType={objectType}\n objectSet={objectSet}\n filterDefinitions={visibleFilterDefinitions}\n filterStates={filterStates}\n onFilterStateChanged={setFilterState}\n whereClause={whereClause}\n />\n\n {showAddButton && (\n <div className={styles.addButtonContainer}>\n {renderAddFilterButton\n ? renderAddFilterButton()\n : (\n <Button type=\"button\" className={styles.addButton}>\n + Add filter\n </Button>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAE9C,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAKnD,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,OAAOC,MAAM,MAAM,yBAAyB;AAC5C,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAO,SAASC,UAAUA,CACxBC,KAAyB,EACL;EACpB,MAAM;IACJC,SAAS;IACTC,KAAK;IACLC,SAAS;IACTC,iBAAiB;IACjBC,eAAe,GAAG,KAAK;IACvBC,OAAO;IACPC,aAAa;IACbC,qBAAqB,GAAG,KAAK;IAC7BC,SAAS;IACTC;EACF,CAAC,
|
|
1
|
+
{"version":3,"file":"FilterList.js","names":["Button","classnames","React","useCallback","useMemo","useFilterListState","styles","FilterListContent","FilterListHeader","FilterList","props","objectSet","title","titleIcon","filterDefinitions","showResetButton","onReset","onFilterAdded","showActiveFilterCount","enableSorting","className","renderAddFilterButton","objectType","$objectSetInternals","def","filterStates","setFilterState","whereClause","activeFilterCount","reset","handleReset","visibleFilterDefinitions","undefined","filter","isVisible","createElement","filterList","onFilterStateChanged","addButtonContainer","type","addButton"],"sources":["FilterList.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 { Button } from \"@base-ui/react/button\";\nimport type { ObjectTypeDefinition } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../FilterListApi.js\";\nimport { useFilterListState } from \"../hooks/useFilterListState.js\";\nimport styles from \"./FilterList.module.css\";\nimport { FilterListContent } from \"./FilterListContent.js\";\nimport { FilterListHeader } from \"./FilterListHeader.js\";\n\nexport function FilterList<Q extends ObjectTypeDefinition>(\n props: FilterListProps<Q>,\n): React.ReactElement {\n const {\n objectSet,\n title,\n titleIcon,\n filterDefinitions,\n showResetButton = false,\n onReset,\n onFilterAdded,\n showActiveFilterCount = false,\n enableSorting,\n className,\n renderAddFilterButton,\n } = props;\n\n const objectType = objectSet.$objectSetInternals.def;\n\n const {\n filterStates,\n setFilterState,\n whereClause,\n activeFilterCount,\n reset,\n } = useFilterListState(props);\n\n const handleReset = useCallback(() => {\n reset();\n onReset?.();\n }, [reset, onReset]);\n\n const visibleFilterDefinitions = useMemo(() => {\n if (!filterDefinitions) return undefined;\n return filterDefinitions.filter(\n (def: FilterDefinitionUnion<Q>) => def.isVisible !== false,\n );\n }, [filterDefinitions]);\n\n const showHeader = title || titleIcon || showResetButton\n || showActiveFilterCount;\n\n const showAddButton = renderAddFilterButton != null || onFilterAdded != null;\n\n return (\n <div\n className={classnames(styles.filterList, className)}\n data-active-count={activeFilterCount}\n >\n {showHeader && (\n <FilterListHeader\n title={title}\n titleIcon={titleIcon}\n showResetButton={showResetButton}\n onReset={handleReset}\n showActiveFilterCount={showActiveFilterCount}\n activeFilterCount={activeFilterCount}\n />\n )}\n\n <FilterListContent\n objectType={objectType}\n objectSet={objectSet}\n filterDefinitions={visibleFilterDefinitions}\n filterStates={filterStates}\n onFilterStateChanged={setFilterState}\n whereClause={whereClause}\n enableSorting={enableSorting}\n />\n\n {showAddButton && (\n <div className={styles.addButtonContainer}>\n {renderAddFilterButton\n ? renderAddFilterButton()\n : (\n <Button type=\"button\" className={styles.addButton}>\n + Add filter\n </Button>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAE9C,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,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;IACbC,SAAS,EAAEA,SAAU;IACrBE,eAAe,EAAEA,eAAgB;IACjCC,OAAO,EAAEc,WAAY;IACrBZ,qBAAqB,EAAEA,qBAAsB;IAC7CU,iBAAiB,EAAEA;EAAkB,CACtC,CACF,eAED1B,KAAA,CAAAiC,aAAA,CAAC5B,iBAAiB;IAChBe,UAAU,EAAEA,UAAW;IACvBX,SAAS,EAAEA,SAAU;IACrBG,iBAAiB,EAAEiB,wBAAyB;IAC5CN,YAAY,EAAEA,YAAa;IAC3BY,oBAAoB,EAAEX,cAAe;IACrCC,WAAW,EAAEA,WAAY;IACzBR,aAAa,EAAEA;EAAc,CAC9B,CAAC,EAED,CA5BiBE,qBAAqB,IAAI,IAAI,IAAIJ,aAAa,IAAI,IAAI,kBA6BtEf,KAAA,CAAAiC,aAAA;IAAKf,SAAS,EAAEd,MAAM,CAACgC;EAAmB,GACvCjB,qBAAqB,GAClBA,qBAAqB,CAAC,CAAC,gBAEvBnB,KAAA,CAAAiC,aAAA,CAACnC,MAAM;IAACuC,IAAI,EAAC,QAAQ;IAACnB,SAAS,EAAEd,MAAM,CAACkC;EAAU,GAAC,cAE3C,CAET,CAEJ,CAAC;AAEV","ignoreList":[]}
|
|
@@ -14,11 +14,25 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { closestCenter, DndContext, DragOverlay, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
|
18
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
17
19
|
import classnames from "classnames";
|
|
18
|
-
import React from "react";
|
|
20
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
19
21
|
import { getFilterKey } from "../utils/getFilterKey.js";
|
|
22
|
+
import { getFilterLabel } from "../utils/getFilterLabel.js";
|
|
20
23
|
import styles from "./FilterListContent.module.css.js";
|
|
21
24
|
import { FilterListItem } from "./FilterListItem.js";
|
|
25
|
+
import { SortableFilterListItem } from "./SortableFilterListItem.js";
|
|
26
|
+
const restrictToVerticalAxis = ({
|
|
27
|
+
transform
|
|
28
|
+
}) => ({
|
|
29
|
+
...transform,
|
|
30
|
+
x: 0
|
|
31
|
+
});
|
|
32
|
+
const POINTER_ACTIVATION_CONSTRAINT = {
|
|
33
|
+
distance: 8
|
|
34
|
+
};
|
|
35
|
+
const MODIFIERS = [restrictToVerticalAxis];
|
|
22
36
|
export function FilterListContent({
|
|
23
37
|
objectType,
|
|
24
38
|
objectSet,
|
|
@@ -26,20 +40,146 @@ export function FilterListContent({
|
|
|
26
40
|
filterStates,
|
|
27
41
|
onFilterStateChanged,
|
|
28
42
|
whereClause,
|
|
43
|
+
enableSorting,
|
|
29
44
|
className,
|
|
30
45
|
style
|
|
31
46
|
}) {
|
|
32
|
-
|
|
47
|
+
const [internalOrder, setInternalOrder] = useState(() => filterDefinitions ?? []);
|
|
48
|
+
const [activeId, setActiveId] = useState(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (filterDefinitions) {
|
|
51
|
+
setInternalOrder(filterDefinitions);
|
|
52
|
+
}
|
|
53
|
+
}, [filterDefinitions]);
|
|
54
|
+
const renderDefinitions = enableSorting ? internalOrder : filterDefinitions;
|
|
55
|
+
const sortableIds = useMemo(() => enableSorting ? internalOrder.map(def => getFilterKey(def)) : [], [enableSorting, internalOrder]);
|
|
56
|
+
const pointerSensor = useSensor(PointerSensor, {
|
|
57
|
+
activationConstraint: POINTER_ACTIVATION_CONSTRAINT
|
|
58
|
+
});
|
|
59
|
+
const keyboardSensor = useSensor(KeyboardSensor, {
|
|
60
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
61
|
+
});
|
|
62
|
+
const sensors = useSensors(pointerSensor, keyboardSensor);
|
|
63
|
+
const activeIndex = activeId != null ? sortableIds.indexOf(String(activeId)) : -1;
|
|
64
|
+
const activeDefinition = activeIndex >= 0 ? internalOrder[activeIndex] : undefined;
|
|
65
|
+
const activeFilterKey = useMemo(() => activeDefinition ? getFilterKey(activeDefinition) : undefined, [activeDefinition]);
|
|
66
|
+
const handleDragStart = useCallback(event => {
|
|
67
|
+
setActiveId(event.active.id);
|
|
68
|
+
}, []);
|
|
69
|
+
const handleDragEnd = useCallback(event => {
|
|
70
|
+
setActiveId(null);
|
|
71
|
+
const {
|
|
72
|
+
active,
|
|
73
|
+
over
|
|
74
|
+
} = event;
|
|
75
|
+
if (!over || active.id === over.id) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const oldIndex = sortableIds.indexOf(String(active.id));
|
|
79
|
+
const newIndex = sortableIds.indexOf(String(over.id));
|
|
80
|
+
if (oldIndex !== -1 && newIndex !== -1) {
|
|
81
|
+
setInternalOrder(arrayMove(internalOrder, oldIndex, newIndex));
|
|
82
|
+
}
|
|
83
|
+
}, [internalOrder, sortableIds]);
|
|
84
|
+
const handleDragCancel = useCallback(() => {
|
|
85
|
+
setActiveId(null);
|
|
86
|
+
}, []);
|
|
87
|
+
const announcements = useMemo(() => ({
|
|
88
|
+
onDragStart({
|
|
89
|
+
active
|
|
90
|
+
}) {
|
|
91
|
+
const idx = sortableIds.indexOf(String(active.id));
|
|
92
|
+
const def = idx >= 0 ? internalOrder[idx] : undefined;
|
|
93
|
+
const label = def ? getFilterLabel(def) : "filter";
|
|
94
|
+
return `Picked up ${label} filter`;
|
|
95
|
+
},
|
|
96
|
+
onDragOver({
|
|
97
|
+
over
|
|
98
|
+
}) {
|
|
99
|
+
if (!over) {
|
|
100
|
+
return "Not over a droppable area";
|
|
101
|
+
}
|
|
102
|
+
const overIdx = sortableIds.indexOf(String(over.id));
|
|
103
|
+
return `Moved to position ${overIdx + 1} of ${sortableIds.length}`;
|
|
104
|
+
},
|
|
105
|
+
onDragEnd({
|
|
106
|
+
active,
|
|
107
|
+
over
|
|
108
|
+
}) {
|
|
109
|
+
const idx = sortableIds.indexOf(String(active.id));
|
|
110
|
+
const def = idx >= 0 ? internalOrder[idx] : undefined;
|
|
111
|
+
const label = def ? getFilterLabel(def) : "filter";
|
|
112
|
+
if (over && active.id !== over.id) {
|
|
113
|
+
const overIdx = sortableIds.indexOf(String(over.id));
|
|
114
|
+
return `Dropped ${label} filter at position ${overIdx + 1}`;
|
|
115
|
+
}
|
|
116
|
+
return `Dropped ${label} filter back in its original position`;
|
|
117
|
+
},
|
|
118
|
+
onDragCancel({
|
|
119
|
+
active
|
|
120
|
+
}) {
|
|
121
|
+
const idx = sortableIds.indexOf(String(active.id));
|
|
122
|
+
const def = idx >= 0 ? internalOrder[idx] : undefined;
|
|
123
|
+
const label = def ? getFilterLabel(def) : "filter";
|
|
124
|
+
return `Cancelled dragging ${label} filter`;
|
|
125
|
+
}
|
|
126
|
+
}), [internalOrder, sortableIds]);
|
|
127
|
+
if (!renderDefinitions || renderDefinitions.length === 0) {
|
|
33
128
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
129
|
className: classnames(styles.content, className),
|
|
35
130
|
style: style,
|
|
36
131
|
"data-empty": "true"
|
|
37
132
|
});
|
|
38
133
|
}
|
|
134
|
+
if (enableSorting) {
|
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
className: classnames(styles.content, className),
|
|
137
|
+
style: style
|
|
138
|
+
}, /*#__PURE__*/React.createElement(DndContext, {
|
|
139
|
+
sensors: sensors,
|
|
140
|
+
collisionDetection: closestCenter,
|
|
141
|
+
modifiers: MODIFIERS,
|
|
142
|
+
onDragStart: handleDragStart,
|
|
143
|
+
onDragEnd: handleDragEnd,
|
|
144
|
+
onDragCancel: handleDragCancel,
|
|
145
|
+
accessibility: {
|
|
146
|
+
announcements
|
|
147
|
+
}
|
|
148
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
149
|
+
items: sortableIds,
|
|
150
|
+
strategy: verticalListSortingStrategy
|
|
151
|
+
}, internalOrder.map((definition, index) => {
|
|
152
|
+
const id = sortableIds[index];
|
|
153
|
+
const filterKey = getFilterKey(definition);
|
|
154
|
+
const state = filterStates.get(filterKey);
|
|
155
|
+
return /*#__PURE__*/React.createElement(SortableFilterListItem, {
|
|
156
|
+
key: id,
|
|
157
|
+
id: id,
|
|
158
|
+
objectType: objectType,
|
|
159
|
+
objectSet: objectSet,
|
|
160
|
+
definition: definition,
|
|
161
|
+
filterKey: filterKey,
|
|
162
|
+
filterState: state,
|
|
163
|
+
onFilterStateChanged: onFilterStateChanged,
|
|
164
|
+
whereClause: whereClause
|
|
165
|
+
});
|
|
166
|
+
})), /*#__PURE__*/React.createElement(DragOverlay, {
|
|
167
|
+
dropAnimation: null,
|
|
168
|
+
className: styles.dragOverlay
|
|
169
|
+
}, activeDefinition && activeFilterKey && /*#__PURE__*/React.createElement(FilterListItem, {
|
|
170
|
+
objectType: objectType,
|
|
171
|
+
objectSet: objectSet,
|
|
172
|
+
definition: activeDefinition,
|
|
173
|
+
filterKey: activeFilterKey,
|
|
174
|
+
filterState: filterStates.get(activeFilterKey),
|
|
175
|
+
onFilterStateChanged: onFilterStateChanged,
|
|
176
|
+
whereClause: whereClause
|
|
177
|
+
}))));
|
|
178
|
+
}
|
|
39
179
|
return /*#__PURE__*/React.createElement("div", {
|
|
40
180
|
className: classnames(styles.content, className),
|
|
41
181
|
style: style
|
|
42
|
-
},
|
|
182
|
+
}, renderDefinitions.map(definition => {
|
|
43
183
|
const filterKey = getFilterKey(definition);
|
|
44
184
|
const state = filterStates.get(filterKey);
|
|
45
185
|
return /*#__PURE__*/React.createElement(FilterListItem, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterListContent.js","names":["classnames","React","getFilterKey","styles","FilterListItem","FilterListContent","objectType","objectSet","filterDefinitions","filterStates","onFilterStateChanged","whereClause","className","style","length","createElement","content","map","definition","filterKey","state","get","key","filterState"],"sources":["FilterListContent.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 classnames from \"classnames\";\nimport React from \"react\";\nimport type { FilterDefinitionUnion } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport { getFilterKey } from \"../utils/getFilterKey.js\";\nimport styles from \"./FilterListContent.module.css\";\nimport { FilterListItem } from \"./FilterListItem.js\";\n\ninterface FilterListContentProps<Q extends ObjectTypeDefinition> {\n objectType: Q;\n objectSet: ObjectSet<Q>;\n filterDefinitions?: Array<FilterDefinitionUnion<Q>>;\n filterStates: Map<string, FilterState>;\n onFilterStateChanged: (\n filterKey: string,\n state: FilterState,\n ) => void;\n whereClause: WhereClause<Q>;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function FilterListContent<Q extends ObjectTypeDefinition>({\n objectType,\n objectSet,\n filterDefinitions,\n filterStates,\n onFilterStateChanged,\n whereClause,\n className,\n style,\n}: FilterListContentProps<Q>): React.ReactElement {\n if (!filterDefinitions || filterDefinitions.length === 0) {\n return (\n <div\n className={classnames(styles.content, className)}\n style={style}\n data-empty=\"true\"\n />\n );\n }\n\n return (\n <div\n className={classnames(styles.content, className)}\n style={style}\n >\n {filterDefinitions.map((definition, index) => {\n const filterKey = getFilterKey(definition);\n const state = filterStates.get(filterKey);\n\n return (\n <FilterListItem\n key={filterKey}\n objectType={objectType}\n objectSet={objectSet}\n definition={definition}\n filterKey={filterKey}\n filterState={state}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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estCenter","DndContext","DragOverlay","KeyboardSensor","PointerSensor","useSensor","useSensors","arrayMove","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","classnames","React","useCallback","useEffect","useMemo","useState","getFilterKey","getFilterLabel","styles","FilterListItem","SortableFilterListItem","restrictToVerticalAxis","transform","x","POINTER_ACTIVATION_CONSTRAINT","distance","MODIFIERS","FilterListContent","objectType","objectSet","filterDefinitions","filterStates","onFilterStateChanged","whereClause","enableSorting","className","style","internalOrder","setInternalOrder","activeId","setActiveId","renderDefinitions","sortableIds","map","def","pointerSensor","activationConstraint","keyboardSensor","coordinateGetter","sensors","activeIndex","indexOf","String","activeDefinition","undefined","activeFilterKey","handleDragStart","event","active","id","handleDragEnd","over","oldIndex","newIndex","handleDragCancel","announcements","onDragStart","idx","label","onDragOver","overIdx","length","onDragEnd","onDragCancel","createElement","content","collisionDetection","modifiers","accessibility","items","strategy","definition","index","filterKey","state","get","key","filterState","dropAnimation","dragOverlay"],"sources":["FilterListContent.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 {\n Announcements,\n DragEndEvent,\n DragStartEvent,\n Modifier,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport {\n closestCenter,\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n arrayMove,\n SortableContext,\n sortableKeyboardCoordinates,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { FilterDefinitionUnion } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport { getFilterKey } from \"../utils/getFilterKey.js\";\nimport { getFilterLabel } from \"../utils/getFilterLabel.js\";\nimport styles from \"./FilterListContent.module.css\";\nimport { FilterListItem } from \"./FilterListItem.js\";\nimport { SortableFilterListItem } from \"./SortableFilterListItem.js\";\n\nconst restrictToVerticalAxis: Modifier = ({ transform }) => ({\n ...transform,\n x: 0,\n});\n\nconst POINTER_ACTIVATION_CONSTRAINT = { distance: 8 } as const;\nconst MODIFIERS: Modifier[] = [restrictToVerticalAxis];\n\ninterface FilterListContentProps<Q extends ObjectTypeDefinition> {\n objectType: Q;\n objectSet: ObjectSet<Q>;\n filterDefinitions?: Array<FilterDefinitionUnion<Q>>;\n filterStates: Map<string, FilterState>;\n onFilterStateChanged: (\n filterKey: string,\n state: FilterState,\n ) => void;\n whereClause: WhereClause<Q>;\n enableSorting?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function FilterListContent<Q extends ObjectTypeDefinition>({\n objectType,\n objectSet,\n filterDefinitions,\n filterStates,\n onFilterStateChanged,\n whereClause,\n enableSorting,\n className,\n style,\n}: FilterListContentProps<Q>): React.ReactElement {\n const [internalOrder, setInternalOrder] = useState<\n Array<FilterDefinitionUnion<Q>>\n >(() => filterDefinitions ?? []);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n\n useEffect(() => {\n if (filterDefinitions) {\n setInternalOrder(filterDefinitions);\n }\n }, [filterDefinitions]);\n\n const renderDefinitions = enableSorting ? internalOrder : filterDefinitions;\n\n const sortableIds = useMemo(\n () =>\n enableSorting\n ? internalOrder.map((def) => getFilterKey(def))\n : [],\n [enableSorting, internalOrder],\n );\n\n const pointerSensor = useSensor(PointerSensor, {\n activationConstraint: POINTER_ACTIVATION_CONSTRAINT,\n });\n const keyboardSensor = useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n });\n const sensors = useSensors(pointerSensor, keyboardSensor);\n\n const activeIndex = activeId != null\n ? sortableIds.indexOf(String(activeId))\n : -1;\n const activeDefinition = activeIndex >= 0\n ? internalOrder[activeIndex]\n : undefined;\n\n const activeFilterKey = useMemo(\n () => activeDefinition ? getFilterKey(activeDefinition) : undefined,\n [activeDefinition],\n );\n\n const handleDragStart = useCallback((event: DragStartEvent) => {\n setActiveId(event.active.id);\n }, []);\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n setActiveId(null);\n const { active, over } = event;\n if (!over || active.id === over.id) {\n return;\n }\n const oldIndex = sortableIds.indexOf(String(active.id));\n const newIndex = sortableIds.indexOf(String(over.id));\n if (oldIndex !== -1 && newIndex !== -1) {\n setInternalOrder(arrayMove(internalOrder, oldIndex, newIndex));\n }\n },\n [internalOrder, sortableIds],\n );\n\n const handleDragCancel = useCallback(() => {\n setActiveId(null);\n }, []);\n\n const announcements = useMemo<Announcements>(\n () => ({\n onDragStart({ active }) {\n const idx = sortableIds.indexOf(String(active.id));\n const def = idx >= 0 ? internalOrder[idx] : undefined;\n const label = def ? getFilterLabel(def) : \"filter\";\n return `Picked up ${label} filter`;\n },\n onDragOver({ over }) {\n if (!over) {\n return \"Not over a droppable area\";\n }\n const overIdx = sortableIds.indexOf(String(over.id));\n return `Moved to position ${overIdx + 1} of ${sortableIds.length}`;\n },\n onDragEnd({ active, over }) {\n const idx = sortableIds.indexOf(String(active.id));\n const def = idx >= 0 ? internalOrder[idx] : undefined;\n const label = def ? getFilterLabel(def) : \"filter\";\n if (over && active.id !== over.id) {\n const overIdx = sortableIds.indexOf(String(over.id));\n return `Dropped ${label} filter at position ${overIdx + 1}`;\n }\n return `Dropped ${label} filter back in its original position`;\n },\n onDragCancel({ active }) {\n const idx = sortableIds.indexOf(String(active.id));\n const def = idx >= 0 ? internalOrder[idx] : undefined;\n const label = def ? getFilterLabel(def) : \"filter\";\n return `Cancelled dragging ${label} filter`;\n },\n }),\n [internalOrder, sortableIds],\n );\n\n if (!renderDefinitions || renderDefinitions.length === 0) {\n return (\n <div\n className={classnames(styles.content, className)}\n style={style}\n data-empty=\"true\"\n />\n );\n }\n\n if (enableSorting) {\n return (\n <div\n className={classnames(styles.content, className)}\n style={style}\n >\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n modifiers={MODIFIERS}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n onDragCancel={handleDragCancel}\n accessibility={{ announcements }}\n >\n <SortableContext\n items={sortableIds}\n strategy={verticalListSortingStrategy}\n >\n {internalOrder.map((definition, index) => {\n const id = sortableIds[index];\n const filterKey = getFilterKey(definition);\n const state = filterStates.get(filterKey);\n\n return (\n <SortableFilterListItem\n key={id}\n id={id}\n objectType={objectType}\n objectSet={objectSet}\n definition={definition}\n filterKey={filterKey}\n filterState={state}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n />\n );\n })}\n </SortableContext>\n\n <DragOverlay\n dropAnimation={null}\n className={styles.dragOverlay}\n >\n {activeDefinition && activeFilterKey && (\n <FilterListItem\n objectType={objectType}\n objectSet={objectSet}\n definition={activeDefinition}\n filterKey={activeFilterKey}\n filterState={filterStates.get(activeFilterKey)}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n />\n )}\n </DragOverlay>\n </DndContext>\n </div>\n );\n }\n\n return (\n <div\n className={classnames(styles.content, className)}\n style={style}\n >\n {renderDefinitions.map((definition) => {\n const filterKey = getFilterKey(definition);\n const state = filterStates.get(filterKey);\n\n return (\n <FilterListItem\n key={filterKey}\n objectType={objectType}\n objectSet={objectSet}\n definition={definition}\n filterKey={filterKey}\n filterState={state}\n onFilterStateChanged={onFilterStateChanged}\n whereClause={whereClause}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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iBAClC5C,KAAA,CAAA+D,aAAA,CAACvD,cAAc;MACbS,UAAU,EAAEA,UAAW;MACvBC,SAAS,EAAEA,SAAU;MACrBoD,UAAU,EAAE5B,gBAAiB;MAC7B8B,SAAS,EAAE5B,eAAgB;MAC3BgC,WAAW,EAAExD,YAAY,CAACsD,GAAG,CAAC9B,eAAe,CAAE;MAC/CvB,oBAAoB,EAAEA,oBAAqB;MAC3CC,WAAW,EAAEA;IAAY,CAC1B,CAEQ,CACH,CACT,CAAC;EAEV;EAEA,oBACEtB,KAAA,CAAA+D,aAAA;IACEvC,SAAS,EAAEzB,UAAU,CAACQ,MAAM,CAACyD,OAAO,EAAExC,SAAS,CAAE;IACjDC,KAAK,EAAEA;EAAM,GAEZK,iBAAiB,CAACE,GAAG,CAAEsC,UAAU,IAAK;IACrC,MAAME,SAAS,GAAGnE,YAAY,CAACiE,UAAU,CAAC;IAC1C,MAAMG,KAAK,GAAGrD,YAAY,CAACsD,GAAG,CAACF,SAAS,CAAC;IAEzC,oBACExE,KAAA,CAAA+D,aAAA,CAACvD,cAAc;MACbmE,GAAG,EAAEH,SAAU;MACfvD,UAAU,EAAEA,UAAW;MACvBC,SAAS,EAAEA,SAAU;MACrBoD,UAAU,EAAEA,UAAW;MACvBE,SAAS,EAAEA,SAAU;MACrBI,WAAW,EAAEH,KAAM;MACnBpD,oBAAoB,EAAEA,oBAAqB;MAC3CC,WAAW,EAAEA;IAAY,CAC1B,CAAC;EAEN,CAAC,CACE,CAAC;AAEV","ignoreList":[]}
|
|
@@ -25,3 +25,9 @@
|
|
|
25
25
|
color: var(--osdk-filter-list-empty-text-color);
|
|
26
26
|
font-size: var(--osdk-filter-list-empty-font-size);
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
.dragOverlay {
|
|
30
|
+
box-shadow: var(--osdk-filter-item-drag-overlay-shadow);
|
|
31
|
+
border-radius: var(--osdk-filter-item-drag-overlay-border-radius);
|
|
32
|
+
background: var(--osdk-filter-item-drag-overlay-bg);
|
|
33
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// CSS Module proxy for FilterListContent.module.css
|
|
2
2
|
const styles = {
|
|
3
3
|
"content": "FilterListContent-module__content___fG0EgVp6",
|
|
4
|
-
"emptyMessage": "FilterListContent-module__emptyMessage___9wdgSE9W"
|
|
4
|
+
"emptyMessage": "FilterListContent-module__emptyMessage___9wdgSE9W",
|
|
5
|
+
"dragOverlay": "FilterListContent-module__dragOverlay___Tjd1YpmI"
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
export default styles;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
/*
|
|
2
3
|
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
4
|
*
|
|
@@ -17,6 +18,8 @@
|
|
|
17
18
|
import classnames from "classnames";
|
|
18
19
|
import React, { memo, useCallback } from "react";
|
|
19
20
|
import { ErrorBoundary } from "../../shared/ErrorBoundary.js";
|
|
21
|
+
import { getFilterLabel } from "../utils/getFilterLabel.js";
|
|
22
|
+
import { DragHandleIcon } from "./DragHandleIcon.js";
|
|
20
23
|
import { FilterInput } from "./FilterInput.js";
|
|
21
24
|
import styles from "./FilterListItem.module.css.js";
|
|
22
25
|
function FilterListItemInner({
|
|
@@ -27,10 +30,12 @@ function FilterListItemInner({
|
|
|
27
30
|
filterState,
|
|
28
31
|
onFilterStateChanged,
|
|
29
32
|
whereClause,
|
|
33
|
+
dragHandleAttributes,
|
|
34
|
+
dragHandleListeners,
|
|
30
35
|
className,
|
|
31
36
|
style
|
|
32
37
|
}) {
|
|
33
|
-
const label =
|
|
38
|
+
const label = getFilterLabel(definition);
|
|
34
39
|
const handleFilterStateChanged = useCallback(newState => {
|
|
35
40
|
onFilterStateChanged(filterKey, newState);
|
|
36
41
|
}, [filterKey, onFilterStateChanged]);
|
|
@@ -40,7 +45,11 @@ function FilterListItemInner({
|
|
|
40
45
|
"data-filter-type": definition.type
|
|
41
46
|
}, /*#__PURE__*/React.createElement("div", {
|
|
42
47
|
className: styles.itemHeader
|
|
43
|
-
}, /*#__PURE__*/React.createElement("
|
|
48
|
+
}, dragHandleAttributes && /*#__PURE__*/React.createElement("button", _extends({
|
|
49
|
+
type: "button",
|
|
50
|
+
className: styles.dragHandle,
|
|
51
|
+
"aria-label": `Reorder ${label}`
|
|
52
|
+
}, dragHandleAttributes, dragHandleListeners), /*#__PURE__*/React.createElement(DragHandleIcon, null)), /*#__PURE__*/React.createElement("span", {
|
|
44
53
|
className: styles.itemLabel
|
|
45
54
|
}, label)), /*#__PURE__*/React.createElement("div", {
|
|
46
55
|
className: styles.itemContent
|
|
@@ -56,20 +65,4 @@ function FilterListItemInner({
|
|
|
56
65
|
}))));
|
|
57
66
|
}
|
|
58
67
|
export const FilterListItem = /*#__PURE__*/memo(FilterListItemInner);
|
|
59
|
-
function getLabel(definition) {
|
|
60
|
-
if ("label" in definition && definition.label) {
|
|
61
|
-
return definition.label;
|
|
62
|
-
}
|
|
63
|
-
switch (definition.type) {
|
|
64
|
-
case "PROPERTY":
|
|
65
|
-
return definition.key;
|
|
66
|
-
case "HAS_LINK":
|
|
67
|
-
case "LINKED_PROPERTY":
|
|
68
|
-
return definition.linkName;
|
|
69
|
-
case "KEYWORD_SEARCH":
|
|
70
|
-
return "Search";
|
|
71
|
-
case "CUSTOM":
|
|
72
|
-
return definition.key;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
68
|
//# sourceMappingURL=FilterListItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterListItem.js","names":["classnames","React","memo","useCallback","ErrorBoundary","FilterInput","styles","FilterListItemInner","objectType","objectSet","definition","filterKey","filterState","onFilterStateChanged","whereClause","className","style","label","
|
|
1
|
+
{"version":3,"file":"FilterListItem.js","names":["classnames","React","memo","useCallback","ErrorBoundary","getFilterLabel","DragHandleIcon","FilterInput","styles","FilterListItemInner","objectType","objectSet","definition","filterKey","filterState","onFilterStateChanged","whereClause","dragHandleAttributes","dragHandleListeners","className","style","label","handleFilterStateChanged","newState","createElement","filterItem","type","itemHeader","_extends","dragHandle","itemLabel","itemContent","errorMessage","FilterListItem"],"sources":["FilterListItem.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 {\n DraggableAttributes,\n DraggableSyntheticListeners,\n} from \"@dnd-kit/core\";\nimport type { ObjectSet, ObjectTypeDefinition, WhereClause } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React, { memo, useCallback } from \"react\";\nimport { ErrorBoundary } from \"../../shared/ErrorBoundary.js\";\nimport type { FilterDefinitionUnion } from \"../FilterListApi.js\";\nimport type { FilterState } from \"../FilterListItemApi.js\";\nimport { getFilterLabel } from \"../utils/getFilterLabel.js\";\nimport { DragHandleIcon } from \"./DragHandleIcon.js\";\nimport { FilterInput } from \"./FilterInput.js\";\nimport styles from \"./FilterListItem.module.css\";\n\ninterface FilterListItemProps<Q extends ObjectTypeDefinition> {\n objectType: Q;\n objectSet: ObjectSet<Q>;\n definition: FilterDefinitionUnion<Q>;\n filterKey: string;\n filterState: FilterState | undefined;\n onFilterStateChanged: (\n filterKey: string,\n state: FilterState,\n ) => void;\n whereClause: WhereClause<Q>;\n dragHandleAttributes?: DraggableAttributes;\n dragHandleListeners?: DraggableSyntheticListeners;\n className?: string;\n style?: React.CSSProperties;\n}\n\nfunction FilterListItemInner<Q extends ObjectTypeDefinition>({\n objectType,\n objectSet,\n definition,\n filterKey,\n filterState,\n onFilterStateChanged,\n whereClause,\n dragHandleAttributes,\n dragHandleListeners,\n className,\n style,\n}: FilterListItemProps<Q>): React.ReactElement {\n const label = getFilterLabel(definition);\n\n const handleFilterStateChanged = useCallback(\n (newState: FilterState) => {\n onFilterStateChanged(filterKey, newState);\n },\n [filterKey, onFilterStateChanged],\n );\n\n return (\n <div\n className={classnames(styles.filterItem, className)}\n style={style}\n data-filter-type={definition.type}\n >\n <div className={styles.itemHeader}>\n {dragHandleAttributes && (\n <button\n type=\"button\"\n className={styles.dragHandle}\n aria-label={`Reorder ${label}`}\n {...dragHandleAttributes}\n {...dragHandleListeners}\n >\n <DragHandleIcon />\n </button>\n )}\n <span className={styles.itemLabel}>{label}</span>\n </div>\n\n <div className={styles.itemContent}>\n <ErrorBoundary errorMessage=\"Error loading filter\">\n <FilterInput\n objectType={objectType}\n objectSet={objectSet}\n definition={definition}\n filterState={filterState}\n onFilterStateChanged={handleFilterStateChanged}\n whereClause={whereClause}\n />\n </ErrorBoundary>\n </div>\n </div>\n );\n}\n\nexport const FilterListItem = memo(\n FilterListItemInner,\n) as typeof FilterListItemInner;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,IAAI,EAAEC,WAAW,QAAQ,OAAO;AAChD,SAASC,aAAa,QAAQ,+BAA+B;AAG7D,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAOC,MAAM,MAAM,6BAA6B;AAmBhD,SAASC,mBAAmBA,CAAiC;EAC3DC,UAAU;EACVC,SAAS;EACTC,UAAU;EACVC,SAAS;EACTC,WA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AY,CAC1B,CACY,CACZ,CACF,CAAC;AAEV;AAEA,OAAO,MAAMiB,cAAc,gBAAG/B,IAAI,CAChCO,mBACF,CAA+B","ignoreList":[]}
|
|
@@ -36,3 +36,35 @@
|
|
|
36
36
|
display: flex;
|
|
37
37
|
flex-direction: column;
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
.dragHandle {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
padding: var(--osdk-filter-item-drag-handle-padding);
|
|
45
|
+
margin-right: var(--osdk-surface-spacing);
|
|
46
|
+
border: none;
|
|
47
|
+
background: var(--osdk-filter-item-drag-handle-bg);
|
|
48
|
+
cursor: var(--osdk-drag-handle-cursor);
|
|
49
|
+
border-radius: var(--osdk-filter-item-drag-handle-border-radius);
|
|
50
|
+
color: var(--osdk-filter-item-drag-handle-color);
|
|
51
|
+
touch-action: none;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
color: var(--osdk-filter-item-drag-handle-color-hover);
|
|
55
|
+
background: var(--osdk-filter-item-drag-handle-bg-hover);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:active {
|
|
59
|
+
cursor: var(--osdk-drag-handle-cursor-active);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:focus-visible {
|
|
63
|
+
outline: 2px solid var(--osdk-filter-item-drag-handle-focus-outline-color);
|
|
64
|
+
outline-offset: 2px;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dragging {
|
|
69
|
+
opacity: var(--osdk-filter-item-dragging-opacity);
|
|
70
|
+
}
|
|
@@ -3,7 +3,9 @@ const styles = {
|
|
|
3
3
|
"filterItem": "FilterListItem-module__filterItem___fDBkbb7u",
|
|
4
4
|
"itemHeader": "FilterListItem-module__itemHeader___jp4epXg-",
|
|
5
5
|
"itemLabel": "FilterListItem-module__itemLabel___cEnbqE59",
|
|
6
|
-
"itemContent": "FilterListItem-module__itemContent___PfVHHhIy"
|
|
6
|
+
"itemContent": "FilterListItem-module__itemContent___PfVHHhIy",
|
|
7
|
+
"dragHandle": "FilterListItem-module__dragHandle___BwFrILWs",
|
|
8
|
+
"dragging": "FilterListItem-module__dragging___S5-LGyfS"
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export default styles;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useSortable } from "@dnd-kit/sortable";
|
|
18
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
19
|
+
import classnames from "classnames";
|
|
20
|
+
import React, { useMemo } from "react";
|
|
21
|
+
import { FilterListItem } from "./FilterListItem.js";
|
|
22
|
+
import styles from "./FilterListItem.module.css.js";
|
|
23
|
+
export function SortableFilterListItem({
|
|
24
|
+
id,
|
|
25
|
+
objectType,
|
|
26
|
+
objectSet,
|
|
27
|
+
definition,
|
|
28
|
+
filterKey,
|
|
29
|
+
filterState,
|
|
30
|
+
onFilterStateChanged,
|
|
31
|
+
whereClause
|
|
32
|
+
}) {
|
|
33
|
+
const {
|
|
34
|
+
attributes,
|
|
35
|
+
listeners,
|
|
36
|
+
setNodeRef,
|
|
37
|
+
transform,
|
|
38
|
+
transition,
|
|
39
|
+
isDragging
|
|
40
|
+
} = useSortable({
|
|
41
|
+
id
|
|
42
|
+
});
|
|
43
|
+
const style = useMemo(() => ({
|
|
44
|
+
transform: CSS.Transform.toString(transform),
|
|
45
|
+
transition: transition ?? undefined
|
|
46
|
+
}), [transform, transition]);
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
ref: setNodeRef,
|
|
49
|
+
style: style,
|
|
50
|
+
className: classnames(isDragging && styles.dragging)
|
|
51
|
+
}, /*#__PURE__*/React.createElement(FilterListItem, {
|
|
52
|
+
objectType: objectType,
|
|
53
|
+
objectSet: objectSet,
|
|
54
|
+
definition: definition,
|
|
55
|
+
filterKey: filterKey,
|
|
56
|
+
filterState: filterState,
|
|
57
|
+
onFilterStateChanged: onFilterStateChanged,
|
|
58
|
+
whereClause: whereClause,
|
|
59
|
+
dragHandleAttributes: attributes,
|
|
60
|
+
dragHandleListeners: listeners
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=SortableFilterListItem.js.map
|