@snack-uikit/code-editor 0.4.3 → 0.4.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.4.4 (2024-11-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PDS-1023:** fix calc isDark ([8c34b37](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/8c34b3758b20ef57c4f68e1dbc0472acf6ef611c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.4.3 (2024-11-14)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -111,7 +111,7 @@ function CodeEditor(_a) {
111
111
  }, (0, utils_1.extractSupportProps)(props), {
112
112
  ref: setWrapperElement,
113
113
  children: (0, jsx_runtime_1.jsx)(react_1.Editor, Object.assign({}, props, {
114
- theme: (theme !== null && theme !== void 0 ? theme : dark) ? 'snackDark' : 'snack',
114
+ theme: theme !== null && theme !== void 0 ? theme : dark ? 'snackDark' : 'snack',
115
115
  className: (0, classnames_1.default)({
116
116
  [styles_module_scss_1.default.editor]: hasBackground
117
117
  }),
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
7
+ };
3
8
  Object.defineProperty(exports, "__esModule", {
4
9
  value: true
5
10
  });
@@ -7,10 +12,9 @@ exports.rgb2hsl = rgb2hsl;
7
12
  exports.isDark = isDark;
8
13
  exports.initLoaderConfig = initLoaderConfig;
9
14
  const react_1 = require("@monaco-editor/react");
15
+ const chroma_js_1 = __importDefault(require("chroma-js"));
10
16
  function rgb2hsl(HTMLcolor) {
11
- const r = parseInt(HTMLcolor.substring(1, 3), 16) / 255;
12
- const g = parseInt(HTMLcolor.substring(3, 5), 16) / 255;
13
- const b = parseInt(HTMLcolor.substring(5, 7), 16) / 255;
17
+ const [r, g, b] = chroma_js_1.default.valid(HTMLcolor) ? (0, chroma_js_1.default)(HTMLcolor).rgb().map(c => c / 255) : [0, 0, 0];
14
18
  const max = Math.max(r, g, b),
15
19
  min = Math.min(r, g, b);
16
20
  let h, s;
@@ -86,5 +86,5 @@ export function CodeEditor(_a) {
86
86
  fontFamily: themeValues.mono.body.s['font-family'],
87
87
  }
88
88
  : DEFAULT_THEME_OPTIONS.mono.s)), options)), [options, themeValues === null || themeValues === void 0 ? void 0 : themeValues.mono]);
89
- return (_jsx("div", Object.assign({ className: className }, extractSupportProps(props), { ref: setWrapperElement, children: _jsx(Editor, Object.assign({}, props, { theme: (theme !== null && theme !== void 0 ? theme : dark) ? 'snackDark' : 'snack', className: cn({ [styles.editor]: hasBackground }), loading: loading !== null && loading !== void 0 ? loading : _jsx(Spinner, {}), options: mergedOptions, onMount: onEditorMount })) })));
89
+ return (_jsx("div", Object.assign({ className: className }, extractSupportProps(props), { ref: setWrapperElement, children: _jsx(Editor, Object.assign({}, props, { theme: theme !== null && theme !== void 0 ? theme : (dark ? 'snackDark' : 'snack'), className: cn({ [styles.editor]: hasBackground }), loading: loading !== null && loading !== void 0 ? loading : _jsx(Spinner, {}), options: mergedOptions, onMount: onEditorMount })) })));
90
90
  }
@@ -1,8 +1,11 @@
1
1
  import { loader } from '@monaco-editor/react';
2
+ import chroma from 'chroma-js';
2
3
  export function rgb2hsl(HTMLcolor) {
3
- const r = parseInt(HTMLcolor.substring(1, 3), 16) / 255;
4
- const g = parseInt(HTMLcolor.substring(3, 5), 16) / 255;
5
- const b = parseInt(HTMLcolor.substring(5, 7), 16) / 255;
4
+ const [r, g, b] = chroma.valid(HTMLcolor)
5
+ ? chroma(HTMLcolor)
6
+ .rgb()
7
+ .map(c => c / 255)
8
+ : [0, 0, 0];
6
9
  const max = Math.max(r, g, b), min = Math.min(r, g, b);
7
10
  let h, s;
8
11
  const l = (max + min) / 2;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.4.3",
7
+ "version": "0.4.4",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -39,7 +39,11 @@
39
39
  "@monaco-editor/react": "4.6.0",
40
40
  "@snack-uikit/loaders": "0.8.1",
41
41
  "@snack-uikit/utils": "3.5.0",
42
+ "chroma-js": "3.1.2",
42
43
  "classnames": "2.5.1"
43
44
  },
44
- "gitHead": "b9670e68c6af5fdd5dfceeae29ef3af8c89e5e6b"
45
+ "devDependencies": {
46
+ "@types/chroma-js": "2.4.4"
47
+ },
48
+ "gitHead": "384206758e2e0c36e025557821f55035662cc9f5"
45
49
  }
@@ -127,7 +127,7 @@ export function CodeEditor({
127
127
  <div className={className} {...extractSupportProps(props)} ref={setWrapperElement}>
128
128
  <Editor
129
129
  {...props}
130
- theme={theme ?? dark ? 'snackDark' : 'snack'}
130
+ theme={theme ?? (dark ? 'snackDark' : 'snack')}
131
131
  className={cn({ [styles.editor]: hasBackground })}
132
132
  loading={loading ?? <Spinner />}
133
133
  options={mergedOptions}
@@ -1,9 +1,12 @@
1
1
  import { loader } from '@monaco-editor/react';
2
+ import chroma from 'chroma-js';
2
3
 
3
4
  export function rgb2hsl(HTMLcolor: string) {
4
- const r = parseInt(HTMLcolor.substring(1, 3), 16) / 255;
5
- const g = parseInt(HTMLcolor.substring(3, 5), 16) / 255;
6
- const b = parseInt(HTMLcolor.substring(5, 7), 16) / 255;
5
+ const [r, g, b] = chroma.valid(HTMLcolor)
6
+ ? chroma(HTMLcolor)
7
+ .rgb()
8
+ .map(c => c / 255)
9
+ : [0, 0, 0];
7
10
 
8
11
  const max = Math.max(r, g, b),
9
12
  min = Math.min(r, g, b);