@pega/cosmos-react-demos 7.16.5 → 7.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ import type { ConditionFieldType, Field, Condition } from '@pega/cosmos-react-condition-builder';
2
+ export declare const sharedFieldTypes: readonly ["BOOLEAN", "TEXT", "DECIMAL", "INTEGER", "DATE_TIME", "DATE_ONLY", "TIME_ONLY"];
3
+ export declare const isFieldType: (t: ConditionFieldType) => t is "BOOLEAN" | "TEXT" | "DECIMAL" | "INTEGER" | "DATE_TIME" | "DATE_ONLY" | "TIME_ONLY";
4
+ export declare const createStoryFields: (demoFiltersInput: {
5
+ field: {
6
+ name: string;
7
+ type: ConditionFieldType;
8
+ };
9
+ label?: string;
10
+ }[]) => Field[];
11
+ export declare const storyFields: Field[];
12
+ export declare const transformSingleChild: (child: Condition, storyFieldsInput: Field[]) => Condition;
13
+ //# sourceMappingURL=PromotedFilters.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromotedFilters.helpers.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAKjG,eAAO,MAAM,gBAAgB,2FAQqB,CAAC;AAEnD,eAAO,MAAM,WAAW,MAAO,kBAAkB,8FACZ,CAAC;AAEtC,eAAO,MAAM,iBAAiB,qBACV;IAAE,KAAK,EAAE;QAAE,MAAM,MAAM,CAAC;QAAC,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,KACxF,KAAK,EAKL,CAAC;AAEJ,eAAO,MAAM,WAAW,SAAiC,CAAC;AAG1D,eAAO,MAAM,oBAAoB,UAAW,SAAS,oBAAoB,KAAK,EAAE,KAAG,SAKlF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { transformComplexCondition } from '@pega/cosmos-react-condition-builder';
2
+ import { demoFilters } from './PromotedFilters.mocks';
3
+ export const sharedFieldTypes = [
4
+ 'BOOLEAN',
5
+ 'TEXT',
6
+ 'DECIMAL',
7
+ 'INTEGER',
8
+ 'DATE_TIME',
9
+ 'DATE_ONLY',
10
+ 'TIME_ONLY'
11
+ ];
12
+ export const isFieldType = (t) => sharedFieldTypes.some(s => s === t);
13
+ export const createStoryFields = (demoFiltersInput) => demoFiltersInput.flatMap(({ field, label }) => isFieldType(field.type)
14
+ ? [{ id: field.name, primary: label ?? field.name, type: field.type }]
15
+ : []);
16
+ export const storyFields = createStoryFields(demoFilters);
17
+ // Wrap a single child in AND so the transformer can process it, then unwrap the result.
18
+ export const transformSingleChild = (child, storyFieldsInput) => {
19
+ const result = transformComplexCondition({ AND: [child] }, storyFieldsInput);
20
+ return 'AND' in result && Array.isArray(result.AND) && result.AND.length === 1
21
+ ? result.AND[0]
22
+ : result;
23
+ };
24
+ //# sourceMappingURL=PromotedFilters.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromotedFilters.helpers.js","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;IACX,WAAW;IACX,WAAW;CACqC,CAAC;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAqB,EAA0C,EAAE,CAC3F,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,gBAAyF,EAChF,EAAE,CACX,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAC5C,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IACtE,CAAC,CAAC,EAAE,CACP,CAAC;AAEJ,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAE1D,wFAAwF;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAgB,EAAE,gBAAyB,EAAa,EAAE;IAC7F,MAAM,MAAM,GAAG,yBAAyB,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAC7E,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;QAC5E,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,MAAM,CAAC;AACb,CAAC,CAAC","sourcesContent":["import type { ConditionFieldType, Field, Condition } from '@pega/cosmos-react-condition-builder';\nimport { transformComplexCondition } from '@pega/cosmos-react-condition-builder';\n\nimport { demoFilters } from './PromotedFilters.mocks';\n\nexport const sharedFieldTypes = [\n 'BOOLEAN',\n 'TEXT',\n 'DECIMAL',\n 'INTEGER',\n 'DATE_TIME',\n 'DATE_ONLY',\n 'TIME_ONLY'\n] as const satisfies readonly ConditionFieldType[];\n\nexport const isFieldType = (t: ConditionFieldType): t is (typeof sharedFieldTypes)[number] =>\n sharedFieldTypes.some(s => s === t);\n\nexport const createStoryFields = (\n demoFiltersInput: { field: { name: string; type: ConditionFieldType }; label?: string }[]\n): Field[] =>\n demoFiltersInput.flatMap(({ field, label }) =>\n isFieldType(field.type)\n ? [{ id: field.name, primary: label ?? field.name, type: field.type }]\n : []\n );\n\nexport const storyFields = createStoryFields(demoFilters);\n\n// Wrap a single child in AND so the transformer can process it, then unwrap the result.\nexport const transformSingleChild = (child: Condition, storyFieldsInput: Field[]): Condition => {\n const result = transformComplexCondition({ AND: [child] }, storyFieldsInput);\n return 'AND' in result && Array.isArray(result.AND) && result.AND.length === 1\n ? result.AND[0]\n : result;\n};\n"]}
@@ -1,4 +1,12 @@
1
+ import type { Meta } from '@storybook/react';
1
2
  import type { Condition, PromotedFiltersProps } from '@pega/cosmos-react-condition-builder';
3
+ export interface PromotedFiltersStoryProps {
4
+ orientation?: 'vertical' | 'horizontal';
5
+ timeZone?: string;
6
+ showTransformedOutput?: boolean;
7
+ }
8
+ export declare const meta: Meta;
9
+ export declare const storyMeta: Meta;
2
10
  export declare const demoCondition: Condition;
3
11
  export declare const demoFilters: PromotedFiltersProps['filters'];
4
12
  //# sourceMappingURL=PromotedFilters.mocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromotedFilters.mocks.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5F,eAAO,MAAM,aAAa,EAAE,SAoB3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,SAAS,CAmNvD,CAAC"}
1
+ {"version":3,"file":"PromotedFilters.mocks.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5F,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,IAAI,EAAE,IAGlB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,IAAW,CAAC;AAEpC,eAAO,MAAM,aAAa,EAAE,SAoB3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,SAAS,CAmNvD,CAAC"}
@@ -1,3 +1,9 @@
1
+ import { PromotedFilters } from '@pega/cosmos-react-condition-builder';
2
+ export const meta = {
3
+ title: 'Condition Builder/PromotedFilters',
4
+ component: PromotedFilters
5
+ };
6
+ export const storyMeta = meta;
1
7
  export const demoCondition = {
2
8
  AND: [
3
9
  {
@@ -1 +1 @@
1
- {"version":3,"file":"PromotedFilters.mocks.js","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.mocks.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,GAAG,EAAE;QACH;YACE,SAAS,EAAE;gBACT,GAAG,EAAE;oBACH,KAAK,EAAE,WAAW;iBACnB;gBACD,UAAU,EAAE,IAAI;gBAChB,GAAG,EAAE;oBACH,KAAK,EAAE,MAAM;iBACd;aACF;SACF;QACD;YACE,SAAS,EAAE;gBACT,GAAG,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;gBAChC,UAAU,EAAE,SAAS;aACtB;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAoC;IAC1D,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE;IACpF,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,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AE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;gBAC7B,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;gBAC/B,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE;aACxC,CAAC;SACL;QACD,IAAI,EAAE,UAAU;KACjB;CACF,CAAC","sourcesContent":["import type { Condition, PromotedFiltersProps } from '@pega/cosmos-react-condition-builder';\n\nexport const demoCondition: Condition = {\n AND: [\n {\n condition: {\n lhs: {\n field: 'FirstName'\n },\n comparator: 'EQ',\n rhs: {\n value: 'John'\n }\n }\n },\n {\n condition: {\n lhs: { field: 'RemoteEmployee' },\n comparator: 'IS_TRUE'\n }\n }\n ]\n};\n\nexport const demoFilters: PromotedFiltersProps['filters'] = [\n { field: { name: 'FirstName', type: 'TEXT' }, mode: 'default', label: 'First name' },\n { field: { name: 'LastName', type: 'TEXT' }, mode: 'advanced', label: 'Last name' },\n {\n field: {\n name: 'JobDescription',\n type: 'TEXT',\n possibleValues: [\n 'Software Engineer',\n 'Front End Developer',\n 'QA Engineer',\n 'Manager',\n 'Product Manager',\n 'Product Owner'\n ]\n },\n mode: 'advanced',\n label: 'Job description'\n },\n {\n field: { name: 'Experience', type: 'INTEGER' },\n mode: 'default',\n label: 'Years of experience'\n },\n {\n field: {\n name: 'Score',\n type: 'INTEGER'\n },\n mode: 'predefined',\n label: 'Score',\n predefinedConditions: [\n {\n id: 'score1',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'GT',\n rhs: {\n value: 0\n }\n }\n },\n {\n id: 'score2',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'EQ',\n rhs: {\n value: 0\n }\n }\n },\n {\n id: 'score3',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'LT',\n rhs: {\n value: 0\n }\n }\n },\n {\n id: 'score4',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'BTW',\n rhs: {\n start: 0,\n end: 10\n }\n }\n },\n {\n id: 'score5',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'IS_NULL'\n }\n }\n ]\n },\n {\n field: {\n name: 'Hired',\n type: 'DATE_ONLY'\n },\n mode: 'predefined',\n label: 'Hired',\n predefinedConditions: [\n {\n id: 'hired1',\n value: {\n lhs: {\n field: 'Hired'\n },\n comparator: 'LT',\n rhs: {\n value: '2022-01-01'\n }\n },\n label: 'Before 2022'\n },\n {\n id: 'hired2',\n value: {\n lhs: {\n field: 'Hired'\n },\n comparator: 'GT',\n rhs: {\n value: '2022-01-01'\n }\n },\n label: 'After 2022'\n },\n {\n id: 'hired3',\n value: {\n lhs: {\n field: 'Hired'\n },\n comparator: 'BTW',\n rhs: {\n start: '2023-01-03',\n end: '2023-31-03'\n }\n },\n label: 'In March 2023'\n }\n ]\n },\n {\n field: { name: 'Salary', type: 'INTEGER' },\n mode: 'advanced',\n label: 'Salary'\n },\n {\n field: { name: 'HireDate', type: 'DATE_ONLY' },\n mode: 'default',\n label: 'Hire date'\n },\n {\n field: { name: 'LastPromotion', type: 'DATE_ONLY' },\n mode: 'advanced',\n label: 'Date of last promotion'\n },\n {\n field: { name: 'DailyMeetingTime', type: 'TIME_ONLY' },\n mode: 'default',\n label: 'Time of daily meeting'\n },\n {\n field: { name: 'StartOfWorkingHours', type: 'TIME_ONLY' },\n mode: 'advanced',\n label: 'Start of working hours'\n },\n {\n field: { name: 'NextReviewDate', type: 'DATE_TIME' },\n mode: 'default',\n label: 'Next scheduled review'\n },\n {\n field: { name: 'LastOfficeCheckIn', type: 'DATE_TIME' },\n mode: 'advanced',\n label: 'Last check-in in the office'\n },\n {\n field: { name: 'RemoteEmployee', type: 'BOOLEAN' },\n mode: 'default',\n label: 'Remote employee'\n },\n {\n field: {\n name: 'Department',\n type: 'PICKLIST',\n possibleValues: [\n 'Customer Service',\n 'Engineering',\n 'Facilities',\n 'Finance',\n 'HR',\n 'IT',\n 'Sales'\n ]\n },\n mode: 'default'\n },\n {\n field: {\n name: 'Status',\n type: 'PICKLIST',\n possibleValues: () =>\n Promise.resolve([\n { id: 'new', primary: 'New' },\n { id: 'open', primary: 'Open' },\n { id: 'resolved', primary: 'Resolved' }\n ])\n },\n mode: 'advanced'\n }\n];\n"]}
1
+ {"version":3,"file":"PromotedFilters.mocks.js","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.mocks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AASvE,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,KAAK,EAAE,mCAAmC;IAC1C,SAAS,EAAE,eAAe;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAS,IAAI,CAAC;AAEpC,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,GAAG,EAAE;QACH;YACE,SAAS,EAAE;gBACT,GAAG,EAAE;oBACH,KAAK,EAAE,WAAW;iBACnB;gBACD,UAAU,EAAE,IAAI;gBAChB,GAAG,EAAE;oBACH,KAAK,EAAE,MAAM;iBACd;aACF;SACF;QACD;YACE,SAAS,EAAE;gBACT,GAAG,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;gBAChC,UAAU,EAAE,SAAS;aACtB;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAoC;IAC1D,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE;IACpF,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE;IACnF;QACE,KAAK,EAAE;YACL,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,MAAM;YACZ,cAAc,EAAE;gBACd,mBAAmB;gBACnB,qBAAqB;gBACrB,aAAa;gBAC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,EAAE,UAAU;KACjB;CACF,CAAC","sourcesContent":["import type { Meta } from '@storybook/react';\n\nimport { PromotedFilters } from '@pega/cosmos-react-condition-builder';\nimport type { Condition, PromotedFiltersProps } from '@pega/cosmos-react-condition-builder';\n\nexport interface PromotedFiltersStoryProps {\n orientation?: 'vertical' | 'horizontal';\n timeZone?: string;\n showTransformedOutput?: boolean;\n}\n\nexport const meta: Meta = {\n title: 'Condition Builder/PromotedFilters',\n component: PromotedFilters\n};\n\nexport const storyMeta: Meta = meta;\n\nexport const demoCondition: Condition = {\n AND: [\n {\n condition: {\n lhs: {\n field: 'FirstName'\n },\n comparator: 'EQ',\n rhs: {\n value: 'John'\n }\n }\n },\n {\n condition: {\n lhs: { field: 'RemoteEmployee' },\n comparator: 'IS_TRUE'\n }\n }\n ]\n};\n\nexport const demoFilters: PromotedFiltersProps['filters'] = [\n { field: { name: 'FirstName', type: 'TEXT' }, mode: 'default', label: 'First name' },\n { field: { name: 'LastName', type: 'TEXT' }, mode: 'advanced', label: 'Last name' },\n {\n field: {\n name: 'JobDescription',\n type: 'TEXT',\n possibleValues: [\n 'Software Engineer',\n 'Front End Developer',\n 'QA Engineer',\n 'Manager',\n 'Product Manager',\n 'Product Owner'\n ]\n },\n mode: 'advanced',\n label: 'Job description'\n },\n {\n field: { name: 'Experience', type: 'INTEGER' },\n mode: 'default',\n label: 'Years of experience'\n },\n {\n field: {\n name: 'Score',\n type: 'INTEGER'\n },\n mode: 'predefined',\n label: 'Score',\n predefinedConditions: [\n {\n id: 'score1',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'GT',\n rhs: {\n value: 0\n }\n }\n },\n {\n id: 'score2',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'EQ',\n rhs: {\n value: 0\n }\n }\n },\n {\n id: 'score3',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'LT',\n rhs: {\n value: 0\n }\n }\n },\n {\n id: 'score4',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'BTW',\n rhs: {\n start: 0,\n end: 10\n }\n }\n },\n {\n id: 'score5',\n value: {\n lhs: {\n field: 'Score'\n },\n comparator: 'IS_NULL'\n }\n }\n ]\n },\n {\n field: {\n name: 'Hired',\n type: 'DATE_ONLY'\n },\n mode: 'predefined',\n label: 'Hired',\n predefinedConditions: [\n {\n id: 'hired1',\n value: {\n lhs: {\n field: 'Hired'\n },\n comparator: 'LT',\n rhs: {\n value: '2022-01-01'\n }\n },\n label: 'Before 2022'\n },\n {\n id: 'hired2',\n value: {\n lhs: {\n field: 'Hired'\n },\n comparator: 'GT',\n rhs: {\n value: '2022-01-01'\n }\n },\n label: 'After 2022'\n },\n {\n id: 'hired3',\n value: {\n lhs: {\n field: 'Hired'\n },\n comparator: 'BTW',\n rhs: {\n start: '2023-01-03',\n end: '2023-31-03'\n }\n },\n label: 'In March 2023'\n }\n ]\n },\n {\n field: { name: 'Salary', type: 'INTEGER' },\n mode: 'advanced',\n label: 'Salary'\n },\n {\n field: { name: 'HireDate', type: 'DATE_ONLY' },\n mode: 'default',\n label: 'Hire date'\n },\n {\n field: { name: 'LastPromotion', type: 'DATE_ONLY' },\n mode: 'advanced',\n label: 'Date of last promotion'\n },\n {\n field: { name: 'DailyMeetingTime', type: 'TIME_ONLY' },\n mode: 'default',\n label: 'Time of daily meeting'\n },\n {\n field: { name: 'StartOfWorkingHours', type: 'TIME_ONLY' },\n mode: 'advanced',\n label: 'Start of working hours'\n },\n {\n field: { name: 'NextReviewDate', type: 'DATE_TIME' },\n mode: 'default',\n label: 'Next scheduled review'\n },\n {\n field: { name: 'LastOfficeCheckIn', type: 'DATE_TIME' },\n mode: 'advanced',\n label: 'Last check-in in the office'\n },\n {\n field: { name: 'RemoteEmployee', type: 'BOOLEAN' },\n mode: 'default',\n label: 'Remote employee'\n },\n {\n field: {\n name: 'Department',\n type: 'PICKLIST',\n possibleValues: [\n 'Customer Service',\n 'Engineering',\n 'Facilities',\n 'Finance',\n 'HR',\n 'IT',\n 'Sales'\n ]\n },\n mode: 'default'\n },\n {\n field: {\n name: 'Status',\n type: 'PICKLIST',\n possibleValues: () =>\n Promise.resolve([\n { id: 'new', primary: 'New' },\n { id: 'open', primary: 'Open' },\n { id: 'resolved', primary: 'Resolved' }\n ])\n },\n mode: 'advanced'\n }\n];\n"]}
@@ -1,8 +1,6 @@
1
1
  import type { StoryFn } from '@storybook/react';
2
+ import type { PromotedFiltersStoryProps } from './PromotedFilters.mocks';
2
3
  declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react/dist/types-a5624094").ReactRenderer, import("@storybook/csf").Args>;
3
4
  export default _default;
4
- interface PromotedFiltersStoryProps {
5
- orientation?: 'vertical' | 'horizontal';
6
- }
7
5
  export declare const PromotedFiltersDemo: StoryFn<PromotedFiltersStoryProps>;
8
6
  //# sourceMappingURL=PromotedFilters.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromotedFilters.stories.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;;AAUtD,wBAGU;AAEV,UAAU,yBAAyB;IACjC,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CACzC;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,yBAAyB,CAqBlE,CAAC"}
1
+ {"version":3,"file":"PromotedFilters.stories.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;;AASzE,wBAGU;AAEV,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,yBAAyB,CAgDlE,CAAC"}
@@ -1,24 +1,37 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { PromotedFilters } from '@pega/cosmos-react-condition-builder';
4
- import { Flex, Text } from '@pega/cosmos-react-core';
4
+ import { Flex } from '@pega/cosmos-react-core';
5
5
  import { demoCondition, demoFilters } from './PromotedFilters.mocks';
6
- import { StyledCodeBlock } from './PromotedFilters.styles';
6
+ import { StyledCodeBlock, StyledComparisonCell, StyledComparisonHeader } from './PromotedFilters.styles';
7
+ import { storyFields, transformSingleChild } from './PromotedFilters.helpers';
8
+ // Storybook's CSF indexer needs a literal default export here.
7
9
  export default {
8
10
  title: 'Condition Builder/PromotedFilters',
9
11
  component: PromotedFilters
10
12
  };
11
13
  export const PromotedFiltersDemo = (args) => {
12
14
  const [condition, setCondition] = useState(demoCondition);
13
- return (_jsxs(Flex, { container: { direction: 'column' }, children: [_jsx(PromotedFilters, { filters: demoFilters, condition: condition, onChange: setCondition, orientation: args.orientation }), _jsxs("div", { children: [_jsx(Text, { variant: 'h4', children: "Output:" }), _jsx(StyledCodeBlock, { children: condition ? JSON.stringify(condition, null, 2) : '(No condition)' })] })] }));
15
+ const tz = args.timeZone || undefined;
16
+ const leafChildren = condition && 'AND' in condition
17
+ ? condition.AND.filter((c) => 'condition' in c)
18
+ : [];
19
+ return (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [_jsx(PromotedFilters, { filters: demoFilters, condition: condition, onChange: setCondition, orientation: args.orientation, fields: storyFields, timeZone: tz }), args.showTransformedOutput ? (_jsxs(Flex, { container: { direction: 'column' }, children: [_jsxs(Flex, { container: { direction: 'row' }, children: [_jsx(StyledComparisonHeader, { children: "Output" }), _jsx(StyledComparisonHeader, { children: "Transformed" })] }), leafChildren.map(child => (_jsxs(Flex, { container: { direction: 'row' }, children: [_jsx(StyledComparisonCell, { children: JSON.stringify(child, null, 2) }), _jsx(StyledComparisonCell, { children: JSON.stringify(transformSingleChild(child, storyFields), null, 2) })] }, `${child.condition.lhs.field}-${child.condition.comparator}`)))] })) : (_jsx(StyledCodeBlock, { children: condition ? JSON.stringify(condition, null, 2) : '(No condition)' }))] }));
14
20
  };
15
21
  PromotedFiltersDemo.args = {
16
- orientation: 'horizontal'
22
+ orientation: 'horizontal',
23
+ timeZone: 'America/New_York',
24
+ showTransformedOutput: false
17
25
  };
18
26
  PromotedFiltersDemo.argTypes = {
19
- orientation: {
20
- options: ['horizontal', 'vertical'],
21
- control: { type: 'select' }
27
+ orientation: { options: ['horizontal', 'vertical'], control: { type: 'select' } },
28
+ timeZone: {
29
+ description: 'IANA timezone (e.g. "America/New_York"). Blank uses browser timezone.',
30
+ control: { type: 'text' }
31
+ },
32
+ showTransformedOutput: {
33
+ description: 'Show raw vs transformed output side-by-side.',
34
+ control: { type: 'boolean' }
22
35
  }
23
36
  };
24
37
  //# sourceMappingURL=PromotedFilters.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromotedFilters.stories.js","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,eAAe;IACb,KAAK,EAAE,mCAAmC;IAC1C,SAAS,EAAE,eAAe;CACnB,CAAC;AAMV,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CACrE,IAA+B,EAC/B,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAwB,aAAa,CAAC,CAAC;IAEjF,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,aACtC,KAAC,eAAe,IACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,IAAI,CAAC,WAAW,GAC7B,EACF,0BACE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,wBAAe,EACjC,KAAC,eAAe,cACb,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,GAClD,IACd,IACD,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,mBAAmB,CAAC,IAAI,GAAG;IACzB,WAAW,EAAE,YAAY;CAC1B,CAAC;AAEF,mBAAmB,CAAC,QAAQ,GAAG;IAC7B,WAAW,EAAE;QACX,OAAO,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;QACnC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC5B;CACF,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState } from 'react';\n\nimport { PromotedFilters } from '@pega/cosmos-react-condition-builder';\nimport type { Condition } from '@pega/cosmos-react-condition-builder';\nimport { Flex, Text } from '@pega/cosmos-react-core';\n\nimport { demoCondition, demoFilters } from './PromotedFilters.mocks';\nimport { StyledCodeBlock } from './PromotedFilters.styles';\n\nexport default {\n title: 'Condition Builder/PromotedFilters',\n component: PromotedFilters\n} as Meta;\n\ninterface PromotedFiltersStoryProps {\n orientation?: 'vertical' | 'horizontal';\n}\n\nexport const PromotedFiltersDemo: StoryFn<PromotedFiltersStoryProps> = (\n args: PromotedFiltersStoryProps\n) => {\n const [condition, setCondition] = useState<Condition | undefined>(demoCondition);\n\n return (\n <Flex container={{ direction: 'column' }}>\n <PromotedFilters\n filters={demoFilters}\n condition={condition}\n onChange={setCondition}\n orientation={args.orientation}\n />\n <div>\n <Text variant='h4'>Output:</Text>\n <StyledCodeBlock>\n {condition ? JSON.stringify(condition, null, 2) : '(No condition)'}\n </StyledCodeBlock>\n </div>\n </Flex>\n );\n};\n\nPromotedFiltersDemo.args = {\n orientation: 'horizontal'\n};\n\nPromotedFiltersDemo.argTypes = {\n orientation: {\n options: ['horizontal', 'vertical'],\n control: { type: 'select' }\n }\n};\n"]}
1
+ {"version":3,"file":"PromotedFilters.stories.js","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE9E,+DAA+D;AAC/D,eAAe;IACb,KAAK,EAAE,mCAAmC;IAC1C,SAAS,EAAE,eAAe;CACnB,CAAC;AAEV,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CACrE,IAA+B,EAC/B,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CACxC,aAAa,CACd,CAAC;IACF,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,IAAI,SAAS,CAAC;IACtC,MAAM,YAAY,GAChB,SAAS,IAAI,KAAK,IAAI,SAAS;QAC7B,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAqC,EAAE,CAAC,WAAW,IAAI,CAAC,CAAC;QAClF,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC9C,KAAC,eAAe,IACd,OA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,EAAE,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IACjF,QAAQ,EAAE;QACR,WAAW,EAAE,uEAAuE;QACpF,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;KAC1B;IACD,qBAAqB,EAAE;QACrB,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC7B;CACF,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState } from 'react';\n\nimport { PromotedFilters } from '@pega/cosmos-react-condition-builder';\nimport type { PromotedFiltersProps, LeafCondition } from '@pega/cosmos-react-condition-builder';\nimport { Flex } from '@pega/cosmos-react-core';\n\nimport { demoCondition, demoFilters } from './PromotedFilters.mocks';\nimport type { PromotedFiltersStoryProps } from './PromotedFilters.mocks';\nimport {\n StyledCodeBlock,\n StyledComparisonCell,\n StyledComparisonHeader\n} from './PromotedFilters.styles';\nimport { storyFields, transformSingleChild } from './PromotedFilters.helpers';\n\n// Storybook's CSF indexer needs a literal default export here.\nexport default {\n title: 'Condition Builder/PromotedFilters',\n component: PromotedFilters\n} as Meta;\n\nexport const PromotedFiltersDemo: StoryFn<PromotedFiltersStoryProps> = (\n args: PromotedFiltersStoryProps\n) => {\n const [condition, setCondition] = useState<PromotedFiltersProps['condition'] | undefined>(\n demoCondition\n );\n const tz = args.timeZone || undefined;\n const leafChildren =\n condition && 'AND' in condition\n ? condition.AND.filter((c): c is { condition: LeafCondition } => 'condition' in c)\n : [];\n\n return (\n <Flex container={{ direction: 'column', gap: 1 }}>\n <PromotedFilters\n filters={demoFilters}\n condition={condition}\n onChange={setCondition}\n orientation={args.orientation}\n fields={storyFields}\n timeZone={tz}\n />\n\n {args.showTransformedOutput ? (\n <Flex container={{ direction: 'column' }}>\n <Flex container={{ direction: 'row' }}>\n <StyledComparisonHeader>Output</StyledComparisonHeader>\n <StyledComparisonHeader>Transformed</StyledComparisonHeader>\n </Flex>\n {leafChildren.map(child => (\n <Flex\n key={`${child.condition.lhs.field}-${child.condition.comparator}`}\n container={{ direction: 'row' }}\n >\n <StyledComparisonCell>{JSON.stringify(child, null, 2)}</StyledComparisonCell>\n <StyledComparisonCell>\n {JSON.stringify(transformSingleChild(child, storyFields), null, 2)}\n </StyledComparisonCell>\n </Flex>\n ))}\n </Flex>\n ) : (\n <StyledCodeBlock>\n {condition ? JSON.stringify(condition, null, 2) : '(No condition)'}\n </StyledCodeBlock>\n )}\n </Flex>\n );\n};\n\nPromotedFiltersDemo.args = {\n orientation: 'horizontal',\n timeZone: 'America/New_York',\n showTransformedOutput: false\n};\n\nPromotedFiltersDemo.argTypes = {\n orientation: { options: ['horizontal', 'vertical'], control: { type: 'select' } },\n timeZone: {\n description: 'IANA timezone (e.g. \"America/New_York\"). Blank uses browser timezone.',\n control: { type: 'text' }\n },\n showTransformedOutput: {\n description: 'Show raw vs transformed output side-by-side.',\n control: { type: 'boolean' }\n }\n};\n"]}
@@ -1,5 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export declare const StyledCodeBlock: import("styled-components").StyledComponent<"pre", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const StyledComparisonCell: import("styled-components").StyledComponent<"pre", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const StyledComparisonHeader: import("styled-components").StyledComponent<"pre", import("styled-components").DefaultTheme, {}, never>;
3
5
  export declare const StyledPromotedFilters: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
4
6
  isVertical: boolean;
5
7
  }, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,eAAe,yGAG3B,CAAC;AAIF,eAAO,MAAM,qBAAqB;gBACpB,OAAO;SAYnB,CAAC;AAIH,eAAO,MAAM,oBAAoB,qOAGhC,CAAC;AAIF,eAAO,MAAM,qBAAqB,yGAEjC,CAAC;AAIF,eAAO,MAAM,sBAAsB,mOAIlC,CAAC"}
1
+ {"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,eAAe,yGAG3B,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAShC,CAAC;AAIF,eAAO,MAAM,sBAAsB,yGAGlC,CAAC;AAIF,eAAO,MAAM,qBAAqB;gBACpB,OAAO;SAYnB,CAAC;AAIH,eAAO,MAAM,oBAAoB,qOAGhC,CAAC;AAIF,eAAO,MAAM,qBAAqB,yGAEjC,CAAC;AAIF,eAAO,MAAM,sBAAsB,mOAIlC,CAAC"}
@@ -5,6 +5,22 @@ export const StyledCodeBlock = styled.pre `
5
5
  margin-bottom: ${props => props.theme.base.spacing};
6
6
  `;
7
7
  StyledCodeBlock.defaultProps = defaultThemeProp;
8
+ export const StyledComparisonCell = styled.pre `
9
+ flex: 1;
10
+ margin: 0;
11
+ padding: ${({ theme }) => `calc(${theme.base.spacing} * 0.5) ${theme.base.spacing}`};
12
+ font-size: ${({ theme }) => theme.base['font-size']};
13
+ line-height: ${({ theme }) => theme.base['line-height']};
14
+ white-space: pre-wrap;
15
+ word-break: break-word;
16
+ border-bottom: 0.0625rem solid ${({ theme }) => theme.base.palette['border-line']};
17
+ `;
18
+ StyledComparisonCell.defaultProps = defaultThemeProp;
19
+ export const StyledComparisonHeader = styled(StyledComparisonCell) `
20
+ font-weight: ${({ theme }) => theme.base['font-weight'].bold};
21
+ background-color: ${({ theme }) => theme.base.palette['secondary-background']};
22
+ `;
23
+ StyledComparisonHeader.defaultProps = defaultThemeProp;
8
24
  export const StyledPromotedFilters = styled.div(props => {
9
25
  const { theme, isVertical } = props;
10
26
  return css `
@@ -1 +1 @@
1
- {"version":3,"file":"PromotedFilters.styles.js","sourceRoot":"","sources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GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { Button, defaultThemeProp, Text } from '@pega/cosmos-react-core';\n\nexport const StyledCodeBlock = styled.pre`\n padding: ${props => props.theme.base.spacing};\n margin-bottom: ${props => props.theme.base.spacing};\n`;\n\nStyledCodeBlock.defaultProps = defaultThemeProp;\n\nexport const StyledPromotedFilters = styled.div<{\n isVertical: boolean;\n}>(props => {\n const { theme, isVertical } = props;\n\n return css`\n border-radius: ${theme.components.card['border-radius']};\n background-color: ${theme.base.palette['secondary-background']};\n ${isVertical &&\n css`\n max-width: 20rem;\n `}\n `;\n});\n\nStyledPromotedFilters.defaultProps = defaultThemeProp;\n\nexport const StyledClearAllButton = styled(Button)`\n margin-top: 0.625rem;\n white-space: nowrap;\n`;\n\nStyledClearAllButton.defaultProps = defaultThemeProp;\n\nexport const StyledVerticalWrapper = styled.div`\n width: 100%;\n`;\n\nStyledVerticalWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledTextWithEllipsis = styled(Text)`\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nStyledTextWithEllipsis.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"PromotedFilters.styles.js","sourceRoot":"","sources":["../../../src/condition-builder/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;aAC5B,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;mBAC3B,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;CACnD,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG,gBAAgB,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YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;CAGjD,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE9C,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;CAIjD,CAAC;AAEF,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { Button, defaultThemeProp, Text } from '@pega/cosmos-react-core';\n\nexport const StyledCodeBlock = styled.pre`\n padding: ${props => props.theme.base.spacing};\n margin-bottom: ${props => props.theme.base.spacing};\n`;\n\nStyledCodeBlock.defaultProps = defaultThemeProp;\n\nexport const StyledComparisonCell = styled.pre`\n flex: 1;\n margin: 0;\n padding: ${({ theme }) => `calc(${theme.base.spacing} * 0.5) ${theme.base.spacing}`};\n font-size: ${({ theme }) => theme.base['font-size']};\n line-height: ${({ theme }) => theme.base['line-height']};\n white-space: pre-wrap;\n word-break: break-word;\n border-bottom: 0.0625rem solid ${({ theme }) => theme.base.palette['border-line']};\n`;\n\nStyledComparisonCell.defaultProps = defaultThemeProp;\n\nexport const StyledComparisonHeader = styled(StyledComparisonCell)`\n font-weight: ${({ theme }) => theme.base['font-weight'].bold};\n background-color: ${({ theme }) => theme.base.palette['secondary-background']};\n`;\n\nStyledComparisonHeader.defaultProps = defaultThemeProp;\n\nexport const StyledPromotedFilters = styled.div<{\n isVertical: boolean;\n}>(props => {\n const { theme, isVertical } = props;\n\n return css`\n border-radius: ${theme.components.card['border-radius']};\n background-color: ${theme.base.palette['secondary-background']};\n ${isVertical &&\n css`\n max-width: 20rem;\n `}\n `;\n});\n\nStyledPromotedFilters.defaultProps = defaultThemeProp;\n\nexport const StyledClearAllButton = styled(Button)`\n margin-top: 0.625rem;\n white-space: nowrap;\n`;\n\nStyledClearAllButton.defaultProps = defaultThemeProp;\n\nexport const StyledVerticalWrapper = styled.div`\n width: 100%;\n`;\n\nStyledVerticalWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledTextWithEllipsis = styled(Text)`\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nStyledTextWithEllipsis.defaultProps = defaultThemeProp;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-demos",
3
- "version": "7.16.5",
3
+ "version": "7.17.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pegasystems/cosmos-react.git",
@@ -20,12 +20,12 @@
20
20
  "build": "tsc -b tsconfig.build.json && tsc -b tsconfig.build-preserve.json"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-condition-builder": "7.16.5",
24
- "@pega/cosmos-react-core": "7.16.5",
25
- "@pega/cosmos-react-dnd": "7.16.5",
26
- "@pega/cosmos-react-rte": "7.16.5",
27
- "@pega/cosmos-react-social": "7.16.5",
28
- "@pega/cosmos-react-work": "7.16.5",
23
+ "@pega/cosmos-react-condition-builder": "7.17.0",
24
+ "@pega/cosmos-react-core": "7.17.0",
25
+ "@pega/cosmos-react-dnd": "7.17.0",
26
+ "@pega/cosmos-react-rte": "7.17.0",
27
+ "@pega/cosmos-react-social": "7.17.0",
28
+ "@pega/cosmos-react-work": "7.17.0",
29
29
  "@storybook/addon-actions": "~8.2.9",
30
30
  "@storybook/react": "~8.2.9",
31
31
  "@types/dompurify": "^3.0.5",