@spectrum-web-components/reactive-controllers 1.1.0-beta.8 → 1.1.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 (66) hide show
  1. package/README.md +1 -0
  2. package/package.json +3 -2
  3. package/src/Color.d.ts +0 -46
  4. package/src/Color.dev.js +0 -198
  5. package/src/Color.dev.js.map +0 -7
  6. package/src/Color.js +0 -2
  7. package/src/Color.js.map +0 -7
  8. package/src/DependencyManger.d.ts +0 -26
  9. package/src/DependencyManger.dev.js +0 -46
  10. package/src/DependencyManger.dev.js.map +0 -7
  11. package/src/DependencyManger.js +0 -2
  12. package/src/DependencyManger.js.map +0 -7
  13. package/src/ElementResolution.d.ts +0 -23
  14. package/src/ElementResolution.dev.js +0 -85
  15. package/src/ElementResolution.dev.js.map +0 -7
  16. package/src/ElementResolution.js +0 -2
  17. package/src/ElementResolution.js.map +0 -7
  18. package/src/FocusGroup.d.ts +0 -62
  19. package/src/FocusGroup.dev.js +0 -308
  20. package/src/FocusGroup.dev.js.map +0 -7
  21. package/src/FocusGroup.js +0 -2
  22. package/src/FocusGroup.js.map +0 -7
  23. package/src/LanguageResolution.d.ts +0 -11
  24. package/src/LanguageResolution.dev.js +0 -41
  25. package/src/LanguageResolution.dev.js.map +0 -7
  26. package/src/LanguageResolution.js +0 -2
  27. package/src/LanguageResolution.js.map +0 -7
  28. package/src/MatchMedia.d.ts +0 -13
  29. package/src/MatchMedia.dev.js +0 -29
  30. package/src/MatchMedia.dev.js.map +0 -7
  31. package/src/MatchMedia.js +0 -2
  32. package/src/MatchMedia.js.map +0 -7
  33. package/src/PendingState.d.ts +0 -40
  34. package/src/PendingState.dev.js +0 -57
  35. package/src/PendingState.dev.js.map +0 -7
  36. package/src/PendingState.js +0 -10
  37. package/src/PendingState.js.map +0 -7
  38. package/src/RovingTabindex.d.ts +0 -19
  39. package/src/RovingTabindex.dev.js +0 -72
  40. package/src/RovingTabindex.dev.js.map +0 -7
  41. package/src/RovingTabindex.js +0 -2
  42. package/src/RovingTabindex.js.map +0 -7
  43. package/src/SystemContextResolution.d.ts +0 -15
  44. package/src/SystemContextResolution.dev.js +0 -39
  45. package/src/SystemContextResolution.dev.js.map +0 -7
  46. package/src/SystemContextResolution.js +0 -2
  47. package/src/SystemContextResolution.js.map +0 -7
  48. package/src/index.d.ts +0 -2
  49. package/src/index.dev.js +0 -4
  50. package/src/index.dev.js.map +0 -7
  51. package/src/index.js +0 -2
  52. package/src/index.js.map +0 -7
  53. package/test/dependency-manager.test.js +0 -24
  54. package/test/dependency-manager.test.js.map +0 -7
  55. package/test/element-resolution.test.js +0 -40
  56. package/test/element-resolution.test.js.map +0 -7
  57. package/test/helpers.js +0 -23
  58. package/test/helpers.js.map +0 -7
  59. package/test/match-media.test.js +0 -29
  60. package/test/match-media.test.js.map +0 -7
  61. package/test/pending-state.test.js +0 -128
  62. package/test/pending-state.test.js.map +0 -7
  63. package/test/roving-tabindex-integration.test.js +0 -244
  64. package/test/roving-tabindex-integration.test.js.map +0 -7
  65. package/test/roving-tabindex.test.js +0 -19
  66. package/test/roving-tabindex.test.js.map +0 -7
package/README.md CHANGED
@@ -10,4 +10,5 @@
10
10
  - LanguageResolutionController
11
11
  - [MatchMediaController](../match-media)
12
12
  - [RovingTabindexController](../roving-tab-index)
13
+ - [PendingStateController](../pending-state)
13
14
  - SystemContextResolutionController
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/reactive-controllers",
3
- "version": "1.1.0-beta.8",
3
+ "version": "1.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -84,6 +84,7 @@
84
84
  "reactive controllers"
85
85
  ],
86
86
  "dependencies": {
87
+ "@spectrum-web-components/progress-circle": "^1.1.0",
87
88
  "lit": "^3.1.3"
88
89
  },
89
90
  "types": "./src/index.d.ts",
@@ -91,5 +92,5 @@
91
92
  "sideEffects": [
92
93
  "./**/*.dev.js"
93
94
  ],
94
- "gitHead": "19d5d5747da9d5b167173b571ead76225fc09319"
95
+ "gitHead": "e3c6e52501451acc6fa85b10dd718267b80a01ab"
95
96
  }
package/src/Color.d.ts DELETED
@@ -1,46 +0,0 @@
1
- import type { ReactiveElement } from 'lit';
2
- import { HSL, HSLA, HSV, HSVA, RGB, RGBA, TinyColor } from '@ctrl/tinycolor';
3
- export type { HSL, HSLA, HSV, HSVA, RGB, RGBA, TinyColor };
4
- export type ColorValue = string | number | TinyColor | HSVA | HSV | RGB | RGBA | HSL | HSLA;
5
- export declare const extractHueAndSaturationRegExp: RegExp;
6
- export declare const replaceHueAndSaturationRegExp: RegExp;
7
- export declare const replaceHueRegExp: RegExp;
8
- export declare class ColorController {
9
- protected host: ReactiveElement;
10
- protected applyColorToState: ({ h, s, v, }: {
11
- h: number;
12
- s: number;
13
- v: number;
14
- }) => void;
15
- protected extractColorFromState: (controller: ColorController) => ColorValue;
16
- protected setColorProcess(currentColor: TinyColor, nextColor: ColorValue, format: string, isString: boolean): void;
17
- protected setColorMaintainHue(currentColor: TinyColor, nextColor: ColorValue, format: string, isString: boolean): void;
18
- protected setColorMaintainSaturation(currentColor: TinyColor, nextColor: ColorValue, format: string, isString: boolean): void;
19
- protected maintains: 'hue' | 'saturation';
20
- private saturation;
21
- constructor(host: ReactiveElement, { applyColorToState, extractColorFromState, maintains, }: {
22
- applyColorToState({ h, s, v, }: {
23
- h: number;
24
- s: number;
25
- v: number;
26
- }): void;
27
- extractColorFromState(controller: ColorController): ColorValue;
28
- maintains?: 'hue' | 'saturation';
29
- });
30
- applyColorFromState(): void;
31
- get hue(): number;
32
- set hue(value: number);
33
- private _hue;
34
- protected getColorProcesses: Record<string, (color: TinyColor, isString: boolean) => ColorValue>;
35
- get value(): ColorValue;
36
- get color(): ColorValue;
37
- set color(color: ColorValue);
38
- private _color;
39
- getColor(format: string): ColorValue;
40
- setColor(color: TinyColor): void;
41
- getHslString(): string;
42
- private _previousColor;
43
- savePreviousColor(): void;
44
- restorePreviousColor(): void;
45
- private _format;
46
- }
package/src/Color.dev.js DELETED
@@ -1,198 +0,0 @@
1
- "use strict";
2
- import { TinyColor } from "@ctrl/tinycolor";
3
- export const extractHueAndSaturationRegExp = /^hs[v|l]a?\s?\((\d{1,3}\.?\d*?),?\s?(\d{1,3})/;
4
- export const replaceHueAndSaturationRegExp = /(^hs[v|l]a?\s?\()\d{1,3}\.?\d*?(,?\s?)\d{1,3}/;
5
- export const replaceHueRegExp = /(^hs[v|l]a?\()\d{1,3}/;
6
- const getHexValue = (color, isString) => isString ? color.toHexString() : color.toHex();
7
- export class ColorController {
8
- constructor(host, {
9
- applyColorToState,
10
- extractColorFromState,
11
- maintains
12
- }) {
13
- this.maintains = "hue";
14
- this._hue = 0;
15
- this.getColorProcesses = {
16
- rgb: (color, isString) => isString ? color.toRgbString() : color.toRgb(),
17
- prgb: (color, isString) => isString ? color.toPercentageRgbString() : color.toPercentageRgb(),
18
- hex8: (color, isString) => isString ? color.toHex8String() : color.toHex8(),
19
- name: (color) => color.toName() || color.toRgbString(),
20
- hsl: (color, isString) => {
21
- if (this.maintains === "hue") {
22
- if (isString) {
23
- const hslString = color.toHslString();
24
- return hslString.replace(replaceHueRegExp, `$1${this.hue}`);
25
- } else {
26
- const { s, l, a } = color.toHsl();
27
- return { h: this.hue, s, l, a };
28
- }
29
- } else {
30
- if (isString) {
31
- const hslString = color.toHslString();
32
- return hslString.replace(
33
- replaceHueAndSaturationRegExp,
34
- `$1${this.hue}$2${this.saturation}`
35
- );
36
- } else {
37
- const { s, l, a } = color.toHsl();
38
- return { h: this.hue, s, l, a };
39
- }
40
- }
41
- },
42
- hsv: (color, isString) => {
43
- if (this.maintains === "hue") {
44
- if (isString) {
45
- const hsvString = color.toHsvString();
46
- return hsvString.replace(replaceHueRegExp, `$1${this.hue}`);
47
- } else {
48
- const { s, v, a } = color.toHsv();
49
- return { h: this.hue, s, v, a };
50
- }
51
- } else {
52
- if (isString) {
53
- const hsvString = color.toHsvString();
54
- return hsvString.replace(
55
- replaceHueAndSaturationRegExp,
56
- `$1${this.hue}$2${this.saturation}`
57
- );
58
- } else {
59
- const { s, v, a } = color.toHsv();
60
- return { h: this.hue, s, v, a };
61
- }
62
- }
63
- },
64
- hex: getHexValue,
65
- hex3: getHexValue,
66
- hex4: getHexValue,
67
- hex6: getHexValue
68
- };
69
- this._color = new TinyColor({ h: 0, s: 1, v: 1 });
70
- this._previousColor = new TinyColor({ h: 0, s: 1, v: 1 });
71
- this._format = {
72
- format: "",
73
- isString: false
74
- };
75
- this.host = host;
76
- this.applyColorToState = applyColorToState;
77
- this.extractColorFromState = extractColorFromState;
78
- this.maintains = maintains || this.maintains;
79
- }
80
- setColorProcess(currentColor, nextColor, format, isString) {
81
- if (this.maintains === "hue") {
82
- this.setColorMaintainHue(currentColor, nextColor, format, isString);
83
- } else if (this.maintains === "saturation") {
84
- this.setColorMaintainSaturation(
85
- currentColor,
86
- nextColor,
87
- format,
88
- isString
89
- );
90
- }
91
- }
92
- setColorMaintainHue(currentColor, nextColor, format, isString) {
93
- const { h, s, v } = this._color.toHsv();
94
- let originalHue = void 0;
95
- if (isString && format.startsWith("hs")) {
96
- const values = extractHueAndSaturationRegExp.exec(
97
- nextColor
98
- );
99
- if (values !== null) {
100
- const [, h2] = values;
101
- originalHue = Number(h2);
102
- }
103
- } else if (!isString && format.startsWith("hs")) {
104
- const colorInput = currentColor.originalInput;
105
- const colorValues = Object.values(colorInput);
106
- originalHue = colorValues[0];
107
- }
108
- this.hue = originalHue || h;
109
- this.applyColorToState({ h, s, v });
110
- }
111
- setColorMaintainSaturation(currentColor, nextColor, format, isString) {
112
- if (isString && format.startsWith("hs")) {
113
- const values = extractHueAndSaturationRegExp.exec(
114
- nextColor
115
- );
116
- if (values !== null) {
117
- const [, h, s] = values;
118
- this.hue = Number(h);
119
- this.saturation = Number(s);
120
- }
121
- } else if (!isString && format.startsWith("hs")) {
122
- const colorInput = currentColor.originalInput;
123
- const colorValues = Object.values(colorInput);
124
- this.hue = colorValues[0];
125
- this.saturation = colorValues[1];
126
- } else {
127
- const { h } = currentColor.toHsv();
128
- this.hue = h;
129
- }
130
- this.applyColorToState(currentColor.toHsv());
131
- }
132
- applyColorFromState() {
133
- this._color = new TinyColor(this.extractColorFromState(this));
134
- }
135
- get hue() {
136
- return this._hue;
137
- }
138
- set hue(value) {
139
- const hue = Math.min(360, Math.max(0, value));
140
- if (hue === this.hue) {
141
- return;
142
- }
143
- const oldValue = this.hue;
144
- const { s, v } = this._color.toHsv();
145
- this._color = new TinyColor({ h: hue, s, v });
146
- this._hue = hue;
147
- this.host.requestUpdate("hue", oldValue);
148
- }
149
- /* c8 ignore next 3 */
150
- get value() {
151
- return this.color;
152
- }
153
- get color() {
154
- return this.getColorProcesses[this._format.format || "hex"](
155
- this._color,
156
- this._format.isString
157
- );
158
- }
159
- set color(color) {
160
- if (color === this.color) {
161
- return;
162
- }
163
- const oldValue = this._color;
164
- this._color = new TinyColor(color);
165
- const format = this._color.format;
166
- let isString = typeof color === "string" || color instanceof String;
167
- if (format.startsWith("hex")) {
168
- isString = color.startsWith("#");
169
- }
170
- this._format = {
171
- format,
172
- isString
173
- };
174
- this.setColorProcess(this._color, color, format, isString);
175
- this.host.requestUpdate("color", oldValue);
176
- }
177
- getColor(format) {
178
- const formatOptions = {
179
- hsl: "toHsl"
180
- };
181
- return this._color[formatOptions[format]]();
182
- }
183
- setColor(color) {
184
- this._color = color;
185
- const isString = typeof this._color.originalInput === "string" || this._color.originalInput instanceof String;
186
- this.setColorProcess(this._color, color, this._color.format, isString);
187
- }
188
- getHslString() {
189
- return this._color.toHslString();
190
- }
191
- savePreviousColor() {
192
- this._previousColor = this._color.clone();
193
- }
194
- restorePreviousColor() {
195
- this.setColor(this._previousColor);
196
- }
197
- }
198
- //# sourceMappingURL=Color.dev.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["Color.ts"],
4
- "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveElement } from 'lit';\nimport { HSL, HSLA, HSV, HSVA, RGB, RGBA, TinyColor } from '@ctrl/tinycolor';\nexport type { HSL, HSLA, HSV, HSVA, RGB, RGBA, TinyColor };\n\nexport type ColorValue =\n | string\n | number\n | TinyColor\n | HSVA\n | HSV\n | RGB\n | RGBA\n | HSL\n | HSLA;\n\nexport const extractHueAndSaturationRegExp =\n /^hs[v|l]a?\\s?\\((\\d{1,3}\\.?\\d*?),?\\s?(\\d{1,3})/;\nexport const replaceHueAndSaturationRegExp =\n /(^hs[v|l]a?\\s?\\()\\d{1,3}\\.?\\d*?(,?\\s?)\\d{1,3}/;\nexport const replaceHueRegExp = /(^hs[v|l]a?\\()\\d{1,3}/;\n\ntype TinyColorToValue = {\n toHex: ColorValue;\n toHexString: ColorValue;\n toHsv: ColorValue;\n toHsvString: ColorValue;\n toHsl: ColorValue;\n toHslString: ColorValue;\n toHex8: ColorValue;\n toHex8String: ColorValue;\n toPercentageRgb: ColorValue;\n toPercentageRgbString: ColorValue;\n toRgb: ColorValue;\n toRgbString: ColorValue;\n};\n\nconst getHexValue = (color: TinyColor, isString: boolean): ColorValue =>\n isString ? color.toHexString() : color.toHex();\n\nexport class ColorController {\n protected host: ReactiveElement;\n\n protected applyColorToState!: ({\n h,\n s,\n v,\n }: {\n h: number;\n s: number;\n v: number;\n }) => void;\n\n protected extractColorFromState!: (\n controller: ColorController\n ) => ColorValue;\n\n protected setColorProcess(\n currentColor: TinyColor,\n nextColor: ColorValue,\n format: string,\n isString: boolean\n ): void {\n if (this.maintains === 'hue') {\n this.setColorMaintainHue(currentColor, nextColor, format, isString);\n } else if (this.maintains === 'saturation') {\n this.setColorMaintainSaturation(\n currentColor,\n nextColor,\n format,\n isString\n );\n }\n }\n\n protected setColorMaintainHue(\n currentColor: TinyColor,\n nextColor: ColorValue,\n format: string,\n isString: boolean\n ): void {\n const { h, s, v } = this._color.toHsv();\n let originalHue: number | undefined = undefined;\n\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(\n nextColor as string\n );\n\n if (values !== null) {\n const [, h] = values;\n originalHue = Number(h);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = currentColor.originalInput;\n const colorValues = Object.values(colorInput);\n originalHue = colorValues[0];\n }\n\n this.hue = originalHue || h;\n this.applyColorToState({ h, s, v });\n }\n\n protected setColorMaintainSaturation(\n currentColor: TinyColor,\n nextColor: ColorValue,\n format: string,\n isString: boolean\n ): void {\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(\n nextColor as string\n );\n\n if (values !== null) {\n const [, h, s] = values;\n this.hue = Number(h);\n this.saturation = Number(s);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = currentColor.originalInput;\n const colorValues = Object.values(colorInput);\n this.hue = colorValues[0];\n this.saturation = colorValues[1];\n } else {\n const { h } = currentColor.toHsv();\n this.hue = h;\n }\n this.applyColorToState(currentColor.toHsv());\n }\n\n protected maintains: 'hue' | 'saturation' = 'hue';\n private saturation!: number;\n\n constructor(\n host: ReactiveElement,\n {\n applyColorToState,\n extractColorFromState,\n maintains,\n }: {\n applyColorToState({\n h,\n s,\n v,\n }: {\n h: number;\n s: number;\n v: number;\n }): void;\n extractColorFromState(controller: ColorController): ColorValue;\n maintains?: 'hue' | 'saturation';\n }\n ) {\n this.host = host;\n this.applyColorToState = applyColorToState;\n this.extractColorFromState = extractColorFromState;\n this.maintains = maintains || this.maintains;\n }\n\n public applyColorFromState(): void {\n this._color = new TinyColor(this.extractColorFromState(this));\n }\n\n public get hue(): number {\n return this._hue;\n }\n\n public set hue(value: number) {\n const hue = Math.min(360, Math.max(0, value));\n if (hue === this.hue) {\n return;\n }\n const oldValue = this.hue;\n const { s, v } = this._color.toHsv();\n this._color = new TinyColor({ h: hue, s, v });\n this._hue = hue;\n this.host.requestUpdate('hue', oldValue);\n }\n\n private _hue = 0;\n\n protected getColorProcesses: Record<\n string,\n (color: TinyColor, isString: boolean) => ColorValue\n > = {\n rgb: (color, isString) =>\n isString ? color.toRgbString() : color.toRgb(),\n prgb: (color, isString) =>\n isString ? color.toPercentageRgbString() : color.toPercentageRgb(),\n hex8: (color, isString) =>\n isString ? color.toHex8String() : color.toHex8(),\n name: (color) => color.toName() || color.toRgbString(),\n hsl: (color, isString) => {\n if (this.maintains === 'hue') {\n if (isString) {\n const hslString = color.toHslString();\n return hslString.replace(replaceHueRegExp, `$1${this.hue}`);\n } else {\n const { s, l, a } = color.toHsl();\n return { h: this.hue, s, l, a };\n }\n } else {\n if (isString) {\n const hslString = color.toHslString();\n return hslString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.hue}$2${this.saturation}`\n );\n } else {\n const { s, l, a } = color.toHsl();\n return { h: this.hue, s, l, a };\n }\n }\n },\n hsv: (color, isString) => {\n if (this.maintains === 'hue') {\n if (isString) {\n const hsvString = color.toHsvString();\n return hsvString.replace(replaceHueRegExp, `$1${this.hue}`);\n } else {\n const { s, v, a } = color.toHsv();\n return { h: this.hue, s, v, a };\n }\n } else {\n if (isString) {\n const hsvString = color.toHsvString();\n return hsvString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.hue}$2${this.saturation}`\n );\n } else {\n const { s, v, a } = color.toHsv();\n return { h: this.hue, s, v, a };\n }\n }\n },\n hex: getHexValue,\n hex3: getHexValue,\n hex4: getHexValue,\n hex6: getHexValue,\n };\n\n /* c8 ignore next 3 */\n public get value(): ColorValue {\n return this.color;\n }\n\n public get color(): ColorValue {\n return this.getColorProcesses[this._format.format || 'hex'](\n this._color,\n this._format.isString\n );\n }\n\n public set color(color: ColorValue) {\n /* c8 ignore next 3 */\n if (color === this.color) {\n return;\n }\n const oldValue = this._color;\n this._color = new TinyColor(color);\n const format = this._color.format;\n let isString = typeof color === 'string' || color instanceof String;\n\n if (format.startsWith('hex')) {\n isString = (color as string).startsWith('#');\n }\n\n this._format = {\n format,\n isString,\n };\n\n this.setColorProcess(this._color, color, format, isString);\n this.host.requestUpdate('color', oldValue);\n }\n\n private _color = new TinyColor({ h: 0, s: 1, v: 1 });\n\n public getColor(format: string): ColorValue {\n const formatOptions: Record<string, keyof TinyColorToValue> = {\n hsl: 'toHsl',\n };\n return this._color[formatOptions[format]]();\n }\n\n public setColor(color: TinyColor): void {\n this._color = color;\n const isString =\n typeof this._color.originalInput === 'string' ||\n this._color.originalInput instanceof String;\n this.setColorProcess(this._color, color, this._color.format, isString);\n }\n\n public getHslString(): string {\n return this._color.toHslString();\n }\n\n private _previousColor = new TinyColor({ h: 0, s: 1, v: 1 });\n\n public savePreviousColor(): void {\n this._previousColor = this._color.clone();\n }\n\n public restorePreviousColor(): void {\n this.setColor(this._previousColor);\n }\n\n private _format: { format: string; isString: boolean } = {\n format: '',\n isString: false,\n };\n}\n"],
5
- "mappings": ";AAaA,SAA0C,iBAAiB;AAcpD,aAAM,gCACT;AACG,aAAM,gCACT;AACG,aAAM,mBAAmB;AAiBhC,MAAM,cAAc,CAAC,OAAkB,aACnC,WAAW,MAAM,YAAY,IAAI,MAAM,MAAM;AAE1C,aAAM,gBAAgB;AAAA,EA8FzB,YACI,MACA;AAAA,IACI;AAAA,IACA;AAAA,IACA;AAAA,EACJ,GAaF;AAtBF,SAAU,YAAkC;AAiD5C,SAAQ,OAAO;AAEf,SAAU,oBAGN;AAAA,MACA,KAAK,CAAC,OAAO,aACT,WAAW,MAAM,YAAY,IAAI,MAAM,MAAM;AAAA,MACjD,MAAM,CAAC,OAAO,aACV,WAAW,MAAM,sBAAsB,IAAI,MAAM,gBAAgB;AAAA,MACrE,MAAM,CAAC,OAAO,aACV,W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TinyColor as l}from"@ctrl/tinycolor";export const extractHueAndSaturationRegExp=/^hs[v|l]a?\s?\((\d{1,3}\.?\d*?),?\s?(\d{1,3})/,replaceHueAndSaturationRegExp=/(^hs[v|l]a?\s?\()\d{1,3}\.?\d*?(,?\s?)\d{1,3}/,replaceHueRegExp=/(^hs[v|l]a?\()\d{1,3}/;const a=(h,t)=>t?h.toHexString():h.toHex();export class ColorController{constructor(t,{applyColorToState:o,extractColorFromState:e,maintains:r}){this.maintains="hue";this._hue=0;this.getColorProcesses={rgb:(t,o)=>o?t.toRgbString():t.toRgb(),prgb:(t,o)=>o?t.toPercentageRgbString():t.toPercentageRgb(),hex8:(t,o)=>o?t.toHex8String():t.toHex8(),name:t=>t.toName()||t.toRgbString(),hsl:(t,o)=>{if(this.maintains==="hue"){if(o)return t.toHslString().replace(replaceHueRegExp,`$1${this.hue}`);{const{s:e,l:r,a:s}=t.toHsl();return{h:this.hue,s:e,l:r,a:s}}}else{if(o)return t.toHslString().replace(replaceHueAndSaturationRegExp,`$1${this.hue}$2${this.saturation}`);{const{s:e,l:r,a:s}=t.toHsl();return{h:this.hue,s:e,l:r,a:s}}}},hsv:(t,o)=>{if(this.maintains==="hue"){if(o)return t.toHsvString().replace(replaceHueRegExp,`$1${this.hue}`);{const{s:e,v:r,a:s}=t.toHsv();return{h:this.hue,s:e,v:r,a:s}}}else{if(o)return t.toHsvString().replace(replaceHueAndSaturationRegExp,`$1${this.hue}$2${this.saturation}`);{const{s:e,v:r,a:s}=t.toHsv();return{h:this.hue,s:e,v:r,a:s}}}},hex:a,hex3:a,hex4:a,hex6:a};this._color=new l({h:0,s:1,v:1});this._previousColor=new l({h:0,s:1,v:1});this._format={format:"",isString:!1};this.host=t,this.applyColorToState=o,this.extractColorFromState=e,this.maintains=r||this.maintains}setColorProcess(t,o,e,r){this.maintains==="hue"?this.setColorMaintainHue(t,o,e,r):this.maintains==="saturation"&&this.setColorMaintainSaturation(t,o,e,r)}setColorMaintainHue(t,o,e,r){const{h:s,s:i,v:u}=this._color.toHsv();let c;if(r&&e.startsWith("hs")){const n=extractHueAndSaturationRegExp.exec(o);if(n!==null){const[,g]=n;c=Number(g)}}else if(!r&&e.startsWith("hs")){const n=t.originalInput;c=Object.values(n)[0]}this.hue=c||s,this.applyColorToState({h:s,s:i,v:u})}setColorMaintainSaturation(t,o,e,r){if(r&&e.startsWith("hs")){const s=extractHueAndSaturationRegExp.exec(o);if(s!==null){const[,i,u]=s;this.hue=Number(i),this.saturation=Number(u)}}else if(!r&&e.startsWith("hs")){const s=t.originalInput,i=Object.values(s);this.hue=i[0],this.saturation=i[1]}else{const{h:s}=t.toHsv();this.hue=s}this.applyColorToState(t.toHsv())}applyColorFromState(){this._color=new l(this.extractColorFromState(this))}get hue(){return this._hue}set hue(t){const o=Math.min(360,Math.max(0,t));if(o===this.hue)return;const e=this.hue,{s:r,v:s}=this._color.toHsv();this._color=new l({h:o,s:r,v:s}),this._hue=o,this.host.requestUpdate("hue",e)}get value(){return this.color}get color(){return this.getColorProcesses[this._format.format||"hex"](this._color,this._format.isString)}set color(t){if(t===this.color)return;const o=this._color;this._color=new l(t);const e=this._color.format;let r=typeof t=="string"||t instanceof String;e.startsWith("hex")&&(r=t.startsWith("#")),this._format={format:e,isString:r},this.setColorProcess(this._color,t,e,r),this.host.requestUpdate("color",o)}getColor(t){const o={hsl:"toHsl"};return this._color[o[t]]()}setColor(t){this._color=t;const o=typeof this._color.originalInput=="string"||this._color.originalInput instanceof String;this.setColorProcess(this._color,t,this._color.format,o)}getHslString(){return this._color.toHslString()}savePreviousColor(){this._previousColor=this._color.clone()}restorePreviousColor(){this.setColor(this._previousColor)}}
2
- //# sourceMappingURL=Color.js.map
package/src/Color.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["Color.ts"],
4
- "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveElement } from 'lit';\nimport { HSL, HSLA, HSV, HSVA, RGB, RGBA, TinyColor } from '@ctrl/tinycolor';\nexport type { HSL, HSLA, HSV, HSVA, RGB, RGBA, TinyColor };\n\nexport type ColorValue =\n | string\n | number\n | TinyColor\n | HSVA\n | HSV\n | RGB\n | RGBA\n | HSL\n | HSLA;\n\nexport const extractHueAndSaturationRegExp =\n /^hs[v|l]a?\\s?\\((\\d{1,3}\\.?\\d*?),?\\s?(\\d{1,3})/;\nexport const replaceHueAndSaturationRegExp =\n /(^hs[v|l]a?\\s?\\()\\d{1,3}\\.?\\d*?(,?\\s?)\\d{1,3}/;\nexport const replaceHueRegExp = /(^hs[v|l]a?\\()\\d{1,3}/;\n\ntype TinyColorToValue = {\n toHex: ColorValue;\n toHexString: ColorValue;\n toHsv: ColorValue;\n toHsvString: ColorValue;\n toHsl: ColorValue;\n toHslString: ColorValue;\n toHex8: ColorValue;\n toHex8String: ColorValue;\n toPercentageRgb: ColorValue;\n toPercentageRgbString: ColorValue;\n toRgb: ColorValue;\n toRgbString: ColorValue;\n};\n\nconst getHexValue = (color: TinyColor, isString: boolean): ColorValue =>\n isString ? color.toHexString() : color.toHex();\n\nexport class ColorController {\n protected host: ReactiveElement;\n\n protected applyColorToState!: ({\n h,\n s,\n v,\n }: {\n h: number;\n s: number;\n v: number;\n }) => void;\n\n protected extractColorFromState!: (\n controller: ColorController\n ) => ColorValue;\n\n protected setColorProcess(\n currentColor: TinyColor,\n nextColor: ColorValue,\n format: string,\n isString: boolean\n ): void {\n if (this.maintains === 'hue') {\n this.setColorMaintainHue(currentColor, nextColor, format, isString);\n } else if (this.maintains === 'saturation') {\n this.setColorMaintainSaturation(\n currentColor,\n nextColor,\n format,\n isString\n );\n }\n }\n\n protected setColorMaintainHue(\n currentColor: TinyColor,\n nextColor: ColorValue,\n format: string,\n isString: boolean\n ): void {\n const { h, s, v } = this._color.toHsv();\n let originalHue: number | undefined = undefined;\n\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(\n nextColor as string\n );\n\n if (values !== null) {\n const [, h] = values;\n originalHue = Number(h);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = currentColor.originalInput;\n const colorValues = Object.values(colorInput);\n originalHue = colorValues[0];\n }\n\n this.hue = originalHue || h;\n this.applyColorToState({ h, s, v });\n }\n\n protected setColorMaintainSaturation(\n currentColor: TinyColor,\n nextColor: ColorValue,\n format: string,\n isString: boolean\n ): void {\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(\n nextColor as string\n );\n\n if (values !== null) {\n const [, h, s] = values;\n this.hue = Number(h);\n this.saturation = Number(s);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = currentColor.originalInput;\n const colorValues = Object.values(colorInput);\n this.hue = colorValues[0];\n this.saturation = colorValues[1];\n } else {\n const { h } = currentColor.toHsv();\n this.hue = h;\n }\n this.applyColorToState(currentColor.toHsv());\n }\n\n protected maintains: 'hue' | 'saturation' = 'hue';\n private saturation!: number;\n\n constructor(\n host: ReactiveElement,\n {\n applyColorToState,\n extractColorFromState,\n maintains,\n }: {\n applyColorToState({\n h,\n s,\n v,\n }: {\n h: number;\n s: number;\n v: number;\n }): void;\n extractColorFromState(controller: ColorController): ColorValue;\n maintains?: 'hue' | 'saturation';\n }\n ) {\n this.host = host;\n this.applyColorToState = applyColorToState;\n this.extractColorFromState = extractColorFromState;\n this.maintains = maintains || this.maintains;\n }\n\n public applyColorFromState(): void {\n this._color = new TinyColor(this.extractColorFromState(this));\n }\n\n public get hue(): number {\n return this._hue;\n }\n\n public set hue(value: number) {\n const hue = Math.min(360, Math.max(0, value));\n if (hue === this.hue) {\n return;\n }\n const oldValue = this.hue;\n const { s, v } = this._color.toHsv();\n this._color = new TinyColor({ h: hue, s, v });\n this._hue = hue;\n this.host.requestUpdate('hue', oldValue);\n }\n\n private _hue = 0;\n\n protected getColorProcesses: Record<\n string,\n (color: TinyColor, isString: boolean) => ColorValue\n > = {\n rgb: (color, isString) =>\n isString ? color.toRgbString() : color.toRgb(),\n prgb: (color, isString) =>\n isString ? color.toPercentageRgbString() : color.toPercentageRgb(),\n hex8: (color, isString) =>\n isString ? color.toHex8String() : color.toHex8(),\n name: (color) => color.toName() || color.toRgbString(),\n hsl: (color, isString) => {\n if (this.maintains === 'hue') {\n if (isString) {\n const hslString = color.toHslString();\n return hslString.replace(replaceHueRegExp, `$1${this.hue}`);\n } else {\n const { s, l, a } = color.toHsl();\n return { h: this.hue, s, l, a };\n }\n } else {\n if (isString) {\n const hslString = color.toHslString();\n return hslString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.hue}$2${this.saturation}`\n );\n } else {\n const { s, l, a } = color.toHsl();\n return { h: this.hue, s, l, a };\n }\n }\n },\n hsv: (color, isString) => {\n if (this.maintains === 'hue') {\n if (isString) {\n const hsvString = color.toHsvString();\n return hsvString.replace(replaceHueRegExp, `$1${this.hue}`);\n } else {\n const { s, v, a } = color.toHsv();\n return { h: this.hue, s, v, a };\n }\n } else {\n if (isString) {\n const hsvString = color.toHsvString();\n return hsvString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.hue}$2${this.saturation}`\n );\n } else {\n const { s, v, a } = color.toHsv();\n return { h: this.hue, s, v, a };\n }\n }\n },\n hex: getHexValue,\n hex3: getHexValue,\n hex4: getHexValue,\n hex6: getHexValue,\n };\n\n /* c8 ignore next 3 */\n public get value(): ColorValue {\n return this.color;\n }\n\n public get color(): ColorValue {\n return this.getColorProcesses[this._format.format || 'hex'](\n this._color,\n this._format.isString\n );\n }\n\n public set color(color: ColorValue) {\n /* c8 ignore next 3 */\n if (color === this.color) {\n return;\n }\n const oldValue = this._color;\n this._color = new TinyColor(color);\n const format = this._color.format;\n let isString = typeof color === 'string' || color instanceof String;\n\n if (format.startsWith('hex')) {\n isString = (color as string).startsWith('#');\n }\n\n this._format = {\n format,\n isString,\n };\n\n this.setColorProcess(this._color, color, format, isString);\n this.host.requestUpdate('color', oldValue);\n }\n\n private _color = new TinyColor({ h: 0, s: 1, v: 1 });\n\n public getColor(format: string): ColorValue {\n const formatOptions: Record<string, keyof TinyColorToValue> = {\n hsl: 'toHsl',\n };\n return this._color[formatOptions[format]]();\n }\n\n public setColor(color: TinyColor): void {\n this._color = color;\n const isString =\n typeof this._color.originalInput === 'string' ||\n this._color.originalInput instanceof String;\n this.setColorProcess(this._color, color, this._color.format, isString);\n }\n\n public getHslString(): string {\n return this._color.toHslString();\n }\n\n private _previousColor = new TinyColor({ h: 0, s: 1, v: 1 });\n\n public savePreviousColor(): void {\n this._previousColor = this._color.clone();\n }\n\n public restorePreviousColor(): void {\n this.setColor(this._previousColor);\n }\n\n private _format: { format: string; isString: boolean } = {\n format: '',\n isString: false,\n };\n}\n"],
5
- "mappings": "aAaA,OAA0C,aAAAA,MAAiB,kBAcpD,aAAM,8BACT,gDACS,8BACT,gDACS,iBAAmB,wBAiBhC,MAAMC,EAAc,CAACC,EAAkBC,IACnCA,EAAWD,EAAM,YAAY,EAAIA,EAAM,MAAM,EAE1C,aAAM,eAAgB,CA8FzB,YACIE,EACA,CACI,kBAAAC,EACA,sBAAAC,EACA,UAAAC,CACJ,EAaF,CAtBF,KAAU,UAAkC,MAiD5C,KAAQ,KAAO,EAEf,KAAU,kBAGN,CACA,IAAK,CAACL,EAAOC,IACTA,EAAWD,EAAM,YAAY,EAAIA,EAAM,MAAM,EACjD,KAAM,CAACA,EAAOC,IACVA,EAAWD,EAAM,sBAAsB,EAAIA,EAAM,gBAAgB,EACrE,KAAM,CAACA,EAAOC,IACVA,EAAWD,EAAM,aAAa,EAAIA,EAAM,OAAO,EACnD,KAAOA,GAAUA,EAAM,OAAO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,OAAOD,GAAU,UAAYA,aAAiB,OAEzDY,EAAO,WAAW,KAAK,IACvBX,EAAYD,EAAiB,WAAW,GAAG,GAG/C,KAAK,QAAU,CACX,OAAAY,EACA,SAAAX,CACJ,EAEA,KAAK,gBAAgB,KAAK,OAAQD,EAAOY,EAAQX,CAAQ,EACzD,KAAK,KAAK,cAAc,QAASmB,CAAQ,CAC7C,CAIO,SAASR,EAA4B,CACxC,MAAMS,EAAwD,CAC1D,IAAK,OACT,EACA,OAAO,KAAK,OAAOA,EAAcT,CAAM,CAAC,EAAE,CAC9C,CAEO,SAASZ,EAAwB,CACpC,KAAK,OAASA,EACd,MAAMC,EACF,OAAO,KAAK,OAAO,eAAkB,UACrC,KAAK,OAAO,yBAAyB,OACzC,KAAK,gBAAgB,KAAK,OAAQD,EAAO,KAAK,OAAO,OAAQC,CAAQ,CACzE,CAEO,cAAuB,CAC1B,OAAO,KAAK,OAAO,YAAY,CACnC,CAIO,mBAA0B,CAC7B,KAAK,eAAiB,KAAK,OAAO,MAAM,CAC5C,CAEO,sBAA6B,CAChC,KAAK,SAAS,KAAK,cAAc,CACrC,CAMJ",
6
- "names": ["TinyColor", "getHexValue", "color", "isString", "host", "applyColorToState", "extractColorFromState", "maintains", "s", "l", "a", "v", "currentColor", "nextColor", "format", "h", "originalHue", "values", "colorInput", "colorValues", "value", "hue", "oldValue", "formatOptions"]
7
- }
@@ -1,26 +0,0 @@
1
- import type { ReactiveElement } from 'lit';
2
- export declare const dependencyManagerLoadedSymbol: unique symbol;
3
- /**
4
- * Manage the availability of custom element dependencies of a host element
5
- * to gate render and functional behavior before and after their presence
6
- */
7
- export declare class DependencyManagerController {
8
- private dependencies;
9
- private host;
10
- /**
11
- * Whether all of the provided dependencies have been registered.
12
- * This will be `false` when no dependencies have been listed for management.
13
- * Changes to this value will trigger `requestUpdate()` on the host.
14
- */
15
- get loaded(): boolean;
16
- private set loaded(value);
17
- private _loaded;
18
- constructor(host: ReactiveElement);
19
- /**
20
- * Submit a custom element tag name to be managed as a dependency.
21
- *
22
- * @param dependency {string} - the custom element tag to manage
23
- * @param alreadyLoaded {boolean} - force the managemented custom element to be listed as loaded
24
- */
25
- add(dependency: string, alreadyLoaded?: boolean): void;
26
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- export const dependencyManagerLoadedSymbol = Symbol(
3
- "dependency manager loaded"
4
- );
5
- export class DependencyManagerController {
6
- constructor(host) {
7
- this.dependencies = {};
8
- this._loaded = false;
9
- this.host = host;
10
- }
11
- /**
12
- * Whether all of the provided dependencies have been registered.
13
- * This will be `false` when no dependencies have been listed for management.
14
- * Changes to this value will trigger `requestUpdate()` on the host.
15
- */
16
- get loaded() {
17
- return this._loaded;
18
- }
19
- set loaded(loaded) {
20
- if (loaded === this.loaded) return;
21
- this._loaded = loaded;
22
- this.host.requestUpdate(dependencyManagerLoadedSymbol, !this.loaded);
23
- }
24
- /**
25
- * Submit a custom element tag name to be managed as a dependency.
26
- *
27
- * @param dependency {string} - the custom element tag to manage
28
- * @param alreadyLoaded {boolean} - force the managemented custom element to be listed as loaded
29
- */
30
- add(dependency, alreadyLoaded) {
31
- const loaded = !!alreadyLoaded || !!customElements.get(dependency) || this.dependencies[dependency];
32
- if (!loaded) {
33
- customElements.whenDefined(dependency).then(() => {
34
- this.add(dependency, true);
35
- });
36
- }
37
- this.dependencies = {
38
- ...this.dependencies,
39
- [dependency]: loaded
40
- };
41
- this.loaded = Object.values(this.dependencies).every(
42
- (loaded2) => loaded2
43
- );
44
- }
45
- }
46
- //# sourceMappingURL=DependencyManger.dev.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["DependencyManger.ts"],
4
- "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveElement } from 'lit';\nexport const dependencyManagerLoadedSymbol = Symbol(\n 'dependency manager loaded'\n);\n\n/**\n * Manage the availability of custom element dependencies of a host element\n * to gate render and functional behavior before and after their presence\n */\nexport class DependencyManagerController {\n private dependencies: Record<string, boolean> = {};\n\n private host!: ReactiveElement;\n\n /**\n * Whether all of the provided dependencies have been registered.\n * This will be `false` when no dependencies have been listed for management.\n * Changes to this value will trigger `requestUpdate()` on the host.\n */\n public get loaded(): boolean {\n return this._loaded;\n }\n\n private set loaded(loaded: boolean) {\n if (loaded === this.loaded) return;\n this._loaded = loaded;\n this.host.requestUpdate(dependencyManagerLoadedSymbol, !this.loaded);\n }\n\n private _loaded = false;\n\n constructor(host: ReactiveElement) {\n this.host = host;\n }\n\n /**\n * Submit a custom element tag name to be managed as a dependency.\n *\n * @param dependency {string} - the custom element tag to manage\n * @param alreadyLoaded {boolean} - force the managemented custom element to be listed as loaded\n */\n public add(dependency: string, alreadyLoaded?: boolean): void {\n const loaded =\n !!alreadyLoaded ||\n !!customElements.get(dependency) ||\n this.dependencies[dependency];\n if (!loaded) {\n customElements.whenDefined(dependency).then(() => {\n this.add(dependency, true);\n });\n }\n this.dependencies = {\n ...this.dependencies,\n [dependency]: loaded,\n };\n // Update the loaded property based on the new loaded state of all dependencies\n this.loaded = Object.values(this.dependencies).every(\n (loaded) => loaded\n );\n }\n}\n"],
5
- "mappings": ";AAaO,aAAM,gCAAgC;AAAA,EACzC;AACJ;AAMO,aAAM,4BAA4B;AAAA,EAsBrC,YAAY,MAAuB;AArBnC,SAAQ,eAAwC,CAAC;AAmBjD,SAAQ,UAAU;AAGd,SAAK,OAAO;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAdA,IAAW,SAAkB;AACzB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAY,OAAO,QAAiB;AAChC,QAAI,WAAW,KAAK,OAAQ;AAC5B,SAAK,UAAU;AACf,SAAK,KAAK,cAAc,+BAA+B,CAAC,KAAK,MAAM;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcO,IAAI,YAAoB,eAA+B;AAC1D,UAAM,SACF,CAAC,CAAC,iBACF,CAAC,CAAC,eAAe,IAAI,UAAU,KAC/B,KAAK,aAAa,UAAU;AAChC,QAAI,CAAC,QAAQ;AACT,qBAAe,YAAY,UAAU,EAAE,KAAK,MAAM;AAC9C,aAAK,IAAI,YAAY,IAAI;AAAA,MAC7B,CAAC;AAAA,IACL;AACA,SAAK,eAAe;AAAA,MAChB,GAAG,KAAK;AAAA,MACR,CAAC,UAAU,GAAG;AAAA,IAClB;AAEA,SAAK,SAAS,OAAO,OAAO,KAAK,YAAY,EAAE;AAAA,MAC3C,CAACA,YAAWA;AAAA,IAChB;AAAA,EACJ;AACJ;",
6
- "names": ["loaded"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";export const dependencyManagerLoadedSymbol=Symbol("dependency manager loaded");export class DependencyManagerController{constructor(e){this.dependencies={};this._loaded=!1;this.host=e}get loaded(){return this._loaded}set loaded(e){e!==this.loaded&&(this._loaded=e,this.host.requestUpdate(dependencyManagerLoadedSymbol,!this.loaded))}add(e,o){const t=!!o||!!customElements.get(e)||this.dependencies[e];t||customElements.whenDefined(e).then(()=>{this.add(e,!0)}),this.dependencies={...this.dependencies,[e]:t},this.loaded=Object.values(this.dependencies).every(d=>d)}}
2
- //# sourceMappingURL=DependencyManger.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["DependencyManger.ts"],
4
- "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveElement } from 'lit';\nexport const dependencyManagerLoadedSymbol = Symbol(\n 'dependency manager loaded'\n);\n\n/**\n * Manage the availability of custom element dependencies of a host element\n * to gate render and functional behavior before and after their presence\n */\nexport class DependencyManagerController {\n private dependencies: Record<string, boolean> = {};\n\n private host!: ReactiveElement;\n\n /**\n * Whether all of the provided dependencies have been registered.\n * This will be `false` when no dependencies have been listed for management.\n * Changes to this value will trigger `requestUpdate()` on the host.\n */\n public get loaded(): boolean {\n return this._loaded;\n }\n\n private set loaded(loaded: boolean) {\n if (loaded === this.loaded) return;\n this._loaded = loaded;\n this.host.requestUpdate(dependencyManagerLoadedSymbol, !this.loaded);\n }\n\n private _loaded = false;\n\n constructor(host: ReactiveElement) {\n this.host = host;\n }\n\n /**\n * Submit a custom element tag name to be managed as a dependency.\n *\n * @param dependency {string} - the custom element tag to manage\n * @param alreadyLoaded {boolean} - force the managemented custom element to be listed as loaded\n */\n public add(dependency: string, alreadyLoaded?: boolean): void {\n const loaded =\n !!alreadyLoaded ||\n !!customElements.get(dependency) ||\n this.dependencies[dependency];\n if (!loaded) {\n customElements.whenDefined(dependency).then(() => {\n this.add(dependency, true);\n });\n }\n this.dependencies = {\n ...this.dependencies,\n [dependency]: loaded,\n };\n // Update the loaded property based on the new loaded state of all dependencies\n this.loaded = Object.values(this.dependencies).every(\n (loaded) => loaded\n );\n }\n}\n"],
5
- "mappings": "aAaO,aAAM,8BAAgC,OACzC,2BACJ,EAMO,aAAM,2BAA4B,CAsBrC,YAAYA,EAAuB,CArBnC,KAAQ,aAAwC,CAAC,EAmBjD,KAAQ,QAAU,GAGd,KAAK,KAAOA,CAChB,CAdA,IAAW,QAAkB,CACzB,OAAO,KAAK,OAChB,CAEA,IAAY,OAAOC,EAAiB,CAC5BA,IAAW,KAAK,SACpB,KAAK,QAAUA,EACf,KAAK,KAAK,cAAc,8BAA+B,CAAC,KAAK,MAAM,EACvE,CAcO,IAAIC,EAAoBC,EAA+B,CAC1D,MAAMF,EACF,CAAC,CAACE,GACF,CAAC,CAAC,eAAe,IAAID,CAAU,GAC/B,KAAK,aAAaA,CAAU,EAC3BD,GACD,eAAe,YAAYC,CAAU,EAAE,KAAK,IAAM,CAC9C,KAAK,IAAIA,EAAY,EAAI,CAC7B,CAAC,EAEL,KAAK,aAAe,CAChB,GAAG,KAAK,aACR,CAACA,CAAU,EAAGD,CAClB,EAEA,KAAK,OAAS,OAAO,OAAO,KAAK,YAAY,EAAE,MAC1CA,GAAWA,CAChB,CACJ,CACJ",
6
- "names": ["host", "loaded", "dependency", "alreadyLoaded"]
7
- }
@@ -1,23 +0,0 @@
1
- import type { ReactiveController, ReactiveElement } from 'lit';
2
- export declare const elementResolverUpdatedSymbol: unique symbol;
3
- export declare class ElementResolutionController implements ReactiveController {
4
- get element(): HTMLElement | null;
5
- set element(element: HTMLElement | null);
6
- private _element;
7
- private host;
8
- private observer;
9
- get selector(): string;
10
- set selector(selector: string);
11
- private _selector;
12
- get selectorAsId(): string;
13
- get selectorIsId(): boolean;
14
- constructor(host: ReactiveElement, { selector }?: {
15
- selector: string;
16
- });
17
- protected mutationCallback: MutationCallback;
18
- hostConnected(): void;
19
- hostDisconnected(): void;
20
- private resolveElement;
21
- private releaseElement;
22
- private elementIsSelected;
23
- }
@@ -1,85 +0,0 @@
1
- "use strict";
2
- export const elementResolverUpdatedSymbol = Symbol("element resolver updated");
3
- export class ElementResolutionController {
4
- constructor(host, { selector } = { selector: "" }) {
5
- this._element = null;
6
- this._selector = "";
7
- this.mutationCallback = (mutationList) => {
8
- let needsResolution = false;
9
- mutationList.forEach((mutation) => {
10
- if (needsResolution) return;
11
- if (mutation.type === "childList") {
12
- const currentElementRemoved = this.element && [...mutation.removedNodes].includes(this.element);
13
- const matchingElementAdded = !!this.selector && [...mutation.addedNodes].some(
14
- this.elementIsSelected
15
- );
16
- needsResolution = needsResolution || currentElementRemoved || matchingElementAdded;
17
- }
18
- if (mutation.type === "attributes") {
19
- const attributeChangedOnCurrentElement = mutation.target === this.element;
20
- const attributeChangedOnMatchingElement = !!this.selector && this.elementIsSelected(mutation.target);
21
- needsResolution = needsResolution || attributeChangedOnCurrentElement || attributeChangedOnMatchingElement;
22
- }
23
- });
24
- if (needsResolution) {
25
- this.resolveElement();
26
- }
27
- };
28
- this.elementIsSelected = (el) => {
29
- var _a;
30
- return this.selectorIsId ? (el == null ? void 0 : el.id) === this.selectorAsId : (_a = el == null ? void 0 : el.matches) == null ? void 0 : _a.call(el, this.selector);
31
- };
32
- this.host = host;
33
- this.selector = selector;
34
- this.observer = new MutationObserver(this.mutationCallback);
35
- this.host.addController(this);
36
- }
37
- get element() {
38
- return this._element;
39
- }
40
- set element(element) {
41
- if (element === this.element) return;
42
- const previous = this.element;
43
- this._element = element;
44
- this.host.requestUpdate(elementResolverUpdatedSymbol, previous);
45
- }
46
- get selector() {
47
- return this._selector;
48
- }
49
- set selector(selector) {
50
- if (selector === this.selector) return;
51
- this.releaseElement();
52
- this._selector = selector;
53
- this.resolveElement();
54
- }
55
- get selectorAsId() {
56
- return this.selector.slice(1);
57
- }
58
- get selectorIsId() {
59
- return !!this.selector && this.selector.startsWith("#");
60
- }
61
- hostConnected() {
62
- this.resolveElement();
63
- this.observer.observe(this.host.getRootNode(), {
64
- subtree: true,
65
- childList: true,
66
- attributes: true
67
- });
68
- }
69
- hostDisconnected() {
70
- this.releaseElement();
71
- this.observer.disconnect();
72
- }
73
- resolveElement() {
74
- if (!this.selector) {
75
- this.releaseElement();
76
- return;
77
- }
78
- const parent = this.host.getRootNode();
79
- this.element = this.selectorIsId ? parent.getElementById(this.selectorAsId) : parent.querySelector(this.selector);
80
- }
81
- releaseElement() {
82
- this.element = null;
83
- }
84
- }
85
- //# sourceMappingURL=ElementResolution.dev.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["ElementResolution.ts"],
4
- "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nexport const elementResolverUpdatedSymbol = Symbol('element resolver updated');\n\nexport class ElementResolutionController implements ReactiveController {\n get element(): HTMLElement | null {\n return this._element;\n }\n\n set element(element: HTMLElement | null) {\n if (element === this.element) return;\n const previous = this.element;\n this._element = element;\n // requestUpdate leveraging the exported Symbol() so that the\n // changes can be easily tracked in the host element.\n this.host.requestUpdate(elementResolverUpdatedSymbol, previous);\n }\n\n private _element: HTMLElement | null = null;\n\n private host!: ReactiveElement;\n\n private observer!: MutationObserver;\n\n get selector(): string {\n return this._selector;\n }\n\n set selector(selector: string) {\n if (selector === this.selector) return;\n this.releaseElement();\n this._selector = selector;\n this.resolveElement();\n }\n\n private _selector = '';\n\n get selectorAsId(): string {\n return this.selector.slice(1);\n }\n\n get selectorIsId(): boolean {\n return !!this.selector && this.selector.startsWith('#');\n }\n\n constructor(\n host: ReactiveElement,\n { selector }: { selector: string } = { selector: '' }\n ) {\n this.host = host;\n this.selector = selector;\n this.observer = new MutationObserver(this.mutationCallback);\n // Add the controller after the MutationObserver has been created in preparation\n // for the `hostConnected`/`hostDisconnected` callbacks to be run.\n this.host.addController(this);\n }\n\n protected mutationCallback: MutationCallback = (mutationList) => {\n let needsResolution = false;\n mutationList.forEach((mutation) => {\n if (needsResolution) return;\n if (mutation.type === 'childList') {\n const currentElementRemoved =\n this.element &&\n [...mutation.removedNodes].includes(this.element);\n const matchingElementAdded =\n !!this.selector &&\n ([...mutation.addedNodes] as HTMLElement[]).some(\n this.elementIsSelected\n );\n needsResolution =\n needsResolution ||\n currentElementRemoved ||\n matchingElementAdded;\n }\n if (mutation.type === 'attributes') {\n const attributeChangedOnCurrentElement =\n mutation.target === this.element;\n const attributeChangedOnMatchingElement =\n !!this.selector &&\n this.elementIsSelected(mutation.target as HTMLElement);\n needsResolution =\n needsResolution ||\n attributeChangedOnCurrentElement ||\n attributeChangedOnMatchingElement;\n }\n });\n if (needsResolution) {\n this.resolveElement();\n }\n };\n\n public hostConnected(): void {\n this.resolveElement();\n this.observer.observe(this.host.getRootNode(), {\n subtree: true,\n childList: true,\n attributes: true,\n });\n }\n\n public hostDisconnected(): void {\n this.releaseElement();\n this.observer.disconnect();\n }\n\n private resolveElement(): void {\n if (!this.selector) {\n this.releaseElement();\n return;\n }\n\n const parent = this.host.getRootNode() as ShadowRoot;\n this.element = this.selectorIsId\n ? (parent.getElementById(this.selectorAsId) as HTMLElement)\n : (parent.querySelector(this.selector) as HTMLElement);\n }\n\n private releaseElement(): void {\n this.element = null;\n }\n\n private elementIsSelected = (el: HTMLElement): boolean => {\n return this.selectorIsId\n ? el?.id === this.selectorAsId\n : el?.matches?.(this.selector);\n };\n}\n"],
5
- "mappings": ";AAaO,aAAM,+BAA+B,OAAO,0BAA0B;AAEtE,aAAM,4BAA0D;AAAA,EAyCnE,YACI,MACA,EAAE,SAAS,IAA0B,EAAE,UAAU,GAAG,GACtD;AA9BF,SAAQ,WAA+B;AAiBvC,SAAQ,YAAY;AAsBpB,SAAU,mBAAqC,CAAC,iBAAiB;AAC7D,UAAI,kBAAkB;AACtB,mBAAa,QAAQ,CAAC,aAAa;AAC/B,YAAI,gBAAiB;AACrB,YAAI,SAAS,SAAS,aAAa;AAC/B,gBAAM,wBACF,KAAK,WACL,CAAC,GAAG,SAAS,YAAY,EAAE,SAAS,KAAK,OAAO;AACpD,gBAAM,uBACF,CAAC,CAAC,KAAK,YACN,CAAC,GAAG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AAQ,KAAK,KAAK,YAAY,GAAG;AAAA,MAC3C,SAAS;AAAA,MACT,WAAW;AAAA,MACX,YAAY;AAAA,IAChB,CAAC;AAAA,EACL;AAAA,EAEO,mBAAyB;AAC5B,SAAK,eAAe;AACpB,SAAK,SAAS,WAAW;AAAA,EAC7B;AAAA,EAEQ,iBAAuB;AAC3B,QAAI,CAAC,KAAK,UAAU;AAChB,WAAK,eAAe;AACpB;AAAA,IACJ;AAEA,UAAM,SAAS,KAAK,KAAK,YAAY;AACrC,SAAK,UAAU,KAAK,eACb,OAAO,eAAe,KAAK,YAAY,IACvC,OAAO,cAAc,KAAK,QAAQ;AAAA,EAC7C;AAAA,EAEQ,iBAAuB;AAC3B,SAAK,UAAU;AAAA,EACnB;AAOJ;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";export const elementResolverUpdatedSymbol=Symbol("element resolver updated");export class ElementResolutionController{constructor(e,{selector:t}={selector:""}){this._element=null;this._selector="";this.mutationCallback=e=>{let t=!1;e.forEach(s=>{if(!t){if(s.type==="childList"){const r=this.element&&[...s.removedNodes].includes(this.element),l=!!this.selector&&[...s.addedNodes].some(this.elementIsSelected);t=t||r||l}if(s.type==="attributes"){const r=s.target===this.element,l=!!this.selector&&this.elementIsSelected(s.target);t=t||r||l}}}),t&&this.resolveElement()};this.elementIsSelected=e=>{var t;return this.selectorIsId?(e==null?void 0:e.id)===this.selectorAsId:(t=e==null?void 0:e.matches)==null?void 0:t.call(e,this.selector)};this.host=e,this.selector=t,this.observer=new MutationObserver(this.mutationCallback),this.host.addController(this)}get element(){return this._element}set element(e){if(e===this.element)return;const t=this.element;this._element=e,this.host.requestUpdate(elementResolverUpdatedSymbol,t)}get selector(){return this._selector}set selector(e){e!==this.selector&&(this.releaseElement(),this._selector=e,this.resolveElement())}get selectorAsId(){return this.selector.slice(1)}get selectorIsId(){return!!this.selector&&this.selector.startsWith("#")}hostConnected(){this.resolveElement(),this.observer.observe(this.host.getRootNode(),{subtree:!0,childList:!0,attributes:!0})}hostDisconnected(){this.releaseElement(),this.observer.disconnect()}resolveElement(){if(!this.selector){this.releaseElement();return}const e=this.host.getRootNode();this.element=this.selectorIsId?e.getElementById(this.selectorAsId):e.querySelector(this.selector)}releaseElement(){this.element=null}}
2
- //# sourceMappingURL=ElementResolution.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["ElementResolution.ts"],
4
- "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nexport const elementResolverUpdatedSymbol = Symbol('element resolver updated');\n\nexport class ElementResolutionController implements ReactiveController {\n get element(): HTMLElement | null {\n return this._element;\n }\n\n set element(element: HTMLElement | null) {\n if (element === this.element) return;\n const previous = this.element;\n this._element = element;\n // requestUpdate leveraging the exported Symbol() so that the\n // changes can be easily tracked in the host element.\n this.host.requestUpdate(elementResolverUpdatedSymbol, previous);\n }\n\n private _element: HTMLElement | null = null;\n\n private host!: ReactiveElement;\n\n private observer!: MutationObserver;\n\n get selector(): string {\n return this._selector;\n }\n\n set selector(selector: string) {\n if (selector === this.selector) return;\n this.releaseElement();\n this._selector = selector;\n this.resolveElement();\n }\n\n private _selector = '';\n\n get selectorAsId(): string {\n return this.selector.slice(1);\n }\n\n get selectorIsId(): boolean {\n return !!this.selector && this.selector.startsWith('#');\n }\n\n constructor(\n host: ReactiveElement,\n { selector }: { selector: string } = { selector: '' }\n ) {\n this.host = host;\n this.selector = selector;\n this.observer = new MutationObserver(this.mutationCallback);\n // Add the controller after the MutationObserver has been created in preparation\n // for the `hostConnected`/`hostDisconnected` callbacks to be run.\n this.host.addController(this);\n }\n\n protected mutationCallback: MutationCallback = (mutationList) => {\n let needsResolution = false;\n mutationList.forEach((mutation) => {\n if (needsResolution) return;\n if (mutation.type === 'childList') {\n const currentElementRemoved =\n this.element &&\n [...mutation.removedNodes].includes(this.element);\n const matchingElementAdded =\n !!this.selector &&\n ([...mutation.addedNodes] as HTMLElement[]).some(\n this.elementIsSelected\n );\n needsResolution =\n needsResolution ||\n currentElementRemoved ||\n matchingElementAdded;\n }\n if (mutation.type === 'attributes') {\n const attributeChangedOnCurrentElement =\n mutation.target === this.element;\n const attributeChangedOnMatchingElement =\n !!this.selector &&\n this.elementIsSelected(mutation.target as HTMLElement);\n needsResolution =\n needsResolution ||\n attributeChangedOnCurrentElement ||\n attributeChangedOnMatchingElement;\n }\n });\n if (needsResolution) {\n this.resolveElement();\n }\n };\n\n public hostConnected(): void {\n this.resolveElement();\n this.observer.observe(this.host.getRootNode(), {\n subtree: true,\n childList: true,\n attributes: true,\n });\n }\n\n public hostDisconnected(): void {\n this.releaseElement();\n this.observer.disconnect();\n }\n\n private resolveElement(): void {\n if (!this.selector) {\n this.releaseElement();\n return;\n }\n\n const parent = this.host.getRootNode() as ShadowRoot;\n this.element = this.selectorIsId\n ? (parent.getElementById(this.selectorAsId) as HTMLElement)\n : (parent.querySelector(this.selector) as HTMLElement);\n }\n\n private releaseElement(): void {\n this.element = null;\n }\n\n private elementIsSelected = (el: HTMLElement): boolean => {\n return this.selectorIsId\n ? el?.id === this.selectorAsId\n : el?.matches?.(this.selector);\n };\n}\n"],
5
- "mappings": "aAaO,aAAM,6BAA+B,OAAO,0BAA0B,EAEtE,aAAM,2BAA0D,CAyCnE,YACIA,EACA,CAAE,SAAAC,CAAS,EAA0B,CAAE,SAAU,EAAG,EACtD,CA9BF,KAAQ,SAA+B,KAiBvC,KAAQ,UAAY,GAsBpB,KAAU,iBAAsCC,GAAiB,CAC7D,IAAIC,EAAkB,GACtBD,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,UAAY,KAAK,SAAS,WAAW,GAAG,CAC1D,CAiDO,eAAsB,CACzB,KAAK,eAAe,EACpB,KAAK,SAAS,QAAQ,KAAK,KAAK,YAAY,EAAG,CAC3C,QAAS,GACT,UAAW,GACX,WAAY,EAChB,CAAC,CACL,CAEO,kBAAyB,CAC5B,KAAK,eAAe,EACpB,KAAK,SAAS,WAAW,CAC7B,CAEQ,gBAAuB,CAC3B,GAAI,CAAC,KAAK,SAAU,CAChB,KAAK,eAAe,EACpB,MACJ,CAEA,MAAMY,EAAS,KAAK,KAAK,YAAY,EACrC,KAAK,QAAU,KAAK,aACbA,EAAO,eAAe,KAAK,YAAY,EACvCA,EAAO,cAAc,KAAK,QAAQ,CAC7C,CAEQ,gBAAuB,CAC3B,KAAK,QAAU,IACnB,CAOJ",
6
- "names": ["host", "selector", "mutationList", "needsResolution", "mutation", "currentElementRemoved", "matchingElementAdded", "attributeChangedOnCurrentElement", "attributeChangedOnMatchingElement", "el", "_a", "element", "previous", "parent"]
7
- }