@arim-aisdc/public-components 0.0.41 → 0.0.42

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.
@@ -4,9 +4,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { PublicThemeVariablesConfig } from "../../themes/variablesConfig";
7
8
  import { useContext, useEffect, useMemo } from 'react';
8
9
  import ConfigContext, { DEFAULT_CONTEXT } from "./context";
9
- import { _setTheme } from "./theme";
10
+ import { setCssVars } from "./cssVars";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  export var ConfigProvider = function ConfigProvider(_ref) {
12
13
  var _ref$config = _ref.config,
@@ -15,12 +16,11 @@ export var ConfigProvider = function ConfigProvider(_ref) {
15
16
  var memoedConfig = useMemo(function () {
16
17
  return _objectSpread(_objectSpread({}, DEFAULT_CONTEXT), config);
17
18
  }, [JSON.stringify(config)]);
18
- var _config$theme = config.theme,
19
- theme = _config$theme === void 0 ? 'light' : _config$theme,
20
- variablesConfig = config.variablesConfig;
19
+ var _config$variablesJson = config.variablesJson,
20
+ variablesJson = _config$variablesJson === void 0 ? PublicThemeVariablesConfig['light'] : _config$variablesJson;
21
21
  useEffect(function () {
22
- _setTheme(theme, variablesConfig);
23
- }, [theme]);
22
+ setCssVars(variablesJson);
23
+ }, [variablesJson]);
24
24
  return /*#__PURE__*/_jsx(ConfigContext.Provider, {
25
25
  value: memoedConfig,
26
26
  children: children
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
- import type { VariablesConfigType } from './type';
2
+ import type { VariablesJsonType } from './type';
3
3
  export interface ConfigConsumerProps {
4
4
  userId?: string;
5
5
  tableKeyPrefixCls?: string;
6
6
  theme?: string;
7
7
  /**主题变量配置文件 */
8
- variablesConfig?: VariablesConfigType;
8
+ variablesJson?: VariablesJsonType;
9
9
  }
10
10
  export declare const DEFAULT_CONTEXT: {
11
11
  theme: string;
@@ -0,0 +1 @@
1
+ export declare const setCssVars: (cssVars?: {}, node?: HTMLElement) => void;
@@ -0,0 +1,16 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ export var setCssVars = function setCssVars() {
8
+ var cssVars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
+ var node = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.documentElement || document.body;
10
+ Object.entries(cssVars).forEach(function (_ref) {
11
+ var _ref2 = _slicedToArray(_ref, 2),
12
+ key = _ref2[0],
13
+ value = _ref2[1];
14
+ return node.style.setProperty(key, value);
15
+ });
16
+ };
@@ -1,3 +1,3 @@
1
1
  export { ConfigProvider, useConfig } from './ConfigProvider';
2
2
  export type { ConfigConsumerProps } from './context';
3
- export type { VariablesConfigType } from './type';
3
+ export type { VariablesJsonType } from './type';
@@ -1,5 +1,3 @@
1
- export type VariablesConfigType = {
2
- [theme: string]: {
3
- [code: string]: string;
4
- };
1
+ export type VariablesJsonType = {
2
+ [code: string]: string;
5
3
  };
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -1,4 +0,0 @@
1
- import { PublicThemeVariablesConfig } from '../../themes/variablesConfig';
2
- import { VariablesConfigType } from './type';
3
- export type ThemeType = keyof typeof PublicThemeVariablesConfig;
4
- export declare const _setTheme: (themeKey: any, variablesConfig?: VariablesConfigType) => void;
@@ -1,22 +0,0 @@
1
- import cssVars from 'css-vars-ponyfill';
2
- import { PublicThemeVariablesConfig } from "../../themes/variablesConfig";
3
- export var _setTheme = function _setTheme(themeKey) {
4
- var variablesConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PublicThemeVariablesConfig;
5
- var themeKeys = Object.keys(variablesConfig);
6
- var KEY;
7
- if (themeKeys.includes(themeKey)) {
8
- KEY = themeKey;
9
- } else {
10
- KEY = 'light';
11
- }
12
- cssVars({
13
- onlyLegacy: true,
14
- variables: variablesConfig[KEY],
15
- onError: function onError() {
16
- cssVars({
17
- onlyLegacy: true,
18
- variables: variablesConfig[KEY]
19
- });
20
- }
21
- });
22
- };