@pega/cosmos-react-core 3.0.0-dev.13.0 → 3.0.0-dev.14.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.
Files changed (44) hide show
  1. package/lib/components/Banner/Banner.d.ts.map +1 -1
  2. package/lib/components/Banner/Banner.js +6 -2
  3. package/lib/components/Banner/Banner.js.map +1 -1
  4. package/lib/components/Configuration/Configuration.d.ts +14 -13
  5. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  6. package/lib/components/Configuration/Configuration.js +24 -14
  7. package/lib/components/Configuration/Configuration.js.map +1 -1
  8. package/lib/components/FormField/FormField.d.ts.map +1 -1
  9. package/lib/components/FormField/FormField.js +6 -2
  10. package/lib/components/FormField/FormField.js.map +1 -1
  11. package/lib/components/Link/Link.d.ts.map +1 -1
  12. package/lib/components/Link/Link.js +1 -2
  13. package/lib/components/Link/Link.js.map +1 -1
  14. package/lib/components/List/CommaSeparatedList.d.ts.map +1 -1
  15. package/lib/components/List/CommaSeparatedList.js +6 -14
  16. package/lib/components/List/CommaSeparatedList.js.map +1 -1
  17. package/lib/components/Modal/Contexts.d.ts.map +1 -1
  18. package/lib/components/Modal/Contexts.js +2 -3
  19. package/lib/components/Modal/Contexts.js.map +1 -1
  20. package/lib/components/Modal/Modal.types.d.ts +2 -6
  21. package/lib/components/Modal/Modal.types.d.ts.map +1 -1
  22. package/lib/components/Modal/Modal.types.js +1 -2
  23. package/lib/components/Modal/Modal.types.js.map +1 -1
  24. package/lib/components/Modal/ModalManager.d.ts +8 -2
  25. package/lib/components/Modal/ModalManager.d.ts.map +1 -1
  26. package/lib/components/Modal/ModalManager.js +10 -7
  27. package/lib/components/Modal/ModalManager.js.map +1 -1
  28. package/lib/components/Toaster/Toaster.d.ts +7 -2
  29. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  30. package/lib/components/Toaster/Toaster.js +7 -7
  31. package/lib/components/Toaster/Toaster.js.map +1 -1
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/index.js +1 -0
  35. package/lib/index.js.map +1 -1
  36. package/lib/init.d.ts +8 -0
  37. package/lib/init.d.ts.map +1 -0
  38. package/lib/init.js +5 -0
  39. package/lib/init.js.map +1 -0
  40. package/lib/theme/ThemeMachine.d.ts +11 -3
  41. package/lib/theme/ThemeMachine.d.ts.map +1 -1
  42. package/lib/theme/ThemeMachine.js +28 -26
  43. package/lib/theme/ThemeMachine.js.map +1 -1
  44. package/package.json +5 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeMachine.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,SAAS,CAAC,KAAK;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,oBAAY,eAAe,GAAG;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;CACrD,CAAC;AAEF,oBAAY,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,IAAI,IAAI,SAAS,SAAS,CAAC,MAAM,OAAO,CAAC,GACrF,CAAC,OAAO,SAAS,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,GAC/D,IAAI,SAAS,MAAM,GACnB;IACE,QAAQ,EAAE,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,UAAU,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;CACtF,GACD,IAAI,GAAG,SAAS,CAAC;AAErB,oBAAY,aAAa,CAAC,GAAG,SAAS,eAAe,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,EAA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M,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrC,UAAU,CAAC,EAAE,KAAK,CAAC;KACpB,GACD;QAAE,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE;CAMlF;AAED,eAAe,YAAY,CAAC"}
@@ -1,31 +1,34 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _ThemeMachine_parent, _ThemeMachine_definition, _ThemeMachine_overrides;
13
1
  import { deepGet, defineSmartGetter } from '../utils';
14
2
  export const resetToInitial = Symbol.for('@pega/cosmos-react-core.theme.resetToInitial');
15
3
  class ThemeMachine {
16
4
  constructor({ theme = {}, parent, definition }) {
17
- _ThemeMachine_parent.set(this, void 0);
18
- _ThemeMachine_definition.set(this, void 0);
19
- _ThemeMachine_overrides.set(this, void 0);
5
+ Object.defineProperty(this, "parent", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: void 0
10
+ });
11
+ Object.defineProperty(this, "definition", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ Object.defineProperty(this, "overrides", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
20
23
  Object.defineProperty(this, "theme", {
21
24
  enumerable: true,
22
25
  configurable: true,
23
26
  writable: true,
24
27
  value: void 0
25
28
  });
26
- __classPrivateFieldSet(this, _ThemeMachine_parent, parent ?? null, "f");
27
- __classPrivateFieldSet(this, _ThemeMachine_definition, parent ? __classPrivateFieldGet(parent, _ThemeMachine_definition, "f") : definition, "f");
28
- __classPrivateFieldSet(this, _ThemeMachine_overrides, new Map(), "f");
29
+ this.parent = parent ?? null;
30
+ this.definition = parent ? parent.definition : definition;
31
+ this.overrides = new Map();
29
32
  this.theme = this.constructTheme(theme);
30
33
  }
31
34
  overrideInTree(keys) {
@@ -34,21 +37,21 @@ class ThemeMachine {
34
37
  while (ancestor) {
35
38
  // Trigger getters in the ancestor themes.
36
39
  deepGet(ancestor.theme, keys);
37
- if (__classPrivateFieldGet(ancestor, _ThemeMachine_overrides, "f").has(fullProp))
38
- return !!__classPrivateFieldGet(ancestor, _ThemeMachine_overrides, "f").get(fullProp);
39
- ancestor = __classPrivateFieldGet(ancestor, _ThemeMachine_parent, "f");
40
+ if (ancestor.overrides.has(fullProp))
41
+ return !!ancestor.overrides.get(fullProp);
42
+ ancestor = ancestor.parent;
40
43
  }
41
44
  return false;
42
45
  }
43
46
  constructTheme(theme) {
44
47
  const constructForNode = (keys = []) => {
45
48
  const themeNode = {};
46
- Object.keys(deepGet(__classPrivateFieldGet(this, _ThemeMachine_definition, "f"), keys)).forEach(key => {
49
+ Object.keys(deepGet(this.definition, keys)).forEach(key => {
47
50
  // Ignore comment nodes.
48
51
  if (key === '$comment')
49
52
  return;
50
53
  const propKeys = [...keys, key];
51
- const defNode = deepGet(__classPrivateFieldGet(this, _ThemeMachine_definition, "f"), propKeys);
54
+ const defNode = deepGet(this.definition, propKeys);
52
55
  // If it is not a leaf node of the theme definition...
53
56
  if (defNode.$type === undefined) {
54
57
  // recursively run for child nodes.
@@ -59,7 +62,7 @@ class ThemeMachine {
59
62
  // If a theme value was set for this ThemeMachine...
60
63
  if (themeValue !== undefined) {
61
64
  // set overrides to true, unless it is being reset.
62
- __classPrivateFieldGet(this, _ThemeMachine_overrides, "f").set(propKeys.join('.'), themeValue !== resetToInitial);
65
+ this.overrides.set(propKeys.join('.'), themeValue !== resetToInitial);
63
66
  }
64
67
  // If a theme value was set for this ThemeMachine, is not being reset, and is for a non-constant property...
65
68
  if (themeValue !== undefined && themeValue !== resetToInitial && !defNode.$constant) {
@@ -69,7 +72,7 @@ class ThemeMachine {
69
72
  // If the property has been overridden in the tree (and not reset)...
70
73
  else if (this.overrideInTree(propKeys)) {
71
74
  // set to the value in the parent theme.
72
- defineSmartGetter(themeNode, key, () => deepGet(__classPrivateFieldGet(this, _ThemeMachine_parent, "f").theme, propKeys));
75
+ defineSmartGetter(themeNode, key, () => deepGet(this.parent.theme, propKeys));
73
76
  }
74
77
  // If the property type is inherited...
75
78
  else if (defNode.$type === 'inherited') {
@@ -87,6 +90,5 @@ class ThemeMachine {
87
90
  return constructForNode();
88
91
  }
89
92
  }
90
- _ThemeMachine_parent = new WeakMap(), _ThemeMachine_definition = new WeakMap(), _ThemeMachine_overrides = new WeakMap();
91
93
  export default ThemeMachine;
92
94
  //# sourceMappingURL=ThemeMachine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeMachine.js","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAwBtD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAEzF,MAAM,YAAY;IAiFhB,YAAY,EACV,KAAK,GAAG,EAA+B,EACvC,MAAM,EACN,UAAU,EAGqE;QAtFjF,uCAAyC;QAEzC,2CAAwB;QAExB,0CAAiC;QAEjC;;;;;WA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A6C;oBAC7C,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;iBACjC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO,gBAAgB,EAA8B,CAAC;IACxD,CAAC;CAcF;;AAED,eAAe,YAAY,CAAC","sourcesContent":["import { deepGet, defineSmartGetter } from '../utils';\nimport { DeepPartial } from '../types';\n\nexport interface ThemeLeaf<Value> {\n $type: string;\n $value: Value;\n $constant?: boolean;\n $comment?: string;\n}\n\nexport type ThemeDefinition = {\n [key: string]: ThemeLeaf<unknown> | ThemeDefinition;\n};\n\nexport type ToThemeIFace<Node, Extension = never> = Node extends ThemeLeaf<infer LeafVal>\n ? (LeafVal extends null ? LeafVal | string : LeafVal) | Extension\n : Node extends object\n ? {\n readonly [Key in Exclude<keyof Node, '$comment'>]: ToThemeIFace<Node[Key], Extension>;\n }\n : Node | Extension;\n\nexport type SettableTheme<Def extends ThemeDefinition> = DeepPartial<ToThemeIFace<Def, symbol>>;\n\nexport const resetToInitial = Symbol.for('@pega/cosmos-react-core.theme.resetToInitial');\n\nclass ThemeMachine<Definition extends ThemeDefinition> {\n #parent: ThemeMachine<Definition> | null;\n\n #definition: Definition;\n\n #overrides: Map<string, boolean>;\n\n readonly theme: ToThemeIFace<Definition>;\n\n overrideInTree(keys: string[]): boolean {\n let ancestor: ThemeMachine<Definition> | null = this;\n const fullProp = keys.join('.');\n\n while (ancestor) {\n // Trigger getters in the ancestor themes.\n deepGet(ancestor.theme, keys);\n\n if (ancestor.#overrides.has(fullProp)) return !!ancestor.#overrides.get(fullProp);\n ancestor = ancestor.#parent;\n }\n\n return false;\n }\n\n constructTheme(theme: SettableTheme<Definition>): ToThemeIFace<Definition> {\n const constructForNode = (keys: string[] = []) => {\n const themeNode: Record<string, any> = {};\n\n Object.keys(deepGet(this.#definition, keys)).forEach(key => {\n // Ignore comment nodes.\n if (key === '$comment') return;\n\n const propKeys = [...keys, key];\n const defNode: Record<string, any> = deepGet(this.#definition, propKeys);\n\n // If it is not a leaf node of the theme definition...\n if (defNode.$type === undefined) {\n // recursively run for child nodes.\n defineSmartGetter(themeNode, key, () => constructForNode(propKeys));\n return;\n }\n\n const themeValue = deepGet(theme, propKeys);\n\n // If a theme value was set for this ThemeMachine...\n if (themeValue !== undefined) {\n // set overrides to true, unless it is being reset.\n this.#overrides.set(propKeys.join('.'), themeValue !== resetToInitial);\n }\n\n // If a theme value was set for this ThemeMachine, is not being reset, and is for a non-constant property...\n if (themeValue !== undefined && themeValue !== resetToInitial && !defNode.$constant) {\n // set to the provided value.\n themeNode[key] = themeValue;\n }\n\n // If the property has been overridden in the tree (and not reset)...\n else if (this.overrideInTree(propKeys)) {\n // set to the value in the parent theme.\n defineSmartGetter(themeNode, key, () => deepGet(this.#parent!.theme, propKeys));\n }\n\n // If the property type is inherited...\n else if (defNode.$type === 'inherited') {\n // set to the value of the inherited property in this theme.\n defineSmartGetter(themeNode, key, () => deepGet(this.theme, defNode.$value.split('.')));\n }\n\n // If the property type is literal...\n else if (defNode.$type === 'literal') {\n // set to the value listed in the definition.\n themeNode[key] = defNode.$value;\n }\n });\n\n return themeNode;\n };\n\n return constructForNode() as ToThemeIFace<Definition>;\n }\n\n constructor({\n theme = {} as SettableTheme<Definition>,\n parent,\n definition\n }:\n | { theme?: SettableTheme<Definition>; parent: ThemeMachine<Definition>; definition?: never }\n | { theme?: SettableTheme<Definition>; parent?: never; definition: Definition }) {\n this.#parent = parent ?? null;\n this.#definition = parent ? parent.#definition : definition!;\n this.#overrides = new Map();\n this.theme = this.constructTheme(theme);\n }\n}\n\nexport default ThemeMachine;\n"]}
1
+ {"version":3,"file":"ThemeMachine.js","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAwBtD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,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AAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBACzF;gBAED,qCAAqC;qBAChC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE;oBACpC,6CAA6C;oBAC7C,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;iBACjC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO,gBAAgB,EAA8B,CAAC;IACxD,CAAC;CAkBF;AAED,eAAe,YAAY,CAAC","sourcesContent":["import { deepGet, defineSmartGetter } from '../utils';\nimport { DeepPartial } from '../types';\n\nexport interface ThemeLeaf<Value> {\n $type: string;\n $value: Value;\n $constant?: boolean;\n $comment?: string;\n}\n\nexport type ThemeDefinition = {\n [key: string]: ThemeLeaf<unknown> | ThemeDefinition;\n};\n\nexport type ToThemeIFace<Node, Extension = never> = Node extends ThemeLeaf<infer LeafVal>\n ? (LeafVal extends null ? LeafVal | string : LeafVal) | Extension\n : Node extends object\n ? {\n readonly [Key in Exclude<keyof Node, '$comment'>]: ToThemeIFace<Node[Key], Extension>;\n }\n : Node | Extension;\n\nexport type SettableTheme<Def extends ThemeDefinition> = DeepPartial<ToThemeIFace<Def, symbol>>;\n\nexport const resetToInitial = Symbol.for('@pega/cosmos-react-core.theme.resetToInitial');\n\nexport interface ThemeMachineLike<Definition extends ThemeDefinition> {\n parent: ThemeMachineLike<Definition> | null;\n\n definition: Definition;\n\n overrides: Map<string, boolean>;\n\n readonly theme: ToThemeIFace<Definition>;\n}\n\nclass ThemeMachine<Definition extends ThemeDefinition> implements ThemeMachineLike<Definition> {\n parent: ThemeMachineLike<Definition> | null;\n\n definition: Definition;\n\n overrides: Map<string, boolean>;\n\n readonly theme: ToThemeIFace<Definition>;\n\n overrideInTree(keys: string[]): boolean {\n let ancestor: ThemeMachineLike<Definition> | null = this;\n const fullProp = keys.join('.');\n\n while (ancestor) {\n // Trigger getters in the ancestor themes.\n deepGet(ancestor.theme, keys);\n\n if (ancestor.overrides.has(fullProp)) return !!ancestor.overrides.get(fullProp);\n ancestor = ancestor.parent;\n }\n\n return false;\n }\n\n constructTheme(theme: SettableTheme<Definition>): ToThemeIFace<Definition> {\n const constructForNode = (keys: string[] = []) => {\n const themeNode: Record<string, any> = {};\n\n Object.keys(deepGet(this.definition, keys)).forEach(key => {\n // Ignore comment nodes.\n if (key === '$comment') return;\n\n const propKeys = [...keys, key];\n const defNode: Record<string, any> = deepGet(this.definition, propKeys);\n\n // If it is not a leaf node of the theme definition...\n if (defNode.$type === undefined) {\n // recursively run for child nodes.\n defineSmartGetter(themeNode, key, () => constructForNode(propKeys));\n return;\n }\n\n const themeValue = deepGet(theme, propKeys);\n\n // If a theme value was set for this ThemeMachine...\n if (themeValue !== undefined) {\n // set overrides to true, unless it is being reset.\n this.overrides.set(propKeys.join('.'), themeValue !== resetToInitial);\n }\n\n // If a theme value was set for this ThemeMachine, is not being reset, and is for a non-constant property...\n if (themeValue !== undefined && themeValue !== resetToInitial && !defNode.$constant) {\n // set to the provided value.\n themeNode[key] = themeValue;\n }\n\n // If the property has been overridden in the tree (and not reset)...\n else if (this.overrideInTree(propKeys)) {\n // set to the value in the parent theme.\n defineSmartGetter(themeNode, key, () => deepGet(this.parent!.theme, propKeys));\n }\n\n // If the property type is inherited...\n else if (defNode.$type === 'inherited') {\n // set to the value of the inherited property in this theme.\n defineSmartGetter(themeNode, key, () => deepGet(this.theme, defNode.$value.split('.')));\n }\n\n // If the property type is literal...\n else if (defNode.$type === 'literal') {\n // set to the value listed in the definition.\n themeNode[key] = defNode.$value;\n }\n });\n\n return themeNode;\n };\n\n return constructForNode() as ToThemeIFace<Definition>;\n }\n\n constructor({\n theme = {} as SettableTheme<Definition>,\n parent,\n definition\n }:\n | {\n theme?: SettableTheme<Definition>;\n parent: ThemeMachineLike<Definition>;\n definition?: never;\n }\n | { theme?: SettableTheme<Definition>; parent?: never; definition: Definition }) {\n this.parent = parent ?? null;\n this.definition = parent ? parent.definition : definition;\n this.overrides = new Map();\n this.theme = this.constructTheme(theme);\n }\n}\n\nexport default ThemeMachine;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "3.0.0-dev.13.0",
3
+ "version": "3.0.0-dev.14.0",
4
4
  "description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
5
5
  "author": "Pegasystems",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -15,7 +15,10 @@
15
15
  "LICENSE",
16
16
  "lib"
17
17
  ],
18
- "sideEffects": false,
18
+ "sideEffects": [
19
+ "./src/init.ts",
20
+ "./lib/init.js"
21
+ ],
19
22
  "scripts": {
20
23
  "build": "tsc -b"
21
24
  },