@elastic/eui-theme-common 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +6 -0
- package/README.md +11 -0
- package/lib/cjs/.tsbuildinfo +1 -0
- package/lib/cjs/global_styling/functions/index.d.ts +2 -0
- package/lib/cjs/global_styling/functions/index.d.ts.map +1 -0
- package/lib/cjs/global_styling/functions/index.js +22 -0
- package/lib/cjs/global_styling/functions/index.js.map +1 -0
- package/lib/cjs/global_styling/functions/size.d.ts +13 -0
- package/lib/cjs/global_styling/functions/size.d.ts.map +1 -0
- package/lib/cjs/global_styling/functions/size.js +42 -0
- package/lib/cjs/global_styling/functions/size.js.map +1 -0
- package/lib/cjs/global_styling/index.d.ts +4 -0
- package/lib/cjs/global_styling/index.d.ts.map +1 -0
- package/lib/cjs/global_styling/index.js +44 -0
- package/lib/cjs/global_styling/index.js.map +1 -0
- package/lib/cjs/global_styling/types.d.ts +66 -0
- package/lib/cjs/global_styling/types.d.ts.map +1 -0
- package/lib/cjs/global_styling/types.js +21 -0
- package/lib/cjs/global_styling/types.js.map +1 -0
- package/lib/cjs/global_styling/variables/_colors_vis.d.ts +13 -0
- package/lib/cjs/global_styling/variables/_colors_vis.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/_colors_vis.js +69 -0
- package/lib/cjs/global_styling/variables/_colors_vis.js.map +1 -0
- package/lib/cjs/global_styling/variables/animations.d.ts +36 -0
- package/lib/cjs/global_styling/variables/animations.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/animations.js +38 -0
- package/lib/cjs/global_styling/variables/animations.js.map +1 -0
- package/lib/cjs/global_styling/variables/borders.d.ts +61 -0
- package/lib/cjs/global_styling/variables/borders.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/borders.js +7 -0
- package/lib/cjs/global_styling/variables/borders.js.map +1 -0
- package/lib/cjs/global_styling/variables/breakpoint.d.ts +15 -0
- package/lib/cjs/global_styling/variables/breakpoint.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/breakpoint.js +23 -0
- package/lib/cjs/global_styling/variables/breakpoint.js.map +1 -0
- package/lib/cjs/global_styling/variables/buttons.d.ts +44 -0
- package/lib/cjs/global_styling/variables/buttons.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/buttons.js +7 -0
- package/lib/cjs/global_styling/variables/buttons.js.map +1 -0
- package/lib/cjs/global_styling/variables/colors.d.ts +245 -0
- package/lib/cjs/global_styling/variables/colors.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/colors.js +7 -0
- package/lib/cjs/global_styling/variables/colors.js.map +1 -0
- package/lib/cjs/global_styling/variables/components.d.ts +69 -0
- package/lib/cjs/global_styling/variables/components.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/components.js +7 -0
- package/lib/cjs/global_styling/variables/components.js.map +1 -0
- package/lib/cjs/global_styling/variables/forms.d.ts +20 -0
- package/lib/cjs/global_styling/variables/forms.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/forms.js +7 -0
- package/lib/cjs/global_styling/variables/forms.js.map +1 -0
- package/lib/cjs/global_styling/variables/index.d.ts +14 -0
- package/lib/cjs/global_styling/variables/index.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/index.js +154 -0
- package/lib/cjs/global_styling/variables/index.js.map +1 -0
- package/lib/cjs/global_styling/variables/levels.d.ts +39 -0
- package/lib/cjs/global_styling/variables/levels.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/levels.js +33 -0
- package/lib/cjs/global_styling/variables/levels.js.map +1 -0
- package/lib/cjs/global_styling/variables/shadow.d.ts +11 -0
- package/lib/cjs/global_styling/variables/shadow.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/shadow.js +27 -0
- package/lib/cjs/global_styling/variables/shadow.js.map +1 -0
- package/lib/cjs/global_styling/variables/size.d.ts +26 -0
- package/lib/cjs/global_styling/variables/size.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/size.js +17 -0
- package/lib/cjs/global_styling/variables/size.js.map +1 -0
- package/lib/cjs/global_styling/variables/states.d.ts +25 -0
- package/lib/cjs/global_styling/variables/states.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/states.js +7 -0
- package/lib/cjs/global_styling/variables/states.js.map +1 -0
- package/lib/cjs/global_styling/variables/typography.d.ts +93 -0
- package/lib/cjs/global_styling/variables/typography.d.ts.map +1 -0
- package/lib/cjs/global_styling/variables/typography.js +48 -0
- package/lib/cjs/global_styling/variables/typography.js.map +1 -0
- package/lib/cjs/index.d.ts +4 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +44 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types.d.ts +33 -0
- package/lib/cjs/types.d.ts.map +1 -0
- package/lib/cjs/types.js +7 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/utils.d.ts +104 -0
- package/lib/cjs/utils.d.ts.map +1 -0
- package/lib/cjs/utils.js +382 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/cjs/utils.test.js +411 -0
- package/lib/cjs/utils.test.js.map +1 -0
- package/lib/esm/.tsbuildinfo +1 -0
- package/lib/esm/global_styling/functions/index.d.ts +1 -0
- package/lib/esm/global_styling/functions/index.js +9 -0
- package/lib/esm/global_styling/functions/index.js.map +1 -0
- package/lib/esm/global_styling/functions/size.d.ts +12 -0
- package/lib/esm/global_styling/functions/size.js +21 -0
- package/lib/esm/global_styling/functions/size.js.map +1 -0
- package/lib/esm/global_styling/index.d.ts +3 -0
- package/lib/esm/global_styling/index.js +11 -0
- package/lib/esm/global_styling/index.js.map +1 -0
- package/lib/esm/global_styling/types.d.ts +65 -0
- package/lib/esm/global_styling/types.js +13 -0
- package/lib/esm/global_styling/types.js.map +1 -0
- package/lib/esm/global_styling/variables/_colors_vis.d.ts +12 -0
- package/lib/esm/global_styling/variables/_colors_vis.js +60 -0
- package/lib/esm/global_styling/variables/_colors_vis.js.map +1 -0
- package/lib/esm/global_styling/variables/animations.d.ts +35 -0
- package/lib/esm/global_styling/variables/animations.js +25 -0
- package/lib/esm/global_styling/variables/animations.js.map +1 -0
- package/lib/esm/global_styling/variables/borders.d.ts +60 -0
- package/lib/esm/global_styling/variables/borders.js +9 -0
- package/lib/esm/global_styling/variables/borders.js.map +1 -0
- package/lib/esm/global_styling/variables/breakpoint.d.ts +14 -0
- package/lib/esm/global_styling/variables/breakpoint.js +9 -0
- package/lib/esm/global_styling/variables/breakpoint.js.map +1 -0
- package/lib/esm/global_styling/variables/buttons.d.ts +43 -0
- package/lib/esm/global_styling/variables/buttons.js +9 -0
- package/lib/esm/global_styling/variables/buttons.js.map +1 -0
- package/lib/esm/global_styling/variables/colors.d.ts +244 -0
- package/lib/esm/global_styling/variables/colors.js +9 -0
- package/lib/esm/global_styling/variables/colors.js.map +1 -0
- package/lib/esm/global_styling/variables/components.d.ts +68 -0
- package/lib/esm/global_styling/variables/components.js +9 -0
- package/lib/esm/global_styling/variables/components.js.map +1 -0
- package/lib/esm/global_styling/variables/forms.d.ts +19 -0
- package/lib/esm/global_styling/variables/forms.js +9 -0
- package/lib/esm/global_styling/variables/forms.js.map +1 -0
- package/lib/esm/global_styling/variables/index.d.ts +13 -0
- package/lib/esm/global_styling/variables/index.js +21 -0
- package/lib/esm/global_styling/variables/index.js.map +1 -0
- package/lib/esm/global_styling/variables/levels.d.ts +38 -0
- package/lib/esm/global_styling/variables/levels.js +34 -0
- package/lib/esm/global_styling/variables/levels.js.map +1 -0
- package/lib/esm/global_styling/variables/shadow.d.ts +10 -0
- package/lib/esm/global_styling/variables/shadow.js +19 -0
- package/lib/esm/global_styling/variables/shadow.js.map +1 -0
- package/lib/esm/global_styling/variables/size.d.ts +25 -0
- package/lib/esm/global_styling/variables/size.js +20 -0
- package/lib/esm/global_styling/variables/size.js.map +1 -0
- package/lib/esm/global_styling/variables/states.d.ts +24 -0
- package/lib/esm/global_styling/variables/states.js +9 -0
- package/lib/esm/global_styling/variables/states.js.map +1 -0
- package/lib/esm/global_styling/variables/typography.d.ts +92 -0
- package/lib/esm/global_styling/variables/typography.js +35 -0
- package/lib/esm/global_styling/variables/typography.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +11 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types.d.ts +32 -0
- package/lib/esm/types.js +9 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils.d.ts +103 -0
- package/lib/esm/utils.js +300 -0
- package/lib/esm/utils.js.map +1 -0
- package/lib/esm/utils.test.d.ts +1 -0
- package/lib/esm/utils.test.js +233 -0
- package/lib/esm/utils.test.js.map +1 -0
- package/licenses/ELASTIC-LICENSE-2.0.md +93 -0
- package/licenses/SSPL-LICENSE.md +557 -0
- package/package.json +78 -0
- package/src/global_styling/functions/_colors.scss +138 -0
- package/src/global_styling/functions/_index.scss +5 -0
- package/src/global_styling/functions/_math.scss +1 -0
- package/src/global_styling/functions/_math_pow.scss +82 -0
- package/src/global_styling/index.scss +18 -0
- package/src/global_styling/mixins/_button.scss +149 -0
- package/src/global_styling/mixins/_form.scss +273 -0
- package/src/global_styling/mixins/_helpers.scss +126 -0
- package/src/global_styling/mixins/_index.scss +14 -0
- package/src/global_styling/mixins/_link.scss +11 -0
- package/src/global_styling/mixins/_loading.scss +6 -0
- package/src/global_styling/mixins/_panel.scss +55 -0
- package/src/global_styling/mixins/_range.scss +62 -0
- package/src/global_styling/mixins/_responsive.scss +44 -0
- package/src/global_styling/mixins/_shadow.scss +108 -0
- package/src/global_styling/mixins/_size.scss +4 -0
- package/src/global_styling/mixins/_states.scss +50 -0
- package/src/global_styling/mixins/_tool_tip.scss +25 -0
- package/src/global_styling/mixins/_typography.scss +167 -0
- package/src/global_styling/react_date_picker/_date_picker.scss +772 -0
- package/src/global_styling/react_date_picker/_index.scss +2 -0
- package/src/global_styling/react_date_picker/_variables.scss +1 -0
- package/src/global_styling/utility/_animations.scss +55 -0
- package/src/global_styling/utility/_index.scss +1 -0
- package/src/global_styling/variables/_animations.scss +13 -0
- package/src/global_styling/variables/_borders.scss +11 -0
- package/src/global_styling/variables/_buttons.scss +18 -0
- package/src/global_styling/variables/_colors_vis.scss +72 -0
- package/src/global_styling/variables/_font_weight.scss +10 -0
- package/src/global_styling/variables/_form.scss +8 -0
- package/src/global_styling/variables/_index.scss +23 -0
- package/src/global_styling/variables/_responsive.scss +9 -0
- package/src/global_styling/variables/_shadows.scss +2 -0
- package/src/global_styling/variables/_size.scss +15 -0
- package/src/global_styling/variables/_states.scss +14 -0
- package/src/global_styling/variables/_typography.scss +75 -0
- package/src/global_styling/variables/_z_index.scss +34 -0
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.array.for-each.js");
|
|
4
|
+
require("core-js/modules/es.object.define-property.js");
|
|
5
|
+
require("core-js/modules/es.object.keys.js");
|
|
6
|
+
require("core-js/modules/es.object.to-string.js");
|
|
7
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
var _global_styling = require("./global_styling");
|
|
12
|
+
Object.keys(_global_styling).forEach(function (key) {
|
|
13
|
+
if (key === "default" || key === "__esModule") return;
|
|
14
|
+
if (key in exports && exports[key] === _global_styling[key]) return;
|
|
15
|
+
Object.defineProperty(exports, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return _global_styling[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
var _types = require("./types");
|
|
23
|
+
Object.keys(_types).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
26
|
+
Object.defineProperty(exports, key, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _types[key];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
var _utils = require("./utils");
|
|
34
|
+
Object.keys(_utils).forEach(function (key) {
|
|
35
|
+
if (key === "default" || key === "__esModule") return;
|
|
36
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
37
|
+
Object.defineProperty(exports, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _utils[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_global_styling","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_types","_utils"],"sources":["../../src/index.ts"],"sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0 and the Server Side Public License, v 1; you may not use this file except\n * in compliance with, at your election, the Elastic License 2.0 or the Server\n * Side Public License, v 1.\n */\n\nexport * from './global_styling';\n\nexport * from './types';\nexport * from './utils';\n"],"mappings":";;;;;;;;;;AAQA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,MAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,MAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,MAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,MAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like `keyof typeof`, but for getting values instead of keys
|
|
3
|
+
* ValueOf<typeof {key1: 'value1', key2: 'value2'}>
|
|
4
|
+
* Results in `'value1' | 'value2'`
|
|
5
|
+
*/
|
|
6
|
+
export declare type ValueOf<T> = T[keyof T];
|
|
7
|
+
/**
|
|
8
|
+
* Replaces all properties on any type as optional, includes nested types
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* interface Person {
|
|
13
|
+
* name: string;
|
|
14
|
+
* age?: number;
|
|
15
|
+
* spouse: Person;
|
|
16
|
+
* children: Person[];
|
|
17
|
+
* }
|
|
18
|
+
* type PartialPerson = RecursivePartial<Person>;
|
|
19
|
+
* // results in
|
|
20
|
+
* interface PartialPerson {
|
|
21
|
+
* name?: string;
|
|
22
|
+
* age?: number;
|
|
23
|
+
* spouse?: RecursivePartial<Person>;
|
|
24
|
+
* children?: RecursivePartial<Person>[]
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare type RecursivePartial<T> = {
|
|
29
|
+
[P in keyof T]?: T[P] extends NonAny[] ? T[P] : T[P] extends readonly NonAny[] ? T[P] : T[P] extends Array<infer U> ? Array<RecursivePartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<RecursivePartial<U>> : T[P] extends Set<infer V> ? Set<RecursivePartial<V>> : T[P] extends Map<infer K, infer V> ? Map<K, RecursivePartial<V>> : T[P] extends NonAny ? T[P] : RecursivePartial<T[P]>;
|
|
30
|
+
};
|
|
31
|
+
declare type NonAny = number | boolean | string | symbol | null;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,GAClC,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,GAC9B,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAC3B,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAC1B,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GACnC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAClC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GACzB,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACxB,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAClC,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAC3B,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACnB,CAAC,CAAC,CAAC,CAAC,GACJ,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3B,CAAC;AACF,aAAK,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC"}
|
package/lib/cjs/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0 and the Server Side Public License, v 1; you may not use this file except\n * in compliance with, at your election, the Elastic License 2.0 or the Server\n * Side Public License, v 1.\n */\n\n/* TODO: duplicated types from /eui/src/components/common - extract to shared location */\n\n/**\n * Like `keyof typeof`, but for getting values instead of keys\n * ValueOf<typeof {key1: 'value1', key2: 'value2'}>\n * Results in `'value1' | 'value2'`\n */\nexport type ValueOf<T> = T[keyof T];\n\n/**\n * Replaces all properties on any type as optional, includes nested types\n *\n * @example\n * ```ts\n * interface Person {\n * name: string;\n * age?: number;\n * spouse: Person;\n * children: Person[];\n * }\n * type PartialPerson = RecursivePartial<Person>;\n * // results in\n * interface PartialPerson {\n * name?: string;\n * age?: number;\n * spouse?: RecursivePartial<Person>;\n * children?: RecursivePartial<Person>[]\n * }\n * ```\n */\nexport type RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends NonAny[] // checks for nested any[]\n ? T[P]\n : T[P] extends readonly NonAny[] // checks for nested ReadonlyArray<any>\n ? T[P]\n : T[P] extends Array<infer U>\n ? Array<RecursivePartial<U>>\n : T[P] extends ReadonlyArray<infer U>\n ? ReadonlyArray<RecursivePartial<U>>\n : T[P] extends Set<infer V> // checks for Sets\n ? Set<RecursivePartial<V>>\n : T[P] extends Map<infer K, infer V> // checks for Maps\n ? Map<K, RecursivePartial<V>>\n : T[P] extends NonAny // checks for primitive values\n ? T[P]\n : RecursivePartial<T[P]>; // recurse for all non-array and non-primitive values\n};\ntype NonAny = number | boolean | string | symbol | null;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { EuiThemeColorMode, EuiThemeColorModeStandard, EuiThemeSystem, EuiThemeShape, EuiThemeComputed } from './global_styling';
|
|
2
|
+
export declare const DEFAULT_COLOR_MODE: "LIGHT";
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether the provided color mode is `inverse`
|
|
5
|
+
* @param {string} colorMode - `light`, `dark`, or `inverse`
|
|
6
|
+
*/
|
|
7
|
+
export declare const isInverseColorMode: (colorMode?: string | undefined) => colorMode is "INVERSE";
|
|
8
|
+
/**
|
|
9
|
+
* Returns the color mode configured in the current EuiThemeProvider.
|
|
10
|
+
* Returns the parent color mode if none is explicity set.
|
|
11
|
+
* @param {string} colorMode - `light`, `dark`, or `inverse`
|
|
12
|
+
* @param {string} parentColorMode - `LIGHT` or `DARK`; used as the fallback
|
|
13
|
+
*/
|
|
14
|
+
export declare const getColorMode: (colorMode?: EuiThemeColorMode | undefined, parentColorMode?: EuiThemeColorModeStandard | undefined) => EuiThemeColorModeStandard;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a value at a given path on an object.
|
|
17
|
+
* If `colorMode` is provided, will scope the value to the appropriate color mode key (LIGHT\DARK)
|
|
18
|
+
* @param {object} model - Object
|
|
19
|
+
* @param {string} _path - Dot-notated string to a path on the object
|
|
20
|
+
* @param {string} colorMode - `light` or `dark`
|
|
21
|
+
*/
|
|
22
|
+
export declare const getOn: (model: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}, _path: string, colorMode?: EuiThemeColorModeStandard | undefined) => {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Sets a value at a given path on an object.
|
|
29
|
+
* @param {object} model - Object
|
|
30
|
+
* @param {string} _path - Dot-notated string to a path on the object
|
|
31
|
+
* @param {any} string - The value to set
|
|
32
|
+
*/
|
|
33
|
+
export declare const setOn: (model: {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}, _path: string, value: any) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a class to store the `computer` method and its eventual parameters.
|
|
38
|
+
* Allows for on-demand computation with up-to-date parameters via `getValue` method.
|
|
39
|
+
* @constructor
|
|
40
|
+
* @param {function} computer - Function to be computed
|
|
41
|
+
* @param {string | array} dependencies - Dependencies passed to the `computer` as parameters
|
|
42
|
+
*/
|
|
43
|
+
export declare class Computed<T> {
|
|
44
|
+
computer: (...values: any[]) => T;
|
|
45
|
+
dependencies: string | string[];
|
|
46
|
+
constructor(computer: (...values: any[]) => T, dependencies?: string | string[]);
|
|
47
|
+
/**
|
|
48
|
+
* Executes the `computer` method with the current state of the theme
|
|
49
|
+
* by taking into account previously computed values and modifications.
|
|
50
|
+
* @param {Proxy | object} base - Computed or uncomputed theme
|
|
51
|
+
* @param {Proxy | object} modifications - Theme value overrides
|
|
52
|
+
* @param {object} working - Partially computed theme
|
|
53
|
+
* @param {string} colorMode - `light` or `dark`
|
|
54
|
+
*/
|
|
55
|
+
getValue(base: EuiThemeSystem | EuiThemeShape | null, modifications: import("./types").RecursivePartial<EuiThemeShape> | undefined, working: Partial<EuiThemeComputed>, colorMode?: EuiThemeColorModeStandard): T;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns a Class (`Computed`) that stores the arbitrary computer method
|
|
59
|
+
* and references to its optional dependecies.
|
|
60
|
+
* @param {function} computer - Arbitrary method to be called at compute time.
|
|
61
|
+
* @param {string | array} dependencies - Values that will be provided to `computer` at compute time.
|
|
62
|
+
*/
|
|
63
|
+
export declare function computed<T>(computer: (value: EuiThemeComputed) => T): T;
|
|
64
|
+
export declare function computed<T>(computer: (value: any[]) => T, dependencies: string[]): T;
|
|
65
|
+
export declare function computed<T>(computer: (value: any) => T, dependencies: string): T;
|
|
66
|
+
/**
|
|
67
|
+
* Takes an uncomputed theme, and computes and returns all values taking
|
|
68
|
+
* into consideration value overrides and configured color mode.
|
|
69
|
+
* Overrides take precedence, and only values in the current color mode
|
|
70
|
+
* are computed and returned.
|
|
71
|
+
* @param {Proxy} base - Object to transform into Proxy
|
|
72
|
+
* @param {Proxy | object} over - Unique identifier or name
|
|
73
|
+
* @param {string} colorMode - `light` or `dark`
|
|
74
|
+
*/
|
|
75
|
+
export declare const getComputed: <T = EuiThemeShape>(base: EuiThemeSystem<T>, over: Partial<EuiThemeSystem<T>>, colorMode: EuiThemeColorModeStandard) => EuiThemeComputed<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Builds a Proxy with a custom `handler` designed to self-reference values
|
|
78
|
+
* and prevent arbitrary value overrides.
|
|
79
|
+
* @param {object} model - Object to transform into Proxy
|
|
80
|
+
* @param {string} key - Unique identifier or name
|
|
81
|
+
*/
|
|
82
|
+
export declare const buildTheme: <T extends {}>(model: T, key: string) => {
|
|
83
|
+
model: T;
|
|
84
|
+
root: T;
|
|
85
|
+
key: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Deeply merges two objects, using `source` values whenever possible.
|
|
89
|
+
* @param {object} _target - Object with fallback values
|
|
90
|
+
* @param {object} source - Object with desired values
|
|
91
|
+
*/
|
|
92
|
+
export declare const mergeDeep: (_target: {
|
|
93
|
+
[key: string]: any;
|
|
94
|
+
}, source?: {
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
}) => {
|
|
97
|
+
[key: string]: any;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Returns token name string based on passed dynamic variants
|
|
101
|
+
* and additional prefix/suffix
|
|
102
|
+
*/
|
|
103
|
+
export declare const getTokenName: (prefix: string, variant: string, suffix?: string | undefined) => string;
|
|
104
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,iBAAiB,EAEjB,yBAAyB,EAEzB,cAAc,EACd,aAAa,EACb,gBAAgB,EAGjB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,kBAAkB,SAA6B,CAAC;AAQ7D;;;GAGG;AACH,eAAO,MAAM,kBAAkB,4DAI9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,0GAGtB,yBAeF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;;UAET,MAAM;;aAgCd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;UAET,MAAM,SACN,GAAG,YAgBX,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,QAAQ,CAAC,CAAC;IAEZ,QAAQ,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE;gBAD/B,QAAQ,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,EACjC,YAAY,GAAE,MAAM,GAAG,MAAM,EAAO;IAG7C;;;;;;;OAOG;IACH,QAAQ,CACN,IAAI,EAAE,cAAc,GAAG,aAAa,GAAG,IAAI,EAC3C,aAAa,+DAA4B,EACzC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAClC,SAAS,CAAC,EAAE,yBAAyB;CAsBxC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,CAAC,GAAG,CAAC,CAAC;AACzE,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,EAC7B,YAAY,EAAE,MAAM,EAAE,GACrB,CAAC,CAAC;AACL,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,EAC3B,YAAY,EAAE,MAAM,GACnB,CAAC,CAAC;AAkBL;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,4FAGX,yBAAyB,wBAgDrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,gCAAiC,MAAM;;;;CA+E7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;CAsBrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,WACL,MAAM,wCAShB,CAAC"}
|
package/lib/cjs/utils.js
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.to-primitive.js");
|
|
4
|
+
require("core-js/modules/es.array.filter.js");
|
|
5
|
+
require("core-js/modules/es.array.from.js");
|
|
6
|
+
require("core-js/modules/es.date.to-primitive.js");
|
|
7
|
+
require("core-js/modules/es.date.to-string.js");
|
|
8
|
+
require("core-js/modules/es.function.name.js");
|
|
9
|
+
require("core-js/modules/es.number.constructor.js");
|
|
10
|
+
require("core-js/modules/es.object.define-properties.js");
|
|
11
|
+
require("core-js/modules/es.object.define-property.js");
|
|
12
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
13
|
+
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
14
|
+
require("core-js/modules/es.regexp.test.js");
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
exports.buildTheme = exports.DEFAULT_COLOR_MODE = exports.Computed = void 0;
|
|
19
|
+
exports.computed = computed;
|
|
20
|
+
exports.setOn = exports.mergeDeep = exports.isInverseColorMode = exports.getTokenName = exports.getOn = exports.getComputed = exports.getColorMode = void 0;
|
|
21
|
+
require("core-js/modules/es.symbol.js");
|
|
22
|
+
require("core-js/modules/es.symbol.description.js");
|
|
23
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
24
|
+
require("core-js/modules/es.array.concat.js");
|
|
25
|
+
require("core-js/modules/es.array.for-each.js");
|
|
26
|
+
require("core-js/modules/es.array.includes.js");
|
|
27
|
+
require("core-js/modules/es.array.is-array.js");
|
|
28
|
+
require("core-js/modules/es.array.iterator.js");
|
|
29
|
+
require("core-js/modules/es.array.map.js");
|
|
30
|
+
require("core-js/modules/es.array.slice.js");
|
|
31
|
+
require("core-js/modules/es.object.keys.js");
|
|
32
|
+
require("core-js/modules/es.object.to-string.js");
|
|
33
|
+
require("core-js/modules/es.object.values.js");
|
|
34
|
+
require("core-js/modules/es.reflect.define-property.js");
|
|
35
|
+
require("core-js/modules/es.reflect.get-own-property-descriptor.js");
|
|
36
|
+
require("core-js/modules/es.reflect.get-prototype-of.js");
|
|
37
|
+
require("core-js/modules/es.reflect.has.js");
|
|
38
|
+
require("core-js/modules/es.reflect.is-extensible.js");
|
|
39
|
+
require("core-js/modules/es.reflect.own-keys.js");
|
|
40
|
+
require("core-js/modules/es.reflect.prevent-extensions.js");
|
|
41
|
+
require("core-js/modules/es.reflect.set-prototype-of.js");
|
|
42
|
+
require("core-js/modules/es.regexp.constructor.js");
|
|
43
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
44
|
+
require("core-js/modules/es.regexp.sticky.js");
|
|
45
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
46
|
+
require("core-js/modules/es.string.includes.js");
|
|
47
|
+
require("core-js/modules/es.string.iterator.js");
|
|
48
|
+
require("core-js/modules/es.string.replace.js");
|
|
49
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
50
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
51
|
+
var _global_styling = require("./global_styling");
|
|
52
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
53
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
54
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
55
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
56
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
57
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
58
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
59
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
60
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
61
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
62
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
63
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
64
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
65
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
66
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } /*
|
|
67
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
68
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
69
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
70
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
71
|
+
* Side Public License, v 1.
|
|
72
|
+
*/
|
|
73
|
+
var DEFAULT_COLOR_MODE = exports.DEFAULT_COLOR_MODE = _global_styling.COLOR_MODES_STANDARD.light;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns whether the parameter is an object
|
|
77
|
+
* @param {any} obj - Anything
|
|
78
|
+
*/
|
|
79
|
+
var isObject = function isObject(obj) {
|
|
80
|
+
return obj && _typeof(obj) === 'object';
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns whether the provided color mode is `inverse`
|
|
85
|
+
* @param {string} colorMode - `light`, `dark`, or `inverse`
|
|
86
|
+
*/
|
|
87
|
+
var isInverseColorMode = exports.isInverseColorMode = function isInverseColorMode(colorMode) {
|
|
88
|
+
return colorMode === _global_styling.COLOR_MODES_INVERSE;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns the color mode configured in the current EuiThemeProvider.
|
|
93
|
+
* Returns the parent color mode if none is explicity set.
|
|
94
|
+
* @param {string} colorMode - `light`, `dark`, or `inverse`
|
|
95
|
+
* @param {string} parentColorMode - `LIGHT` or `DARK`; used as the fallback
|
|
96
|
+
*/
|
|
97
|
+
var getColorMode = exports.getColorMode = function getColorMode(colorMode, parentColorMode) {
|
|
98
|
+
if (colorMode == null) {
|
|
99
|
+
return parentColorMode || DEFAULT_COLOR_MODE;
|
|
100
|
+
}
|
|
101
|
+
var mode = colorMode.toUpperCase();
|
|
102
|
+
if (isInverseColorMode(mode)) {
|
|
103
|
+
return parentColorMode === _global_styling.COLOR_MODES_STANDARD.dark || parentColorMode === undefined ? _global_styling.COLOR_MODES_STANDARD.light : _global_styling.COLOR_MODES_STANDARD.dark;
|
|
104
|
+
} else {
|
|
105
|
+
return mode;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns a value at a given path on an object.
|
|
111
|
+
* If `colorMode` is provided, will scope the value to the appropriate color mode key (LIGHT\DARK)
|
|
112
|
+
* @param {object} model - Object
|
|
113
|
+
* @param {string} _path - Dot-notated string to a path on the object
|
|
114
|
+
* @param {string} colorMode - `light` or `dark`
|
|
115
|
+
*/
|
|
116
|
+
var getOn = exports.getOn = function getOn(model, _path, colorMode) {
|
|
117
|
+
var path = _path.split('.');
|
|
118
|
+
var node = model;
|
|
119
|
+
while (path.length) {
|
|
120
|
+
var segment = path.shift();
|
|
121
|
+
if (node.hasOwnProperty(segment) === false) {
|
|
122
|
+
if (colorMode && node.hasOwnProperty(colorMode) === true && node[colorMode].hasOwnProperty(segment) === true) {
|
|
123
|
+
if (node[colorMode][segment] instanceof Computed) {
|
|
124
|
+
node = node[colorMode][segment].getValue(null, {}, node, colorMode);
|
|
125
|
+
} else {
|
|
126
|
+
node = node[colorMode][segment];
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
if (node[segment] instanceof Computed) {
|
|
133
|
+
node = node[segment].getValue(null, {}, node, colorMode);
|
|
134
|
+
} else {
|
|
135
|
+
node = node[segment];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return node;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Sets a value at a given path on an object.
|
|
144
|
+
* @param {object} model - Object
|
|
145
|
+
* @param {string} _path - Dot-notated string to a path on the object
|
|
146
|
+
* @param {any} string - The value to set
|
|
147
|
+
*/
|
|
148
|
+
var setOn = exports.setOn = function setOn(model, _path, value) {
|
|
149
|
+
var path = _path.split('.');
|
|
150
|
+
var propertyName = path.pop();
|
|
151
|
+
var node = model;
|
|
152
|
+
while (path.length) {
|
|
153
|
+
var segment = path.shift();
|
|
154
|
+
if (node.hasOwnProperty(segment) === false) {
|
|
155
|
+
node[segment] = {};
|
|
156
|
+
}
|
|
157
|
+
node = node[segment];
|
|
158
|
+
}
|
|
159
|
+
node[propertyName] = value;
|
|
160
|
+
return true;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Creates a class to store the `computer` method and its eventual parameters.
|
|
165
|
+
* Allows for on-demand computation with up-to-date parameters via `getValue` method.
|
|
166
|
+
* @constructor
|
|
167
|
+
* @param {function} computer - Function to be computed
|
|
168
|
+
* @param {string | array} dependencies - Dependencies passed to the `computer` as parameters
|
|
169
|
+
*/
|
|
170
|
+
var Computed = exports.Computed = /*#__PURE__*/function () {
|
|
171
|
+
function Computed(computer) {
|
|
172
|
+
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
173
|
+
_classCallCheck(this, Computed);
|
|
174
|
+
this.computer = computer;
|
|
175
|
+
this.dependencies = dependencies;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Executes the `computer` method with the current state of the theme
|
|
180
|
+
* by taking into account previously computed values and modifications.
|
|
181
|
+
* @param {Proxy | object} base - Computed or uncomputed theme
|
|
182
|
+
* @param {Proxy | object} modifications - Theme value overrides
|
|
183
|
+
* @param {object} working - Partially computed theme
|
|
184
|
+
* @param {string} colorMode - `light` or `dark`
|
|
185
|
+
*/
|
|
186
|
+
return _createClass(Computed, [{
|
|
187
|
+
key: "getValue",
|
|
188
|
+
value: function getValue(base) {
|
|
189
|
+
var modifications = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
190
|
+
var working = arguments.length > 2 ? arguments[2] : undefined;
|
|
191
|
+
var colorMode = arguments.length > 3 ? arguments[3] : undefined;
|
|
192
|
+
if (!this.dependencies.length) {
|
|
193
|
+
return this.computer(working);
|
|
194
|
+
}
|
|
195
|
+
if (!Array.isArray(this.dependencies)) {
|
|
196
|
+
var _ref, _getOn;
|
|
197
|
+
return this.computer((_ref = (_getOn = getOn(working, this.dependencies)) !== null && _getOn !== void 0 ? _getOn : getOn(modifications, this.dependencies, colorMode)) !== null && _ref !== void 0 ? _ref : base ? getOn(base, this.dependencies, colorMode) : working);
|
|
198
|
+
}
|
|
199
|
+
return this.computer(this.dependencies.map(function (dependency) {
|
|
200
|
+
var _ref2, _getOn2;
|
|
201
|
+
return (_ref2 = (_getOn2 = getOn(working, dependency)) !== null && _getOn2 !== void 0 ? _getOn2 : getOn(modifications, dependency, colorMode)) !== null && _ref2 !== void 0 ? _ref2 : base ? getOn(base, dependency, colorMode) : working;
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
}]);
|
|
205
|
+
}();
|
|
206
|
+
/**
|
|
207
|
+
* Returns a Class (`Computed`) that stores the arbitrary computer method
|
|
208
|
+
* and references to its optional dependecies.
|
|
209
|
+
* @param {function} computer - Arbitrary method to be called at compute time.
|
|
210
|
+
* @param {string | array} dependencies - Values that will be provided to `computer` at compute time.
|
|
211
|
+
*/
|
|
212
|
+
function computed(comp, dep) {
|
|
213
|
+
return new Computed(comp, dep);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Type guard to check for a Computed object based on object shape
|
|
218
|
+
* without relying on the Computed class directly
|
|
219
|
+
*/
|
|
220
|
+
var isComputedLike = function isComputedLike(key) {
|
|
221
|
+
if (_typeof(key) !== 'object' || Array.isArray(key)) return false;
|
|
222
|
+
return key.hasOwnProperty('dependencies') && key.hasOwnProperty('computer');
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Takes an uncomputed theme, and computes and returns all values taking
|
|
227
|
+
* into consideration value overrides and configured color mode.
|
|
228
|
+
* Overrides take precedence, and only values in the current color mode
|
|
229
|
+
* are computed and returned.
|
|
230
|
+
* @param {Proxy} base - Object to transform into Proxy
|
|
231
|
+
* @param {Proxy | object} over - Unique identifier or name
|
|
232
|
+
* @param {string} colorMode - `light` or `dark`
|
|
233
|
+
*/
|
|
234
|
+
var getComputed = exports.getComputed = function getComputed(base, over, colorMode) {
|
|
235
|
+
var output = {
|
|
236
|
+
themeName: base.key
|
|
237
|
+
};
|
|
238
|
+
function loop(base, over) {
|
|
239
|
+
var checkExisting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
240
|
+
var path = arguments.length > 3 ? arguments[3] : undefined;
|
|
241
|
+
Object.keys(base).forEach(function (key) {
|
|
242
|
+
var newPath = path ? "".concat(path, ".").concat(key) : "".concat(key);
|
|
243
|
+
// @ts-expect-error `key` is not necessarily a colorMode key
|
|
244
|
+
if ([].concat(_toConsumableArray(Object.values(_global_styling.COLOR_MODES_STANDARD)), [colorMode]).includes(key)) {
|
|
245
|
+
if (key !== colorMode) {
|
|
246
|
+
return;
|
|
247
|
+
} else {
|
|
248
|
+
var colorModeSegment = new RegExp("(\\.".concat(colorMode, "\\b)|(\\b").concat(colorMode, "\\.)"));
|
|
249
|
+
newPath = newPath.replace(colorModeSegment, '');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
var existing = checkExisting && getOn(output, newPath);
|
|
253
|
+
if (!existing || isObject(existing)) {
|
|
254
|
+
// NOTE: the class type check for Computed is not true for themes created externally;
|
|
255
|
+
// we additionally check on the object shape to confirm a Computed value
|
|
256
|
+
var baseValue = base[key] instanceof Computed || isComputedLike(base[key]) ? base[key].getValue(base.root, over.root, output, colorMode) : base[key];
|
|
257
|
+
var overValue = over[key] instanceof Computed || isComputedLike(over[key]) ? over[key].getValue(base.root, over.root, output, colorMode) : over[key];
|
|
258
|
+
if (isObject(baseValue) && !Array.isArray(baseValue)) {
|
|
259
|
+
loop(baseValue, overValue !== null && overValue !== void 0 ? overValue : {}, checkExisting, newPath);
|
|
260
|
+
} else {
|
|
261
|
+
setOn(output, newPath, overValue !== null && overValue !== void 0 ? overValue : baseValue);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
// Compute standard theme values and apply overrides
|
|
267
|
+
loop(base, over);
|
|
268
|
+
// Compute and apply extension values only
|
|
269
|
+
loop(over, {}, true);
|
|
270
|
+
return output;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Builds a Proxy with a custom `handler` designed to self-reference values
|
|
275
|
+
* and prevent arbitrary value overrides.
|
|
276
|
+
* @param {object} model - Object to transform into Proxy
|
|
277
|
+
* @param {string} key - Unique identifier or name
|
|
278
|
+
*/
|
|
279
|
+
var buildTheme = exports.buildTheme = function buildTheme(model, key) {
|
|
280
|
+
var handler = {
|
|
281
|
+
getPrototypeOf: function getPrototypeOf(target) {
|
|
282
|
+
return Reflect.getPrototypeOf(target.model);
|
|
283
|
+
},
|
|
284
|
+
setPrototypeOf: function setPrototypeOf(target, prototype) {
|
|
285
|
+
return Reflect.setPrototypeOf(target.model, prototype);
|
|
286
|
+
},
|
|
287
|
+
isExtensible: function isExtensible(target) {
|
|
288
|
+
return Reflect.isExtensible(target);
|
|
289
|
+
},
|
|
290
|
+
preventExtensions: function preventExtensions(target) {
|
|
291
|
+
return Reflect.preventExtensions(target.model);
|
|
292
|
+
},
|
|
293
|
+
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, key) {
|
|
294
|
+
return Reflect.getOwnPropertyDescriptor(target.model, key);
|
|
295
|
+
},
|
|
296
|
+
defineProperty: function defineProperty(target, property, attributes) {
|
|
297
|
+
return Reflect.defineProperty(target.model, property, attributes);
|
|
298
|
+
},
|
|
299
|
+
has: function has(target, property) {
|
|
300
|
+
return Reflect.has(target.model, property);
|
|
301
|
+
},
|
|
302
|
+
get: function get(_target, property) {
|
|
303
|
+
if (property === 'key') {
|
|
304
|
+
return _target[property];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// prevent Safari from locking up when the proxy is used in dev tools
|
|
308
|
+
// as it doesn't support getPrototypeOf
|
|
309
|
+
if (property === '__proto__') return {};
|
|
310
|
+
var target = property === 'root' ? _target : _target.model || _target;
|
|
311
|
+
// @ts-ignore `string` index signature
|
|
312
|
+
var value = target[property];
|
|
313
|
+
if (isObject(value) && !Array.isArray(value)) {
|
|
314
|
+
return new Proxy({
|
|
315
|
+
model: value,
|
|
316
|
+
root: _target.root,
|
|
317
|
+
key: "_".concat(_target.key)
|
|
318
|
+
}, handler);
|
|
319
|
+
} else {
|
|
320
|
+
return value;
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
set: function set(target) {
|
|
324
|
+
return target;
|
|
325
|
+
},
|
|
326
|
+
deleteProperty: function deleteProperty(target) {
|
|
327
|
+
return target;
|
|
328
|
+
},
|
|
329
|
+
ownKeys: function ownKeys(target) {
|
|
330
|
+
return Reflect.ownKeys(target.model);
|
|
331
|
+
},
|
|
332
|
+
apply: function apply(target) {
|
|
333
|
+
return target;
|
|
334
|
+
},
|
|
335
|
+
construct: function construct(target) {
|
|
336
|
+
return target;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var themeProxy = new Proxy({
|
|
340
|
+
model: model,
|
|
341
|
+
root: model,
|
|
342
|
+
key: key
|
|
343
|
+
}, handler);
|
|
344
|
+
return themeProxy;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Deeply merges two objects, using `source` values whenever possible.
|
|
349
|
+
* @param {object} _target - Object with fallback values
|
|
350
|
+
* @param {object} source - Object with desired values
|
|
351
|
+
*/
|
|
352
|
+
var mergeDeep = exports.mergeDeep = function mergeDeep(_target) {
|
|
353
|
+
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
354
|
+
var target = _objectSpread({}, _target);
|
|
355
|
+
if (!isObject(target) || !isObject(source)) {
|
|
356
|
+
return source;
|
|
357
|
+
}
|
|
358
|
+
Object.keys(source).forEach(function (key) {
|
|
359
|
+
var targetValue = target[key];
|
|
360
|
+
var sourceValue = source[key];
|
|
361
|
+
if (isObject(targetValue) && isObject(sourceValue)) {
|
|
362
|
+
target[key] = mergeDeep(_objectSpread({}, targetValue), _objectSpread({}, sourceValue));
|
|
363
|
+
} else {
|
|
364
|
+
target[key] = sourceValue;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
return target;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Returns token name string based on passed dynamic variants
|
|
372
|
+
* and additional prefix/suffix
|
|
373
|
+
*/
|
|
374
|
+
var getTokenName = exports.getTokenName = function getTokenName(prefix, variant, suffix) {
|
|
375
|
+
var getCapitalized = function getCapitalized(str) {
|
|
376
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
377
|
+
};
|
|
378
|
+
var colorName = variant.charAt(0).toUpperCase() + variant.slice(1);
|
|
379
|
+
var _suffix = suffix ? getCapitalized(suffix) : '';
|
|
380
|
+
return "".concat(prefix).concat(getCapitalized(colorName)).concat(_suffix);
|
|
381
|
+
};
|
|
382
|
+
//# sourceMappingURL=utils.js.map
|