@deephaven/components 0.53.1-layout-manager.4 → 0.54.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.
- package/dist/DateInput.d.ts +1 -1
- package/dist/DateInput.d.ts.map +1 -1
- package/dist/DateInput.js +0 -8
- package/dist/DateInput.js.map +1 -1
- package/dist/theme/ThemeUtils.d.ts +14 -10
- package/dist/theme/ThemeUtils.d.ts.map +1 -1
- package/dist/theme/ThemeUtils.js +39 -33
- package/dist/theme/ThemeUtils.js.map +1 -1
- package/dist/theme/theme-dark/index.d.ts.map +1 -1
- package/dist/theme/theme-dark/index.js +2 -1
- package/dist/theme/theme-dark/index.js.map +1 -1
- package/dist/theme/theme-dark/theme-dark-semantic-chart.css +1 -0
- package/dist/theme/theme-dark/theme-dark-semantic-chart.css.map +1 -0
- package/package.json +7 -7
package/dist/DateInput.d.ts
CHANGED
package/dist/DateInput.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../src/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAYrD,KAAK,cAAc,GAAG;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../src/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAYrD,KAAK,cAAc,GAAG;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,SAAS,yFA0Cd,CAAC;AAGF,eAAe,SAAS,CAAC"}
|
package/dist/DateInput.js
CHANGED
|
@@ -44,13 +44,5 @@ var DateInput = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
DateInput.displayName = 'DateInput';
|
|
47
|
-
DateInput.defaultProps = {
|
|
48
|
-
className: '',
|
|
49
|
-
onChange: () => false,
|
|
50
|
-
defaultValue: '',
|
|
51
|
-
onFocus: () => false,
|
|
52
|
-
onBlur: () => false,
|
|
53
|
-
'data-testid': undefined
|
|
54
|
-
};
|
|
55
47
|
export default DateInput;
|
|
56
48
|
//# sourceMappingURL=DateInput.js.map
|
package/dist/DateInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","names":["React","useCallback","useState","classNames","Log","MaskedInput","getNextSegmentValue","jsx","_jsx","log","module","DATE_PATTERN","EXAMPLES","DATE_FORMAT","DateInput","forwardRef","props","ref","className","onChange","undefined","defaultValue","onFocus","onBlur","dataTestId","value","setValue","selection","setSelection","handleChange","newValue","debug","children","example","onSelect","pattern","placeholder","displayName"
|
|
1
|
+
{"version":3,"file":"DateInput.js","names":["React","useCallback","useState","classNames","Log","MaskedInput","getNextSegmentValue","jsx","_jsx","log","module","DATE_PATTERN","EXAMPLES","DATE_FORMAT","DateInput","forwardRef","props","ref","className","onChange","undefined","defaultValue","onFocus","onBlur","dataTestId","value","setValue","selection","setSelection","handleChange","newValue","debug","children","example","onSelect","pattern","placeholder","displayName"],"sources":["../src/DateInput.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport classNames from 'classnames';\nimport Log from '@deephaven/log';\nimport MaskedInput, { SelectionSegment } from './MaskedInput';\nimport { getNextSegmentValue } from './DateInputUtils';\n\nconst log = Log.module('DateInput');\n\nconst DATE_PATTERN = '[12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])';\nconst EXAMPLES = ['2000-01-01', '2022-12-31'];\nconst DATE_FORMAT = 'YYYY-MM-DD';\n\ntype DateInputProps = {\n className?: string;\n onChange?: (date: string) => void;\n defaultValue?: string;\n onFocus?: () => void;\n onBlur?: () => void;\n 'data-testid'?: string;\n};\n\nconst DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(\n (props: DateInputProps, ref) => {\n const {\n className = '',\n onChange = () => undefined,\n defaultValue = '',\n onFocus = () => undefined,\n onBlur = () => undefined,\n 'data-testid': dataTestId,\n } = props;\n const [value, setValue] = useState(defaultValue);\n const [selection, setSelection] = useState<SelectionSegment>();\n\n const handleChange = useCallback(\n (newValue: string): void => {\n log.debug('handleChange', newValue);\n setValue(newValue);\n onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <div className=\"d-flex flex-row align-items-center\">\n <MaskedInput\n ref={ref}\n className={classNames(className)}\n example={EXAMPLES}\n getNextSegmentValue={getNextSegmentValue}\n onChange={handleChange}\n onSelect={setSelection}\n pattern={DATE_PATTERN}\n placeholder={DATE_FORMAT}\n selection={selection}\n value={value}\n onFocus={onFocus}\n onBlur={onBlur}\n data-testid={dataTestId}\n />\n </div>\n );\n }\n);\nDateInput.displayName = 'DateInput';\n\nexport default DateInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,WAAW;AAAA,SACTC,mBAAmB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAE5B,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,WAAW,CAAC;AAEnC,IAAMC,YAAY,GAAG,yDAAyD;AAC9E,IAAMC,QAAQ,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;AAC7C,IAAMC,WAAW,GAAG,YAAY;AAWhC,IAAMC,SAAS,gBAAGd,KAAK,CAAC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1
|
import { ThemeData, ThemePreloadData, ThemePreloadStyleContent, ThemeRegistrationData } from './ThemeModel';
|
|
2
|
+
export declare const CSS_VAR_EXPRESSION_PREFIX = "var(--";
|
|
2
3
|
export declare const TMP_CSS_PROP_PREFIX = "dh-tmp";
|
|
4
|
+
export declare const NON_WHITESPACE_REGEX: RegExp;
|
|
5
|
+
export declare const WHITESPACE_REGEX: RegExp;
|
|
3
6
|
export type VarExpressionResolver = (varExpression: string) => string;
|
|
4
7
|
/**
|
|
5
8
|
* Creates a string containing preload style content for the current theme.
|
|
@@ -28,31 +31,32 @@ export declare function getDefaultBaseThemes(): ThemeData[];
|
|
|
28
31
|
*/
|
|
29
32
|
export declare function getThemePreloadData(): ThemePreloadData | null;
|
|
30
33
|
/**
|
|
31
|
-
* Identifies start and end indices of any
|
|
34
|
+
* Identifies start and end indices of any top-level expressions in the given
|
|
32
35
|
* string.
|
|
33
36
|
*
|
|
34
37
|
* e.g.
|
|
35
|
-
*
|
|
38
|
+
* getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')
|
|
36
39
|
* yields:
|
|
37
40
|
* [
|
|
38
|
-
* [0, 12],
|
|
39
|
-
* [14,
|
|
41
|
+
* [0, 12], // 'var(--aaa-aa)'
|
|
42
|
+
* [14, 17] // '#fff'
|
|
43
|
+
* [19, 31], // 'var(--bbb-bb)'
|
|
40
44
|
* ]
|
|
41
45
|
*
|
|
42
46
|
* In cases where there are nested expressions, only the indices of the outermost
|
|
43
47
|
* expression will be included.
|
|
44
48
|
*
|
|
45
49
|
* e.g.
|
|
46
|
-
*
|
|
50
|
+
* getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')
|
|
47
51
|
* yields:
|
|
48
52
|
* [
|
|
49
|
-
* [0, 34],
|
|
50
|
-
* [36, 48], //
|
|
53
|
+
* [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'
|
|
54
|
+
* [36, 48], // 'var(--bbb-bb)'
|
|
51
55
|
* ]
|
|
52
|
-
* @param value The string to search for
|
|
53
|
-
* @returns An array of [start, end] index pairs for each
|
|
56
|
+
* @param value The string to search for expressions
|
|
57
|
+
* @returns An array of [start, end] index pairs for each expression
|
|
54
58
|
*/
|
|
55
|
-
export declare function
|
|
59
|
+
export declare function getExpressionRanges(value: string): [number, number][];
|
|
56
60
|
/**
|
|
57
61
|
* Make a copy of the given object replacing any css variable expressions
|
|
58
62
|
* contained in its prop values with values resolved from the given HTML element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeUtils.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeUtils.ts"],"names":[],"mappings":"AAgBA,OAAO,EAIL,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EAEtB,MAAM,cAAc,CAAC;AAItB,eAAO,MAAM,mBAAmB,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"ThemeUtils.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeUtils.ts"],"names":[],"mappings":"AAgBA,OAAO,EAIL,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EAEtB,MAAM,cAAc,CAAC;AAItB,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAC5C,eAAO,MAAM,oBAAoB,QAAO,CAAC;AACzC,eAAO,MAAM,gBAAgB,QAAO,CAAC;AAErC,MAAM,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,MAAM,KAAK,MAAM,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,4BAA4B,IAAI,wBAAwB,CAWvE;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,GAAG,CAAC,MAAM,CAAC,CAcb;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,qBAAqB,GACvC,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CA+BtC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,EAAE,CAalD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,IAAI,CAU7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAiCrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1E,MAAM,EAAE,CAAC,EACT,aAAa,GAAE,WAA2B,GACzC,CAAC,CA2CH;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,MAAM,GACZ,MAAM,CAyBR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAKvE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAUnC"}
|
package/dist/theme/ThemeUtils.js
CHANGED
|
@@ -16,7 +16,10 @@ import { themeDark } from "./theme-dark/index.js";
|
|
|
16
16
|
import { themeLight } from "./theme-light/index.js";
|
|
17
17
|
import { DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY, DEFAULT_PRELOAD_DATA_VARIABLES, THEME_CACHE_LOCAL_STORAGE_KEY } from "./ThemeModel.js";
|
|
18
18
|
var log = Log.module('ThemeUtils');
|
|
19
|
+
export var CSS_VAR_EXPRESSION_PREFIX = 'var(--';
|
|
19
20
|
export var TMP_CSS_PROP_PREFIX = 'dh-tmp';
|
|
21
|
+
export var NON_WHITESPACE_REGEX = /\S/;
|
|
22
|
+
export var WHITESPACE_REGEX = /\s/;
|
|
20
23
|
/**
|
|
21
24
|
* Creates a string containing preload style content for the current theme.
|
|
22
25
|
* This resolves the current values of a few CSS variables that can be used
|
|
@@ -42,9 +45,12 @@ export function calculatePreloadStyleContent() {
|
|
|
42
45
|
export function extractDistinctCssVariableExpressions(record) {
|
|
43
46
|
var set = new Set();
|
|
44
47
|
Object.values(record).forEach(value => {
|
|
45
|
-
|
|
48
|
+
getExpressionRanges(value).forEach(_ref2 => {
|
|
46
49
|
var [start, end] = _ref2;
|
|
47
|
-
|
|
50
|
+
var expression = value.substring(start, end + 1);
|
|
51
|
+
if (expression.includes(CSS_VAR_EXPRESSION_PREFIX)) {
|
|
52
|
+
set.add(expression);
|
|
53
|
+
}
|
|
48
54
|
});
|
|
49
55
|
});
|
|
50
56
|
return set;
|
|
@@ -98,54 +104,53 @@ export function getThemePreloadData() {
|
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
/**
|
|
101
|
-
* Identifies start and end indices of any
|
|
107
|
+
* Identifies start and end indices of any top-level expressions in the given
|
|
102
108
|
* string.
|
|
103
109
|
*
|
|
104
110
|
* e.g.
|
|
105
|
-
*
|
|
111
|
+
* getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')
|
|
106
112
|
* yields:
|
|
107
113
|
* [
|
|
108
|
-
* [0, 12],
|
|
109
|
-
* [14,
|
|
114
|
+
* [0, 12], // 'var(--aaa-aa)'
|
|
115
|
+
* [14, 17] // '#fff'
|
|
116
|
+
* [19, 31], // 'var(--bbb-bb)'
|
|
110
117
|
* ]
|
|
111
118
|
*
|
|
112
119
|
* In cases where there are nested expressions, only the indices of the outermost
|
|
113
120
|
* expression will be included.
|
|
114
121
|
*
|
|
115
122
|
* e.g.
|
|
116
|
-
*
|
|
123
|
+
* getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')
|
|
117
124
|
* yields:
|
|
118
125
|
* [
|
|
119
|
-
* [0, 34],
|
|
120
|
-
* [36, 48], //
|
|
126
|
+
* [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'
|
|
127
|
+
* [36, 48], // 'var(--bbb-bb)'
|
|
121
128
|
* ]
|
|
122
|
-
* @param value The string to search for
|
|
123
|
-
* @returns An array of [start, end] index pairs for each
|
|
129
|
+
* @param value The string to search for expressions
|
|
130
|
+
* @returns An array of [start, end] index pairs for each expression
|
|
124
131
|
*/
|
|
125
|
-
export function
|
|
132
|
+
export function getExpressionRanges(value) {
|
|
133
|
+
var _NON_WHITESPACE_REGEX, _NON_WHITESPACE_REGEX2;
|
|
126
134
|
var ranges = [];
|
|
127
|
-
var
|
|
128
|
-
var start = value.indexOf(cssVarPrefix);
|
|
135
|
+
var start = (_NON_WHITESPACE_REGEX = (_NON_WHITESPACE_REGEX2 = NON_WHITESPACE_REGEX.exec(value)) === null || _NON_WHITESPACE_REGEX2 === void 0 ? void 0 : _NON_WHITESPACE_REGEX2.index) !== null && _NON_WHITESPACE_REGEX !== void 0 ? _NON_WHITESPACE_REGEX : 0;
|
|
129
136
|
var parenLevel = 0;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
parenLevel += 1;
|
|
136
|
-
} else if (value[i] === ')') {
|
|
137
|
-
parenLevel -= 1;
|
|
138
|
-
}
|
|
139
|
-
if (parenLevel === 0) {
|
|
140
|
-
ranges.push([start, i]);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
137
|
+
for (var i = 0; i < value.length; i += 1) {
|
|
138
|
+
if (value[i] === '(') {
|
|
139
|
+
parenLevel += 1;
|
|
140
|
+
} else if (value[i] === ')') {
|
|
141
|
+
parenLevel -= 1;
|
|
143
142
|
}
|
|
144
|
-
if (parenLevel
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
if (i === value.length - 1 || WHITESPACE_REGEX.test(value[i + 1]) && parenLevel === 0) {
|
|
144
|
+
ranges.push([start, i]);
|
|
145
|
+
while (i < value.length - 1 && WHITESPACE_REGEX.test(value[i + 1])) {
|
|
146
|
+
i += 1;
|
|
147
|
+
}
|
|
148
|
+
start = i + 1;
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
}
|
|
151
|
+
if (parenLevel !== 0) {
|
|
152
|
+
log.error('Unbalanced parentheses in css var expression', value);
|
|
153
|
+
return [];
|
|
149
154
|
}
|
|
150
155
|
return ranges;
|
|
151
156
|
}
|
|
@@ -212,13 +217,14 @@ export function resolveCssVariablesInRecord(record) {
|
|
|
212
217
|
export function resolveCssVariablesInString(resolver, value) {
|
|
213
218
|
var result = [];
|
|
214
219
|
var i = 0;
|
|
215
|
-
|
|
220
|
+
getExpressionRanges(value).forEach(_ref4 => {
|
|
216
221
|
var [start, end] = _ref4;
|
|
217
222
|
if (i < start) {
|
|
218
223
|
result.push(value.substring(i, start));
|
|
219
224
|
i += start - i;
|
|
220
225
|
}
|
|
221
|
-
|
|
226
|
+
var expression = value.substring(start, end + 1);
|
|
227
|
+
result.push(expression.includes(CSS_VAR_EXPRESSION_PREFIX) ? resolver(expression) : expression);
|
|
222
228
|
i += end - start + 1;
|
|
223
229
|
});
|
|
224
230
|
if (result.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeUtils.js","names":["Log","assertNotNull","ColorUtils","themeDark","themeLight","DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","DEFAULT_PRELOAD_DATA_VARIABLES","THEME_CACHE_LOCAL_STORAGE_KEY","log","module","TMP_CSS_PROP_PREFIX","calculatePreloadStyleContent","bodyStyle","getComputedStyle","document","body","pairs","Object","entries","map","_ref","key","defaultValue","concat","getPropertyValue","join","extractDistinctCssVariableExpressions","record","set","Set","values","forEach","value","getCssVariableRanges","_ref2","start","end","add","substring","getActiveThemes","themeKey","themeRegistration","_custom$baseThemeKey","custom","find","theme","baseThemeKey","base","error","debug","getDefaultBaseThemes","name","styleContent","getThemePreloadData","data","localStorage","getItem","JSON","parse","_unused","ranges","cssVarPrefix","indexOf","parenLevel","i","length","push","resolveCssVariablesInRecord","targetElement","arguments","undefined","perfStart","performance","now","tmpPropEl","createElement","appendChild","varExpressions","varExpression","tmpPropKey","style","setProperty","result","computedStyle","window","resolver","resolved","normalizeCssColor","_ref3","resolveCssVariablesInString","remove","_ref4","setThemePreloadData","preloadData","setItem","stringify","getThemeKey","pluginName","themeName","preloadTheme","_getThemePreloadData$","_getThemePreloadData","preloadStyleContent","innerHTML","head"],"sources":["../../src/theme/ThemeUtils.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport { assertNotNull, ColorUtils } from '@deephaven/utils';\n// Note that ?inline imports are natively supported by Vite, but consumers of\n// @deephaven/components using Webpack will need to add a rule to their module\n// config.\n// e.g.\n// module: {\n// rules: [\n// {\n// resourceQuery: /inline/,\n// type: 'asset/source',\n// },\n// ],\n// },\nimport { themeDark } from './theme-dark';\nimport { themeLight } from './theme-light';\nimport {\n DEFAULT_DARK_THEME_KEY,\n DEFAULT_LIGHT_THEME_KEY,\n DEFAULT_PRELOAD_DATA_VARIABLES,\n ThemeData,\n ThemePreloadData,\n ThemePreloadStyleContent,\n ThemeRegistrationData,\n THEME_CACHE_LOCAL_STORAGE_KEY,\n} from './ThemeModel';\n\nconst log = Log.module('ThemeUtils');\n\nexport const TMP_CSS_PROP_PREFIX = 'dh-tmp';\n\nexport type VarExpressionResolver = (varExpression: string) => string;\n\n/**\n * Creates a string containing preload style content for the current theme.\n * This resolves the current values of a few CSS variables that can be used\n * to style the page before the theme is loaded on next page load.\n */\nexport function calculatePreloadStyleContent(): ThemePreloadStyleContent {\n const bodyStyle = getComputedStyle(document.body);\n\n // Calculate the current preload variables. If the variable is not set, use\n // the default value.\n const pairs = Object.entries(DEFAULT_PRELOAD_DATA_VARIABLES).map(\n ([key, defaultValue]) =>\n `${key}:${bodyStyle.getPropertyValue(key) || defaultValue}`\n );\n\n return `:root{${pairs.join(';')}}`;\n}\n\n/**\n * Extracts all css variable expressions from the given record and returns\n * a set of unique expressions.\n * @param record The record to extract css variable expressions from\n */\nexport function extractDistinctCssVariableExpressions(\n record: Record<string, string>\n): Set<string> {\n const set = new Set<string>();\n\n Object.values(record).forEach(value => {\n getCssVariableRanges(value).forEach(([start, end]) => {\n set.add(value.substring(start, end + 1));\n });\n });\n\n return set;\n}\n\n/**\n * Returns an array of the active themes. The first item will always be one\n * of the base themes. Optionally, the second item will be a custom theme.\n */\nexport function getActiveThemes(\n themeKey: string,\n themeRegistration: ThemeRegistrationData\n): [ThemeData] | [ThemeData, ThemeData] {\n const custom = themeRegistration.custom.find(\n theme => theme.themeKey === themeKey\n );\n\n const baseThemeKey = custom?.baseThemeKey ?? themeKey;\n\n let base = themeRegistration.base.find(\n theme => theme.themeKey === baseThemeKey\n );\n\n if (base == null) {\n log.error(\n `No registered base theme found for theme key: '${baseThemeKey}'`,\n 'Registered:',\n themeRegistration.base.map(theme => theme.themeKey),\n themeRegistration.custom.map(theme => theme.themeKey)\n );\n base = themeRegistration.base.find(\n theme => theme.themeKey === DEFAULT_DARK_THEME_KEY\n );\n\n assertNotNull(\n base,\n `Default base theme '${DEFAULT_DARK_THEME_KEY}' is not registered`\n );\n }\n\n log.debug('Applied themes:', base.themeKey, custom?.themeKey);\n\n return custom == null ? [base] : [base, custom];\n}\n\n/**\n * Get default base theme data.\n */\nexport function getDefaultBaseThemes(): ThemeData[] {\n return [\n {\n name: 'Default Dark',\n themeKey: DEFAULT_DARK_THEME_KEY,\n styleContent: themeDark,\n },\n {\n name: 'Default Light',\n themeKey: DEFAULT_LIGHT_THEME_KEY,\n styleContent: themeLight,\n },\n ];\n}\n\n/**\n * Get the preload data from local storage or null if it does not exist or is\n * invalid\n */\nexport function getThemePreloadData(): ThemePreloadData | null {\n const data = localStorage.getItem(THEME_CACHE_LOCAL_STORAGE_KEY);\n\n try {\n return data == null ? null : JSON.parse(data);\n } catch {\n // ignore\n }\n\n return null;\n}\n\n/**\n * Identifies start and end indices of any css variable expressions in the given\n * string.\n *\n * e.g.\n * getCssVariableRanges('var(--aaa-aa) var(--bbb-bb)')\n * yields:\n * [\n * [0, 12],\n * [14, 26],\n * ]\n *\n * In cases where there are nested expressions, only the indices of the outermost\n * expression will be included.\n *\n * e.g.\n * getCssVariableRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')\n * yields:\n * [\n * [0, 34], // range for --ccc-cc expression\n * [36, 48], // range for --bbb-bb expression\n * ]\n * @param value The string to search for css variable expressions\n * @returns An array of [start, end] index pairs for each css variable expression\n */\nexport function getCssVariableRanges(value: string): [number, number][] {\n const ranges: [number, number][] = [];\n\n const cssVarPrefix = 'var(--';\n let start = value.indexOf(cssVarPrefix);\n let parenLevel = 0;\n\n while (start > -1) {\n parenLevel = 1;\n let i = start + cssVarPrefix.length;\n for (; i < value.length; i += 1) {\n if (value[i] === '(') {\n parenLevel += 1;\n } else if (value[i] === ')') {\n parenLevel -= 1;\n }\n\n if (parenLevel === 0) {\n ranges.push([start, i]);\n break;\n }\n }\n\n if (parenLevel !== 0) {\n log.error('Unbalanced parentheses in css var expression', value);\n return [];\n }\n\n start = value.indexOf(cssVarPrefix, i + 1);\n }\n\n return ranges;\n}\n\n/**\n * Make a copy of the given object replacing any css variable expressions\n * contained in its prop values with values resolved from the given HTML element.\n * Variables that resolve to color strings will also be normalized to rgb or\n * rgba color strings.\n *\n * Note that the browser will force a reflow when calling `getComputedStyle` if\n * css properties have changed. In order to avoid a reflow for every property\n * check we use distinct setup, resolve / normalize, and cleanup passes:\n * 1. Setup - Create a tmp element and set all css props we want to evaluate\n * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls\n * and replace the original expressions with resolved values. Also normalize\n * css colors to rgb/a.\n * 3. Cleanup - Remove the tmp element\n * @param record An object whose values may contain css var expressions\n * @param targetElement The element to resolve css variables against. Defaults\n * to document.body\n */\nexport function resolveCssVariablesInRecord<T extends Record<string, string>>(\n record: T,\n targetElement: HTMLElement = document.body\n): T {\n const perfStart = performance.now();\n\n // Add a temporary div to attach temp css variables to\n const tmpPropEl = document.createElement('div');\n targetElement.appendChild(tmpPropEl);\n\n const varExpressions = [...extractDistinctCssVariableExpressions(record)];\n\n // Set temporary css variables for resolving var expressions\n varExpressions.forEach((varExpression, i) => {\n const tmpPropKey = `--${TMP_CSS_PROP_PREFIX}-${i}`;\n tmpPropEl.style.setProperty(tmpPropKey, varExpression);\n });\n\n const result = {} as T;\n\n const computedStyle = window.getComputedStyle(tmpPropEl);\n\n const resolver = (varExpression: string): string => {\n const tmpPropKey = `--${TMP_CSS_PROP_PREFIX}-${varExpressions.indexOf(\n varExpression\n )}`;\n\n const resolved = computedStyle.getPropertyValue(tmpPropKey);\n\n return ColorUtils.normalizeCssColor(resolved);\n };\n\n // Resolve the temporary css variables\n Object.entries(record).forEach(([key, value]) => {\n result[key as keyof T] = resolveCssVariablesInString(\n resolver,\n value\n ) as T[keyof T];\n });\n\n // Remove the temporary css variables\n tmpPropEl.remove();\n\n log.debug('Resolved css variables', performance.now() - perfStart, 'ms');\n\n return result;\n}\n\n/**\n * Resolve css variable expressions in the given string using the\n * given resolver and replace the original expressions with the resolved values.\n *\n * @param resolver Function that can resolve a css variable expression\n * @param value Value that may contain css variable expressions\n */\nexport function resolveCssVariablesInString(\n resolver: VarExpressionResolver,\n value: string\n): string {\n const result: string[] = [];\n let i = 0;\n getCssVariableRanges(value).forEach(([start, end]) => {\n if (i < start) {\n result.push(value.substring(i, start));\n i += start - i;\n }\n\n result.push(resolver(value.substring(start, end + 1)));\n\n i += end - start + 1;\n });\n\n if (result.length === 0) {\n return value;\n }\n\n return result.join('');\n}\n\n/**\n * Store theme preload data in local storage.\n * @param preloadData The preload data to set\n */\nexport function setThemePreloadData(preloadData: ThemePreloadData): void {\n localStorage.setItem(\n THEME_CACHE_LOCAL_STORAGE_KEY,\n JSON.stringify(preloadData)\n );\n}\n\n/**\n * Derive unique theme key from plugin root path and theme name.\n * @param pluginName The root path of the plugin\n * @param themeName The name of the theme\n */\nexport function getThemeKey(pluginName: string, themeName: string): string {\n return `${pluginName}_${themeName}`;\n}\n\n/**\n * Preload minimal theme variables from the cache.\n */\nexport function preloadTheme(): void {\n const preloadStyleContent =\n getThemePreloadData()?.preloadStyleContent ??\n calculatePreloadStyleContent();\n\n log.debug('Preloading theme content:', `'${preloadStyleContent}'`);\n\n const style = document.createElement('style');\n style.innerHTML = preloadStyleContent;\n document.head.appendChild(style);\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,EAAEC,UAAU,QAAQ,kBAAkB;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,SACSC,SAAS;AAAA,SACTC,UAAU;AAAA,SAEjBC,sBAAsB,EACtBC,uBAAuB,EACvBC,8BAA8B,EAK9BC,6BAA6B;AAG/B,IAAMC,GAAG,GAAGT,GAAG,CAACU,MAAM,CAAC,YAAY,CAAC;AAEpC,OAAO,IAAMC,mBAAmB,GAAG,QAAQ;AAI3C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAA,EAA6B;EACvE,IAAMC,SAAS,GAAGC,gBAAgB,CAACC,QAAQ,CAACC,IAAI,CAAC;;EAEjD;EACA;EACA,IAAMC,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACZ,8BAA8B,CAAC,CAACa,GAAG,CAC9DC,IAAA;IAAA,IAAC,CAACC,GAAG,EAAEC,YAAY,CAAC,GAAAF,IAAA;IAAA,UAAAG,MAAA,CACfF,GAAG,OAAAE,MAAA,CAAIX,SAAS,CAACY,gBAAgB,CAACH,GAAG,CAAC,IAAIC,YAAY;EAAA,CAC7D,CAAC;EAED,gBAAAC,MAAA,CAAgBP,KAAK,CAACS,IAAI,CAAC,GAAG,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qCAAqCA,CACnDC,MAA8B,EACjB;EACb,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AA,CAAuBC,mBAAmB,cAAAF,qBAAA,cAAAA,qBAAA,GAC1CzF,4BAA4B,CAAC,CAAC;EAEhCH,GAAG,CAACyC,KAAK,CAAC,2BAA2B,MAAA1B,MAAA,CAAM+E,mBAAmB,MAAG,CAAC;EAElE,IAAMtB,KAAK,GAAGlE,QAAQ,CAAC6D,aAAa,CAAC,OAAO,CAAC;EAC7CK,KAAK,CAACuB,SAAS,GAAGD,mBAAmB;EACrCxF,QAAQ,CAAC0F,IAAI,CAAC5B,WAAW,CAACI,KAAK,CAAC;AAClC"}
|
|
1
|
+
{"version":3,"file":"ThemeUtils.js","names":["Log","assertNotNull","ColorUtils","themeDark","themeLight","DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","DEFAULT_PRELOAD_DATA_VARIABLES","THEME_CACHE_LOCAL_STORAGE_KEY","log","module","CSS_VAR_EXPRESSION_PREFIX","TMP_CSS_PROP_PREFIX","NON_WHITESPACE_REGEX","WHITESPACE_REGEX","calculatePreloadStyleContent","bodyStyle","getComputedStyle","document","body","pairs","Object","entries","map","_ref","key","defaultValue","concat","getPropertyValue","join","extractDistinctCssVariableExpressions","record","set","Set","values","forEach","value","getExpressionRanges","_ref2","start","end","expression","substring","includes","add","getActiveThemes","themeKey","themeRegistration","_custom$baseThemeKey","custom","find","theme","baseThemeKey","base","error","debug","getDefaultBaseThemes","name","styleContent","getThemePreloadData","data","localStorage","getItem","JSON","parse","_unused","_NON_WHITESPACE_REGEX","_NON_WHITESPACE_REGEX2","ranges","exec","index","parenLevel","i","length","test","push","resolveCssVariablesInRecord","targetElement","arguments","undefined","perfStart","performance","now","tmpPropEl","createElement","appendChild","varExpressions","varExpression","tmpPropKey","style","setProperty","result","computedStyle","window","resolver","indexOf","resolved","normalizeCssColor","_ref3","resolveCssVariablesInString","remove","_ref4","setThemePreloadData","preloadData","setItem","stringify","getThemeKey","pluginName","themeName","preloadTheme","_getThemePreloadData$","_getThemePreloadData","preloadStyleContent","innerHTML","head"],"sources":["../../src/theme/ThemeUtils.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport { assertNotNull, ColorUtils } from '@deephaven/utils';\n// Note that ?inline imports are natively supported by Vite, but consumers of\n// @deephaven/components using Webpack will need to add a rule to their module\n// config.\n// e.g.\n// module: {\n// rules: [\n// {\n// resourceQuery: /inline/,\n// type: 'asset/source',\n// },\n// ],\n// },\nimport { themeDark } from './theme-dark';\nimport { themeLight } from './theme-light';\nimport {\n DEFAULT_DARK_THEME_KEY,\n DEFAULT_LIGHT_THEME_KEY,\n DEFAULT_PRELOAD_DATA_VARIABLES,\n ThemeData,\n ThemePreloadData,\n ThemePreloadStyleContent,\n ThemeRegistrationData,\n THEME_CACHE_LOCAL_STORAGE_KEY,\n} from './ThemeModel';\n\nconst log = Log.module('ThemeUtils');\n\nexport const CSS_VAR_EXPRESSION_PREFIX = 'var(--';\nexport const TMP_CSS_PROP_PREFIX = 'dh-tmp';\nexport const NON_WHITESPACE_REGEX = /\\S/;\nexport const WHITESPACE_REGEX = /\\s/;\n\nexport type VarExpressionResolver = (varExpression: string) => string;\n\n/**\n * Creates a string containing preload style content for the current theme.\n * This resolves the current values of a few CSS variables that can be used\n * to style the page before the theme is loaded on next page load.\n */\nexport function calculatePreloadStyleContent(): ThemePreloadStyleContent {\n const bodyStyle = getComputedStyle(document.body);\n\n // Calculate the current preload variables. If the variable is not set, use\n // the default value.\n const pairs = Object.entries(DEFAULT_PRELOAD_DATA_VARIABLES).map(\n ([key, defaultValue]) =>\n `${key}:${bodyStyle.getPropertyValue(key) || defaultValue}`\n );\n\n return `:root{${pairs.join(';')}}`;\n}\n\n/**\n * Extracts all css variable expressions from the given record and returns\n * a set of unique expressions.\n * @param record The record to extract css variable expressions from\n */\nexport function extractDistinctCssVariableExpressions(\n record: Record<string, string>\n): Set<string> {\n const set = new Set<string>();\n\n Object.values(record).forEach(value => {\n getExpressionRanges(value).forEach(([start, end]) => {\n const expression = value.substring(start, end + 1);\n\n if (expression.includes(CSS_VAR_EXPRESSION_PREFIX)) {\n set.add(expression);\n }\n });\n });\n\n return set;\n}\n\n/**\n * Returns an array of the active themes. The first item will always be one\n * of the base themes. Optionally, the second item will be a custom theme.\n */\nexport function getActiveThemes(\n themeKey: string,\n themeRegistration: ThemeRegistrationData\n): [ThemeData] | [ThemeData, ThemeData] {\n const custom = themeRegistration.custom.find(\n theme => theme.themeKey === themeKey\n );\n\n const baseThemeKey = custom?.baseThemeKey ?? themeKey;\n\n let base = themeRegistration.base.find(\n theme => theme.themeKey === baseThemeKey\n );\n\n if (base == null) {\n log.error(\n `No registered base theme found for theme key: '${baseThemeKey}'`,\n 'Registered:',\n themeRegistration.base.map(theme => theme.themeKey),\n themeRegistration.custom.map(theme => theme.themeKey)\n );\n base = themeRegistration.base.find(\n theme => theme.themeKey === DEFAULT_DARK_THEME_KEY\n );\n\n assertNotNull(\n base,\n `Default base theme '${DEFAULT_DARK_THEME_KEY}' is not registered`\n );\n }\n\n log.debug('Applied themes:', base.themeKey, custom?.themeKey);\n\n return custom == null ? [base] : [base, custom];\n}\n\n/**\n * Get default base theme data.\n */\nexport function getDefaultBaseThemes(): ThemeData[] {\n return [\n {\n name: 'Default Dark',\n themeKey: DEFAULT_DARK_THEME_KEY,\n styleContent: themeDark,\n },\n {\n name: 'Default Light',\n themeKey: DEFAULT_LIGHT_THEME_KEY,\n styleContent: themeLight,\n },\n ];\n}\n\n/**\n * Get the preload data from local storage or null if it does not exist or is\n * invalid\n */\nexport function getThemePreloadData(): ThemePreloadData | null {\n const data = localStorage.getItem(THEME_CACHE_LOCAL_STORAGE_KEY);\n\n try {\n return data == null ? null : JSON.parse(data);\n } catch {\n // ignore\n }\n\n return null;\n}\n\n/**\n * Identifies start and end indices of any top-level expressions in the given\n * string.\n *\n * e.g.\n * getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')\n * yields:\n * [\n * [0, 12], // 'var(--aaa-aa)'\n * [14, 17] // '#fff'\n * [19, 31], // 'var(--bbb-bb)'\n * ]\n *\n * In cases where there are nested expressions, only the indices of the outermost\n * expression will be included.\n *\n * e.g.\n * getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')\n * yields:\n * [\n * [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'\n * [36, 48], // 'var(--bbb-bb)'\n * ]\n * @param value The string to search for expressions\n * @returns An array of [start, end] index pairs for each expression\n */\nexport function getExpressionRanges(value: string): [number, number][] {\n const ranges: [number, number][] = [];\n\n let start = NON_WHITESPACE_REGEX.exec(value)?.index ?? 0;\n let parenLevel = 0;\n\n for (let i = 0; i < value.length; i += 1) {\n if (value[i] === '(') {\n parenLevel += 1;\n } else if (value[i] === ')') {\n parenLevel -= 1;\n }\n\n if (\n i === value.length - 1 ||\n (WHITESPACE_REGEX.test(value[i + 1]) && parenLevel === 0)\n ) {\n ranges.push([start, i]);\n\n while (i < value.length - 1 && WHITESPACE_REGEX.test(value[i + 1])) {\n i += 1;\n }\n\n start = i + 1;\n }\n }\n\n if (parenLevel !== 0) {\n log.error('Unbalanced parentheses in css var expression', value);\n return [];\n }\n\n return ranges;\n}\n\n/**\n * Make a copy of the given object replacing any css variable expressions\n * contained in its prop values with values resolved from the given HTML element.\n * Variables that resolve to color strings will also be normalized to rgb or\n * rgba color strings.\n *\n * Note that the browser will force a reflow when calling `getComputedStyle` if\n * css properties have changed. In order to avoid a reflow for every property\n * check we use distinct setup, resolve / normalize, and cleanup passes:\n * 1. Setup - Create a tmp element and set all css props we want to evaluate\n * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls\n * and replace the original expressions with resolved values. Also normalize\n * css colors to rgb/a.\n * 3. Cleanup - Remove the tmp element\n * @param record An object whose values may contain css var expressions\n * @param targetElement The element to resolve css variables against. Defaults\n * to document.body\n */\nexport function resolveCssVariablesInRecord<T extends Record<string, string>>(\n record: T,\n targetElement: HTMLElement = document.body\n): T {\n const perfStart = performance.now();\n\n // Add a temporary div to attach temp css variables to\n const tmpPropEl = document.createElement('div');\n targetElement.appendChild(tmpPropEl);\n\n const varExpressions = [...extractDistinctCssVariableExpressions(record)];\n\n // Set temporary css variables for resolving var expressions\n varExpressions.forEach((varExpression, i) => {\n const tmpPropKey = `--${TMP_CSS_PROP_PREFIX}-${i}`;\n tmpPropEl.style.setProperty(tmpPropKey, varExpression);\n });\n\n const result = {} as T;\n\n const computedStyle = window.getComputedStyle(tmpPropEl);\n\n const resolver = (varExpression: string): string => {\n const tmpPropKey = `--${TMP_CSS_PROP_PREFIX}-${varExpressions.indexOf(\n varExpression\n )}`;\n\n const resolved = computedStyle.getPropertyValue(tmpPropKey);\n\n return ColorUtils.normalizeCssColor(resolved);\n };\n\n // Resolve the temporary css variables\n Object.entries(record).forEach(([key, value]) => {\n result[key as keyof T] = resolveCssVariablesInString(\n resolver,\n value\n ) as T[keyof T];\n });\n\n // Remove the temporary css variables\n tmpPropEl.remove();\n\n log.debug('Resolved css variables', performance.now() - perfStart, 'ms');\n\n return result;\n}\n\n/**\n * Resolve css variable expressions in the given string using the\n * given resolver and replace the original expressions with the resolved values.\n *\n * @param resolver Function that can resolve a css variable expression\n * @param value Value that may contain css variable expressions\n */\nexport function resolveCssVariablesInString(\n resolver: VarExpressionResolver,\n value: string\n): string {\n const result: string[] = [];\n let i = 0;\n getExpressionRanges(value).forEach(([start, end]) => {\n if (i < start) {\n result.push(value.substring(i, start));\n i += start - i;\n }\n\n const expression = value.substring(start, end + 1);\n\n result.push(\n expression.includes(CSS_VAR_EXPRESSION_PREFIX)\n ? resolver(expression)\n : expression\n );\n\n i += end - start + 1;\n });\n\n if (result.length === 0) {\n return value;\n }\n\n return result.join('');\n}\n\n/**\n * Store theme preload data in local storage.\n * @param preloadData The preload data to set\n */\nexport function setThemePreloadData(preloadData: ThemePreloadData): void {\n localStorage.setItem(\n THEME_CACHE_LOCAL_STORAGE_KEY,\n JSON.stringify(preloadData)\n );\n}\n\n/**\n * Derive unique theme key from plugin root path and theme name.\n * @param pluginName The root path of the plugin\n * @param themeName The name of the theme\n */\nexport function getThemeKey(pluginName: string, themeName: string): string {\n return `${pluginName}_${themeName}`;\n}\n\n/**\n * Preload minimal theme variables from the cache.\n */\nexport function preloadTheme(): void {\n const preloadStyleContent =\n getThemePreloadData()?.preloadStyleContent ??\n calculatePreloadStyleContent();\n\n log.debug('Preloading theme content:', `'${preloadStyleContent}'`);\n\n const style = document.createElement('style');\n style.innerHTML = preloadStyleContent;\n document.head.appendChild(style);\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,EAAEC,UAAU,QAAQ,kBAAkB;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,SACSC,SAAS;AAAA,SACTC,UAAU;AAAA,SAEjBC,sBAAsB,EACtBC,uBAAuB,EACvBC,8BAA8B,EAK9BC,6BAA6B;AAG/B,IAAMC,GAAG,GAAGT,GAAG,CAACU,MAAM,CAAC,YAAY,CAAC;AAEpC,OAAO,IAAMC,yBAAyB,GAAG,QAAQ;AACjD,OAAO,IAAMC,mBAAmB,GAAG,QAAQ;AAC3C,OAAO,IAAMC,oBAAoB,GAAG,IAAI;AACxC,OAAO,IAAMC,gBAAgB,GAAG,IAAI;AAIpC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAA,EAA6B;EACvE,IAAMC,SAAS,GAAGC,gBAAgB,CAACC,QAAQ,CAACC,IAAI,CAAC;;EAEjD;EACA;EACA,IAAMC,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACf,8BAA8B,CAAC,CAACgB,GAAG,CAC9DC,IAAA;IAAA,IAAC,CAACC,GAAG,EAAEC,YAAY,CAAC,GAAAF,IAAA;IAAA,UAAAG,MAAA,CACfF,GAAG,OAAAE,MAAA,CAAIX,SAAS,CAACY,gBAAgB,CAACH,GAAG,CAAC,IAAIC,YAAY;EAAA,CAC7D,CAAC;EAED,gBAAAC,MAAA,CAAgBP,KAAK,CAACS,IAAI,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AOuD,MAAM,CAAC9D,IAAI,CAAC,EAAE,CAAC;AACxB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASyE,mBAAmBA,CAACC,WAA6B,EAAQ;EACvE1C,YAAY,CAAC2C,OAAO,CAClBhG,6BAA6B,EAC7BuD,IAAI,CAAC0C,SAAS,CAACF,WAAW,CAC5B,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,WAAWA,CAACC,UAAkB,EAAEC,SAAiB,EAAU;EACzE,UAAAjF,MAAA,CAAUgF,UAAU,OAAAhF,MAAA,CAAIiF,SAAS;AACnC;;AAEA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAS;EAAA,IAAAC,qBAAA,EAAAC,oBAAA;EACnC,IAAMC,mBAAmB,IAAAF,qBAAA,IAAAC,oBAAA,GACvBpD,mBAAmB,CAAC,CAAC,cAAAoD,oBAAA,uBAArBA,oBAAA,CAAuBC,mBAAmB,cAAAF,qBAAA,cAAAA,qBAAA,GAC1C/F,4BAA4B,CAAC,CAAC;EAEhCN,GAAG,CAAC8C,KAAK,CAAC,2BAA2B,MAAA5B,MAAA,CAAMqF,mBAAmB,MAAG,CAAC;EAElE,IAAMvB,KAAK,GAAGvE,QAAQ,CAACkE,aAAa,CAAC,OAAO,CAAC;EAC7CK,KAAK,CAACwB,SAAS,GAAGD,mBAAmB;EACrC9F,QAAQ,CAACgG,IAAI,CAAC7B,WAAW,CAACI,KAAK,CAAC;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theme/theme-dark/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theme/theme-dark/index.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,SAAS,QAOV,CAAC;AAEb,eAAe,SAAS,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import themeDarkPalette from "./theme-dark-palette.css?raw";
|
|
2
2
|
import themeDarkSemantic from "./theme-dark-semantic.css?raw";
|
|
3
|
+
import themeDarkSemanticChart from "./theme-dark-semantic-chart.css?raw";
|
|
3
4
|
import themeDarkSemanticEditor from "./theme-dark-semantic-editor.css?raw";
|
|
4
5
|
import themeDarkSemanticGrid from "./theme-dark-semantic-grid.css?raw";
|
|
5
6
|
import themeDarkComponents from "./theme-dark-components.css?raw";
|
|
@@ -40,6 +41,6 @@ import themeDarkComponents from "./theme-dark-components.css?raw";
|
|
|
40
41
|
* --dh-color-from-dark-components: #000;
|
|
41
42
|
* }
|
|
42
43
|
*/
|
|
43
|
-
export var themeDark = [themeDarkPalette, themeDarkSemantic, themeDarkSemanticEditor, themeDarkSemanticGrid, themeDarkComponents].join('\n');
|
|
44
|
+
export var themeDark = [themeDarkPalette, themeDarkSemantic, themeDarkSemanticChart, themeDarkSemanticEditor, themeDarkSemanticGrid, themeDarkComponents].join('\n');
|
|
44
45
|
export default themeDark;
|
|
45
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["themeDarkPalette","themeDarkSemantic","themeDarkSemanticEditor","themeDarkSemanticGrid","themeDarkComponents","themeDark","join"],"sources":["../../../src/theme/theme-dark/index.ts"],"sourcesContent":["import themeDarkPalette from './theme-dark-palette.css?raw';\nimport themeDarkSemantic from './theme-dark-semantic.css?raw';\nimport themeDarkSemanticEditor from './theme-dark-semantic-editor.css?raw';\nimport themeDarkSemanticGrid from './theme-dark-semantic-grid.css?raw';\nimport themeDarkComponents from './theme-dark-components.css?raw';\n\n/**\n * DH theme variables are imported via Vite `?raw` query which provides the\n * text content of the variable files as a string. The exported theme is just a\n * concatenation of the contents of all of these imports.\n *\n * Note that ?raw / ?inline imports are natively supported by Vite, but consumers\n * of @deephaven/components using Webpack will need to add a rule to their module\n * config.\n * e.g.\n * module: {\n * rules: [\n * {\n * resourceQuery: /inline/,\n * type: 'asset/source',\n * },\n * ],\n * },\n *\n * e.g.\n *\n * :root {\n * --dh-color-from-dark-palette: #fff;\n * --dh-color-from-dark-palette2: #ccc;\n * }\n * :root {\n * --dh-color-from-dark-semantic: #000;\n * }\n * :root {\n * --dh-color-from-dark-semantic-editor: #000;\n * }\n * :root {\n * --dh-color-from-dark-semantic-grid: #000;\n * }\n * :root {\n * --dh-color-from-dark-components: #000;\n * }\n */\nexport const themeDark = [\n themeDarkPalette,\n themeDarkSemantic,\n themeDarkSemanticEditor,\n themeDarkSemanticGrid,\n themeDarkComponents,\n].join('\\n');\n\nexport default themeDark;\n"],"mappings":"OAAOA,gBAAgB;AAAA,OAChBC,iBAAiB;AAAA,OACjBC,uBAAuB;AAAA,OACvBC,qBAAqB;AAAA,OACrBC,mBAAmB;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","names":["themeDarkPalette","themeDarkSemantic","themeDarkSemanticChart","themeDarkSemanticEditor","themeDarkSemanticGrid","themeDarkComponents","themeDark","join"],"sources":["../../../src/theme/theme-dark/index.ts"],"sourcesContent":["import themeDarkPalette from './theme-dark-palette.css?raw';\nimport themeDarkSemantic from './theme-dark-semantic.css?raw';\nimport themeDarkSemanticChart from './theme-dark-semantic-chart.css?raw';\nimport themeDarkSemanticEditor from './theme-dark-semantic-editor.css?raw';\nimport themeDarkSemanticGrid from './theme-dark-semantic-grid.css?raw';\nimport themeDarkComponents from './theme-dark-components.css?raw';\n\n/**\n * DH theme variables are imported via Vite `?raw` query which provides the\n * text content of the variable files as a string. The exported theme is just a\n * concatenation of the contents of all of these imports.\n *\n * Note that ?raw / ?inline imports are natively supported by Vite, but consumers\n * of @deephaven/components using Webpack will need to add a rule to their module\n * config.\n * e.g.\n * module: {\n * rules: [\n * {\n * resourceQuery: /inline/,\n * type: 'asset/source',\n * },\n * ],\n * },\n *\n * e.g.\n *\n * :root {\n * --dh-color-from-dark-palette: #fff;\n * --dh-color-from-dark-palette2: #ccc;\n * }\n * :root {\n * --dh-color-from-dark-semantic: #000;\n * }\n * :root {\n * --dh-color-from-dark-semantic-editor: #000;\n * }\n * :root {\n * --dh-color-from-dark-semantic-grid: #000;\n * }\n * :root {\n * --dh-color-from-dark-components: #000;\n * }\n */\nexport const themeDark = [\n themeDarkPalette,\n themeDarkSemantic,\n themeDarkSemanticChart,\n themeDarkSemanticEditor,\n themeDarkSemanticGrid,\n themeDarkComponents,\n].join('\\n');\n\nexport default themeDark;\n"],"mappings":"OAAOA,gBAAgB;AAAA,OAChBC,iBAAiB;AAAA,OACjBC,sBAAsB;AAAA,OACtBC,uBAAuB;AAAA,OACvBC,qBAAqB;AAAA,OACrBC,mBAAmB;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,SAAS,GAAG,CACvBN,gBAAgB,EAChBC,iBAAiB,EACjBC,sBAAsB,EACtBC,uBAAuB,EACvBC,qBAAqB,EACrBC,mBAAmB,CACpB,CAACE,IAAI,CAAC,IAAI,CAAC;AAEZ,eAAeD,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--dh-color-chart-bg: var(--dh-color-content-background);--dh-color-chart-plot-bg: var(--dh-color-gray-200);--dh-color-chart-title: var(--dh-color-white);--dh-color-chart-colorway: var(--dh-color-visual-cyan) var(--dh-color-visual-green) var(--dh-color-visual-yellow) var(--dh-color-visual-purple) var(--dh-color-visual-orange) var(--dh-color-visual-red) var(--dh-color-visual-chartreuse) var(--dh-color-visual-fuchsia) var(--dh-color-visual-seafoam) var(--dh-color-visual-magenta) var(--dh-color-white);--dh-color-chart-grid: var(--dh-color-gray-400);--dh-color-chart-axis-line: var(--dh-color-gray-500);--dh-color-chart-axis-line-zero: var(--dh-color-gray-700);--dh-color-chart-active: var(--dh-color-accent-600);--dh-color-chart-range-bg: hsla(var(--dh-color-gray-hue), 1%, 36%, 0.7);--dh-color-chart-area: var(--dh-color-visual-blue);--dh-color-chart-trend: var(--dh-color-green-1200);--dh-color-chart-error-band-line: var(--dh-color-green-1400);--dh-color-chart-error-band-fill: hsla( var(--dh-color-green-hue), 71%, 70%, 0.1 );--dh-color-chart-ohlc-increase: var(--dh-color-visual-green);--dh-color-chart-ohlc-decrease: var(--dh-color-visual-red);--dh-color-chart-line-deprecated: var(--dh-color-visual-green)}/*# sourceMappingURL=theme-dark-semantic-chart.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../../src/theme/theme-dark/theme-dark-semantic-chart.css"],"names":[],"mappings":"AAEA,MACE,wDACA,mDACA,8CAGA,8VAMA,gDACA,qDACA,0DACA,oDAGA,wEACA,mDACA,mDAGA,6DAGA,mFAQA,6DACA,2DAOA","file":"theme-dark-semantic-chart.css","sourcesContent":["/* stylelint-disable alpha-value-notation */\n/* stylelint-disable custom-property-empty-line-before */\n:root {\n --dh-color-chart-bg: var(--dh-color-content-background);\n --dh-color-chart-plot-bg: var(--dh-color-gray-200);\n --dh-color-chart-title: var(--dh-color-white);\n\n /* Colorway */\n --dh-color-chart-colorway: var(--dh-color-visual-cyan)\n var(--dh-color-visual-green) var(--dh-color-visual-yellow)\n var(--dh-color-visual-purple) var(--dh-color-visual-orange)\n var(--dh-color-visual-red) var(--dh-color-visual-chartreuse)\n var(--dh-color-visual-fuchsia) var(--dh-color-visual-seafoam)\n var(--dh-color-visual-magenta) var(--dh-color-white);\n --dh-color-chart-grid: var(--dh-color-gray-400);\n --dh-color-chart-axis-line: var(--dh-color-gray-500);\n --dh-color-chart-axis-line-zero: var(--dh-color-gray-700);\n --dh-color-chart-active: var(--dh-color-accent-600);\n\n /* Update hsl components to --dh-color-gray-500-hsl as part of PR #1603 */\n --dh-color-chart-range-bg: hsla(var(--dh-color-gray-hue), 1%, 36%, 0.7);\n --dh-color-chart-area: var(--dh-color-visual-blue);\n --dh-color-chart-trend: var(--dh-color-green-1200);\n\n /* Error band */\n --dh-color-chart-error-band-line: var(--dh-color-green-1400);\n\n /* Update hsl components to --dh-color-green-1200-hsl base color defined by PR #1603 */\n --dh-color-chart-error-band-fill: hsla(\n var(--dh-color-green-hue),\n 71%,\n 70%,\n 0.1\n );\n\n /* OHLC */\n --dh-color-chart-ohlc-increase: var(--dh-color-visual-green);\n --dh-color-chart-ohlc-decrease: var(--dh-color-visual-red);\n\n /* \n * This color shows up in the styleguide, but it doesn't seem to be consumed\n * in production code. There has been discussion about it not being needed \n * anymore. \n */\n --dh-color-chart-line-deprecated: var(--dh-color-visual-green);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Deephaven React component library",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@adobe/react-spectrum": "^3.29.0",
|
|
28
|
-
"@deephaven/icons": "^0.
|
|
29
|
-
"@deephaven/log": "^0.
|
|
30
|
-
"@deephaven/react-hooks": "^0.
|
|
31
|
-
"@deephaven/utils": "^0.
|
|
28
|
+
"@deephaven/icons": "^0.54.0",
|
|
29
|
+
"@deephaven/log": "^0.54.0",
|
|
30
|
+
"@deephaven/react-hooks": "^0.54.0",
|
|
31
|
+
"@deephaven/utils": "^0.54.0",
|
|
32
32
|
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
|
33
33
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
34
34
|
"@react-spectrum/theme-default": "^3.5.1",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"react-dom": "^17.x"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@deephaven/mocks": "^0.
|
|
55
|
+
"@deephaven/mocks": "^0.54.0"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "724c84e40aa8a716f10f39c33019a5301bfd5dab"
|
|
69
69
|
}
|