@pibit.ai/cure-design-system 0.6.37 → 0.6.38

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.
Files changed (34) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +311 -288
  4. package/dist/patterns/filter-group/date-adapter.d.ts +20 -0
  5. package/dist/patterns/filter-group/date-adapter.d.ts.map +1 -0
  6. package/dist/patterns/filter-group/date-adapter.js +38 -0
  7. package/dist/patterns/filter-group/document-fields-to-tree.d.ts +33 -0
  8. package/dist/patterns/filter-group/document-fields-to-tree.d.ts.map +1 -0
  9. package/dist/patterns/filter-group/document-fields-to-tree.js +53 -0
  10. package/dist/patterns/filter-group/filter-condition-row.d.ts +47 -0
  11. package/dist/patterns/filter-group/filter-condition-row.d.ts.map +1 -0
  12. package/dist/patterns/filter-group/filter-condition-row.js +642 -0
  13. package/dist/patterns/filter-group/filter-group-builder.d.ts +42 -0
  14. package/dist/patterns/filter-group/filter-group-builder.d.ts.map +1 -0
  15. package/dist/patterns/filter-group/filter-group-builder.js +92 -0
  16. package/dist/patterns/filter-group/filter-group-card.d.ts +25 -0
  17. package/dist/patterns/filter-group/filter-group-card.d.ts.map +1 -0
  18. package/dist/patterns/filter-group/filter-group-card.js +266 -0
  19. package/dist/patterns/filter-group/index.d.ts +11 -0
  20. package/dist/patterns/filter-group/index.d.ts.map +1 -0
  21. package/dist/patterns/filter-group/nested-field-select.d.ts +68 -0
  22. package/dist/patterns/filter-group/nested-field-select.d.ts.map +1 -0
  23. package/dist/patterns/filter-group/nested-field-select.js +431 -0
  24. package/dist/patterns/filter-group/types.d.ts +105 -0
  25. package/dist/patterns/filter-group/types.d.ts.map +1 -0
  26. package/dist/patterns/filter-group/types.js +222 -0
  27. package/dist/patterns/filter-group/use-filter-group.d.ts +38 -0
  28. package/dist/patterns/filter-group/use-filter-group.d.ts.map +1 -0
  29. package/dist/patterns/filter-group/use-filter-group.js +81 -0
  30. package/dist/patterns/filter-group/validation.d.ts +13 -0
  31. package/dist/patterns/filter-group/validation.d.ts.map +1 -0
  32. package/dist/patterns/filter-group/validation.js +19 -0
  33. package/dist/styles/components.css +1 -1
  34. package/package.json +2 -1
@@ -0,0 +1,20 @@
1
+ import { CalendarDate, CalendarDateTime } from '@internationalized/date';
2
+ import { DateValue } from 'react-aria-components';
3
+ export interface FilterDateAdapter {
4
+ /** A condition's date string as a calendar date; today when empty or unparseable. */
5
+ parseDate: (value?: string) => CalendarDate;
6
+ /** A condition's timestamp string as a date-time, or null when empty. */
7
+ parseTimestamp: (value: unknown) => CalendarDateTime | null;
8
+ /** A picked date-time back to the condition's string; a cleared picker becomes "". */
9
+ formatTimestamp: (value: DateValue | null) => string;
10
+ }
11
+ export declare const parseFilterDate: (dateString?: string) => CalendarDate;
12
+ /**
13
+ * The form's timestamp string as a date-time, or null when empty. A string with no
14
+ * time part reads as midnight.
15
+ */
16
+ export declare const parseFilterTimestamp: (value: unknown) => CalendarDateTime | null;
17
+ /** A picked date-time back to the form's string. A date without a time is midnight. */
18
+ export declare const formatFilterTimestamp: (value: DateValue | null) => string;
19
+ export declare const defaultFilterDateAdapter: FilterDateAdapter;
20
+ //# sourceMappingURL=date-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-adapter.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/date-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA4B,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,MAAM,WAAW,iBAAiB;IAC9B,qFAAqF;IACrF,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IAC5C,yEAAyE;IACzE,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,GAAG,IAAI,CAAC;IAC5D,sFAAsF;IACtF,eAAe,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,MAAM,CAAC;CACxD;AAID,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,KAAG,YAoCrD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,gBAAgB,GAAG,IAQxE,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,GAAI,OAAO,SAAS,GAAG,IAAI,KAAG,MAI/D,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAItC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { Time as i, toCalendarDateTime as h, CalendarDate as o, today as y, getLocalTimeZone as l } from "@internationalized/date";
2
+ const m = (t) => String(t).padStart(2, "0"), p = (t) => {
3
+ if (typeof t == "string" && t) {
4
+ const n = /^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/(\d{2}|\d{4})$/, a = t.match(n);
5
+ if (a) {
6
+ const [, r, d, c] = a, f = parseInt(r, 10), u = parseInt(d, 10);
7
+ let s = parseInt(c, 10);
8
+ return c.length === 2 && (s += s >= 50 ? 1900 : 2e3), new o(s, f, u);
9
+ }
10
+ const e = t.match(/^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])/);
11
+ if (e)
12
+ return new o(parseInt(e[1]), parseInt(e[2]), parseInt(e[3]));
13
+ if (/^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{1,2},\s*\d{4}$/i.test(t)) {
14
+ const r = new Date(t);
15
+ if (!Number.isNaN(r.getTime()))
16
+ return new o(r.getFullYear(), r.getMonth() + 1, r.getDate());
17
+ }
18
+ }
19
+ return y(l());
20
+ }, D = (t) => {
21
+ if (!t || typeof t != "string") return null;
22
+ const [n = "", a = "00:00:00"] = t.split(" "), e = a.match(/(\d{1,2}):(\d{2})(?::(\d{2}))?/), r = e ? new i(Number(e[1]), Number(e[2]), e[3] ? Number(e[3]) : 0) : new i();
23
+ return h(p(n), r);
24
+ }, T = (t) => {
25
+ if (!t) return "";
26
+ const n = "hour" in t ? t : new i();
27
+ return `${t.month}/${t.day}/${t.year} ${m(n.hour)}:${m(n.minute)}:${m(n.second)}`;
28
+ }, w = {
29
+ parseDate: p,
30
+ parseTimestamp: D,
31
+ formatTimestamp: T
32
+ };
33
+ export {
34
+ w as defaultFilterDateAdapter,
35
+ T as formatFilterTimestamp,
36
+ p as parseFilterDate,
37
+ D as parseFilterTimestamp
38
+ };
@@ -0,0 +1,33 @@
1
+ import { DocumentFieldsConfig } from './types';
2
+ import { TreeViewBuildConfig } from '../tree-view';
3
+ export declare const TREE_CONFIG: TreeViewBuildConfig;
4
+ export interface DocumentFieldTreeNode {
5
+ id: string;
6
+ label: string;
7
+ type: string;
8
+ children: DocumentFieldTreeNode[];
9
+ icon?: DocumentFieldsConfig[string]["icon"];
10
+ }
11
+ /**
12
+ * Convert DocumentFieldsConfig to a root-level array of nodes for TreeView, read with TREE_CONFIG.
13
+ */
14
+ export declare function documentFieldsToTreeData(documentFields: DocumentFieldsConfig): DocumentFieldTreeNode[];
15
+ /**
16
+ * Collect ids of all nodes that have children in the given tree. Used to expand those nodes
17
+ * by default so that search results (or selected path) are visible. TreeView builds full path
18
+ * ids (e.g. "ACORD.location.city") from the segment ids of the raw tree this works on, so this
19
+ * walks the same raw tree and joins the segments the same way to get matching ids.
20
+ * We do a recursive walk and build path as we go, adding to expanded set when node has children.
21
+ */
22
+ export declare function getExpandedIdsForTree(nodes: DocumentFieldTreeNode[], parentPath?: string): Set<string>;
23
+ /**
24
+ * Given a selected field id (e.g. "ACORD.location.city"), return the set of parent path ids
25
+ * that should be expanded so the selected node is visible: ["ACORD", "ACORD.location"].
26
+ */
27
+ export declare function getExpandedIdsForSelectedField(selectedFieldId: string): Set<string>;
28
+ /**
29
+ * Filter tree data by search query: keep nodes whose label (or any descendant) matches.
30
+ * Returns new tree with only matching nodes and their ancestors.
31
+ */
32
+ export declare function filterTreeBySearch(nodes: DocumentFieldTreeNode[], query: string): DocumentFieldTreeNode[];
33
+ //# sourceMappingURL=document-fields-to-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-fields-to-tree.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/document-fields-to-tree.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAA2B,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,eAAO,MAAM,WAAW,EAAE,mBAAiF,CAAC;AAE5G,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,qBAAqB,EAAE,CAAC;IAClC,IAAI,CAAC,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;CAC/C;AAWD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,oBAAoB,GAAG,qBAAqB,EAAE,CAQtG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,EAAE,EAAE,UAAU,GAAE,MAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAa1G;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,eAAe,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAQnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAmBzG"}
@@ -0,0 +1,53 @@
1
+ const a = { labelKey: "label", childrenKey: "children", idKey: "id" };
2
+ function d(n) {
3
+ return n.map((e) => ({
4
+ id: e.key,
5
+ label: e.label,
6
+ type: e.type ?? "object",
7
+ children: e.children ? d(e.children) : []
8
+ }));
9
+ }
10
+ function s(n) {
11
+ return Object.entries(n).map(([e, t]) => ({
12
+ id: e,
13
+ label: t.label,
14
+ type: "document",
15
+ children: d(t.fields),
16
+ icon: t.icon
17
+ }));
18
+ }
19
+ function u(n, e = "") {
20
+ const t = /* @__PURE__ */ new Set();
21
+ function r(c, l) {
22
+ for (const i of c) {
23
+ const o = l ? `${l}.${i.id}` : i.id;
24
+ i.children.length > 0 && (t.add(o), r(i.children, o));
25
+ }
26
+ }
27
+ return r(n, e), t;
28
+ }
29
+ function h(n) {
30
+ if (!n.trim()) return /* @__PURE__ */ new Set();
31
+ const e = n.split("."), t = /* @__PURE__ */ new Set();
32
+ for (let r = 1; r < e.length; r++)
33
+ t.add(e.slice(0, r).join("."));
34
+ return t;
35
+ }
36
+ function f(n, e) {
37
+ if (!e.trim()) return n;
38
+ const t = e.toLowerCase();
39
+ function r(c) {
40
+ return c.map((l) => {
41
+ const i = r(l.children);
42
+ return l.label.toLowerCase().includes(t) || i.length > 0 ? { ...l, children: i.length > 0 ? i : l.children } : null;
43
+ }).filter((l) => l !== null);
44
+ }
45
+ return r(n);
46
+ }
47
+ export {
48
+ a as TREE_CONFIG,
49
+ s as documentFieldsToTreeData,
50
+ f as filterTreeBySearch,
51
+ h as getExpandedIdsForSelectedField,
52
+ u as getExpandedIdsForTree
53
+ };
@@ -0,0 +1,47 @@
1
+ import { default as React } from 'react';
2
+ import { FilterDateAdapter } from './date-adapter';
3
+ import { FilterCondition, FilterField, FilterOperator, FilterLogicalOperator, DocumentFieldsConfig } from './types';
4
+ interface FilterConditionRowProps {
5
+ condition: FilterCondition;
6
+ fields: FilterField[];
7
+ operators?: FilterOperator[];
8
+ logicalOperator?: FilterLogicalOperator;
9
+ isFirst: boolean;
10
+ showLogicalOperator: boolean;
11
+ onUpdate: (updates: Partial<FilterCondition>) => void;
12
+ onDelete: () => void;
13
+ onLogicalOperatorChange?: (operator: FilterLogicalOperator) => void;
14
+ size?: "sm" | "md" | "lg";
15
+ /** Whether drag is enabled */
16
+ dragEnabled?: boolean;
17
+ /** Document fields for nested field selection (optional, uses standard select if not provided) */
18
+ documentFields?: DocumentFieldsConfig;
19
+ /** Whether to use fixed positioning for the dropdown */
20
+ useFixedPositioning?: boolean;
21
+ /** Whether this condition is invalid */
22
+ isInvalid?: boolean;
23
+ allowFlexCol?: boolean;
24
+ /** Whether to force text input for all value fields (date/timestamp will use text input instead of date picker) */
25
+ forceTextInput?: boolean;
26
+ /** Whether to hide the logical operator / Where label column entirely */
27
+ hideLabels?: boolean;
28
+ /** Options for multiselect value input when operator requires multiple values (e.g. "in", "not in"). If not provided, options are derived from the selected field when it is a select type. */
29
+ multiselectOptions?: {
30
+ id: string;
31
+ label: string;
32
+ }[];
33
+ /** When true, value inputs (single select and multi-select) support searching/filtering options. Default false. */
34
+ searchable?: boolean;
35
+ /**
36
+ * Optional test-id prefix. When set, the row emits `${prefix}-row`, `-field-select`, `-operator-select`,
37
+ * `-value-input`, `-remove-button` and `-drag-handle` test ids. No attributes are emitted when undefined.
38
+ */
39
+ testIdPrefix?: string;
40
+ /** Optional row index, emitted as `data-row-index` only when `testIdPrefix` is set. */
41
+ rowIndex?: number;
42
+ /** Date/timestamp string plumbing; defaults to the platform formats (M/D/YYYY, M/D/YYYY HH:MM:SS). */
43
+ dateAdapter?: FilterDateAdapter;
44
+ }
45
+ export declare const FilterConditionRow: React.FC<FilterConditionRowProps>;
46
+ export default FilterConditionRow;
47
+ //# sourceMappingURL=filter-condition-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-condition-row.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/filter-condition-row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAMjF,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EACR,eAAe,EACf,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,o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