@lingxiteam/theme-utils 0.5.3 → 0.5.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.
Files changed (127) hide show
  1. package/dist/config/Button.d.ts +113 -0
  2. package/dist/config/Button.js +277 -0
  3. package/dist/config/Card.d.ts +144 -0
  4. package/dist/config/Card.js +162 -0
  5. package/dist/config/Cascader.d.ts +196 -0
  6. package/dist/config/Cascader.js +225 -0
  7. package/dist/config/Checkbox.d.ts +162 -0
  8. package/dist/config/Checkbox.js +178 -0
  9. package/dist/config/CheckboxGroup.d.ts +184 -0
  10. package/dist/config/CheckboxGroup.js +192 -0
  11. package/dist/config/Collapse.d.ts +186 -0
  12. package/dist/config/Collapse.js +330 -0
  13. package/dist/config/Container.d.ts +275 -0
  14. package/dist/config/Container.js +301 -0
  15. package/dist/config/DatePicker.d.ts +179 -0
  16. package/dist/config/DatePicker.js +179 -0
  17. package/dist/config/Description.d.ts +106 -0
  18. package/dist/config/Description.js +126 -0
  19. package/dist/config/Divider.d.ts +61 -0
  20. package/dist/config/Divider.js +61 -0
  21. package/dist/config/Form.d.ts +3071 -0
  22. package/dist/config/Form.js +1358 -0
  23. package/dist/config/Icon.d.ts +55 -0
  24. package/dist/config/Icon.js +55 -0
  25. package/dist/config/Input.d.ts +159 -0
  26. package/dist/config/Input.js +159 -0
  27. package/dist/config/InputNumber.d.ts +154 -0
  28. package/dist/config/InputNumber.js +154 -0
  29. package/dist/config/Link.d.ts +128 -0
  30. package/dist/config/Link.js +120 -0
  31. package/dist/config/MultipleSelect.d.ts +167 -0
  32. package/dist/config/MultipleSelect.js +175 -0
  33. package/dist/config/Radio.d.ts +239 -0
  34. package/dist/config/Radio.js +261 -0
  35. package/dist/config/RangePicker.d.ts +182 -0
  36. package/dist/config/RangePicker.js +182 -0
  37. package/dist/config/Select.d.ts +190 -0
  38. package/dist/config/Select.js +198 -0
  39. package/dist/config/StdUpload.d.ts +197 -0
  40. package/dist/config/StdUpload.js +211 -0
  41. package/dist/config/Switch.d.ts +141 -0
  42. package/dist/config/Switch.js +151 -0
  43. package/dist/config/Table.d.ts +482 -0
  44. package/dist/config/Table.js +560 -0
  45. package/dist/config/Tabs.d.ts +230 -0
  46. package/dist/config/Tabs.js +970 -0
  47. package/dist/config/Tag.d.ts +173 -0
  48. package/dist/config/Tag.js +548 -0
  49. package/dist/config/Text.d.ts +34 -0
  50. package/dist/config/Text.js +34 -0
  51. package/dist/config/TextArea.d.ts +151 -0
  52. package/dist/config/TextArea.js +151 -0
  53. package/dist/config/TimePicker.d.ts +180 -0
  54. package/dist/config/TimePicker.js +180 -0
  55. package/dist/config/Tree.d.ts +151 -0
  56. package/dist/config/Tree.js +195 -0
  57. package/dist/config/TreeSelect.d.ts +197 -0
  58. package/dist/config/TreeSelect.js +213 -0
  59. package/dist/css.d.ts +6 -0
  60. package/dist/css.js +126 -0
  61. package/dist/demo.d.ts +5 -0
  62. package/dist/demo.js +79 -0
  63. package/dist/h5config/Accordion.d.ts +410 -0
  64. package/dist/h5config/Accordion.js +548 -0
  65. package/dist/h5config/Button.d.ts +142 -0
  66. package/dist/h5config/Button.js +253 -0
  67. package/dist/h5config/Card.d.ts +275 -0
  68. package/dist/h5config/Card.js +535 -0
  69. package/dist/h5config/DAddressPicker.d.ts +188 -0
  70. package/dist/h5config/DAddressPicker.js +230 -0
  71. package/dist/h5config/DCheckbox.d.ts +202 -0
  72. package/dist/h5config/DCheckbox.js +248 -0
  73. package/dist/h5config/DForm.d.ts +1597 -0
  74. package/dist/h5config/DForm.js +932 -0
  75. package/dist/h5config/DMultiplePicker.d.ts +189 -0
  76. package/dist/h5config/DMultiplePicker.js +235 -0
  77. package/dist/h5config/DformDate.d.ts +191 -0
  78. package/dist/h5config/DformDate.js +233 -0
  79. package/dist/h5config/DformFile.d.ts +277 -0
  80. package/dist/h5config/DformFile.js +292 -0
  81. package/dist/h5config/DformImagePicker.d.ts +138 -0
  82. package/dist/h5config/DformImagePicker.js +156 -0
  83. package/dist/h5config/DformInput.d.ts +189 -0
  84. package/dist/h5config/DformInput.js +231 -0
  85. package/dist/h5config/DformInputNumber.d.ts +173 -0
  86. package/dist/h5config/DformInputNumber.js +215 -0
  87. package/dist/h5config/DformPicker.d.ts +190 -0
  88. package/dist/h5config/DformPicker.js +236 -0
  89. package/dist/h5config/DformRadio.d.ts +210 -0
  90. package/dist/h5config/DformRadio.js +256 -0
  91. package/dist/h5config/DformRangePicker.d.ts +195 -0
  92. package/dist/h5config/DformRangePicker.js +237 -0
  93. package/dist/h5config/DformSelect.d.ts +198 -0
  94. package/dist/h5config/DformSelect.js +262 -0
  95. package/dist/h5config/DformSwitch.d.ts +145 -0
  96. package/dist/h5config/DformSwitch.js +163 -0
  97. package/dist/h5config/DformTextArea.d.ts +184 -0
  98. package/dist/h5config/DformTextArea.js +226 -0
  99. package/dist/h5config/Divider.d.ts +53 -0
  100. package/dist/h5config/Divider.js +90 -0
  101. package/dist/h5config/FilterItems.d.ts +154 -0
  102. package/dist/h5config/FilterItems.js +204 -0
  103. package/dist/h5config/Grid.d.ts +235 -0
  104. package/dist/h5config/Grid.js +278 -0
  105. package/dist/h5config/Icon.d.ts +54 -0
  106. package/dist/h5config/Icon.js +54 -0
  107. package/dist/h5config/Link.d.ts +51 -0
  108. package/dist/h5config/Link.js +51 -0
  109. package/dist/h5config/LoadMore.d.ts +527 -0
  110. package/dist/h5config/LoadMore.js +940 -0
  111. package/dist/h5config/NoticeBarPlus.d.ts +111 -0
  112. package/dist/h5config/NoticeBarPlus.js +141 -0
  113. package/dist/h5config/SearchView.d.ts +135 -0
  114. package/dist/h5config/SearchView.js +177 -0
  115. package/dist/h5config/StaticTabs.d.ts +121 -0
  116. package/dist/h5config/StaticTabs.js +180 -0
  117. package/dist/h5config/Table.d.ts +197 -0
  118. package/dist/h5config/Table.js +589 -0
  119. package/dist/index.d.ts +4 -0
  120. package/dist/index.js +4 -0
  121. package/dist/lx-mobile.d.ts +23 -0
  122. package/dist/lx-mobile.js +174 -0
  123. package/dist/lx.d.ts +24 -0
  124. package/dist/lx.js +139 -0
  125. package/dist/utils.d.ts +12 -0
  126. package/dist/utils.js +67 -0
  127. package/package.json +1 -1
@@ -0,0 +1,174 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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 { stringifyCss, parseCss, prefixAnyCSS } from "./css";
8
+ import { objToListByGroupsName } from "./utils";
9
+ import { Button } from "./h5config/Button";
10
+ import { DynamicTable } from "./h5config/Table";
11
+ import { FilterItems } from "./h5config/FilterItems";
12
+ import { NoticeBarPlus } from "./h5config/NoticeBarPlus";
13
+ import { StaticTabs } from "./h5config/StaticTabs";
14
+ import { Grid } from "./h5config/Grid";
15
+ import { SearchView } from "./h5config/SearchView";
16
+ import { DForm } from "./h5config/DForm";
17
+ import { DformInput } from "./h5config/DformInput";
18
+ import { DformTextArea } from "./h5config/DformTextArea";
19
+ import { DformInputNumber } from "./h5config/DformInputNumber";
20
+ import { DformRadio } from "./h5config/DformRadio";
21
+ import { DCheckbox } from "./h5config/DCheckbox";
22
+ import { DformPicker } from "./h5config/DformPicker";
23
+ import { DMultiplePicker } from "./h5config/DMultiplePicker";
24
+ import { DformSelect } from "./h5config/DformSelect";
25
+ import { DAddressPicker } from "./h5config/DAddressPicker";
26
+ import { DformDate } from "./h5config/DformDate";
27
+ import { DformRangePicker } from "./h5config/DformRangePicker";
28
+ import { DformSwitch } from "./h5config/DformSwitch";
29
+ import { DformImagePicker } from "./h5config/DformImagePicker";
30
+ import { DformFile } from "./h5config/DformFile";
31
+ import { Icon } from "./h5config/Icon";
32
+ import { ALink } from "./h5config/Link";
33
+ import { Card } from "./h5config/Card";
34
+ import { Accordion } from "./h5config/Accordion";
35
+ export var THEME_KEYS_MOBILE_TITLE = {
36
+ '@brand-primary': '主题色',
37
+ '@border-color-base': '边框色',
38
+ '@font-size-base': '主字号',
39
+ '@color-text-base': '主文本色',
40
+ '@color-text-placeholder': '警告色',
41
+ '@font-size-heading': '标题字',
42
+ '@button-font-size': '按钮字号',
43
+ '@fill-base': '背景色',
44
+ '@brand-primary-tap': '点击色',
45
+ '@color-link': '链接色'
46
+ };
47
+ export var MOBILE_ASSETS_CSS_TPL = {
48
+ Icon: Icon,
49
+ ALink: ALink,
50
+ Button: Button,
51
+ // TODO: 分割线 style 写死,最后修改方案
52
+ // Divider,
53
+ Card: Card,
54
+ DynamicTable: DynamicTable,
55
+ FilterItems: FilterItems,
56
+ NoticeBarPlus: NoticeBarPlus,
57
+ StaticTabs: StaticTabs,
58
+ Grid: Grid,
59
+ SearchView: SearchView,
60
+ // TODO: 动态列表自己并没有样式才对
61
+ // LoadMore,
62
+ DForm: DForm,
63
+ DformInput: DformInput,
64
+ DformTextArea: DformTextArea,
65
+ DformInputNumber: DformInputNumber,
66
+ DformRadio: DformRadio,
67
+ DCheckbox: DCheckbox,
68
+ DformPicker: DformPicker,
69
+ DMultiplePicker: DMultiplePicker,
70
+ DformSelect: DformSelect,
71
+ DAddressPicker: DAddressPicker,
72
+ DformDate: DformDate,
73
+ DformRangePicker: DformRangePicker,
74
+ DformSwitch: DformSwitch,
75
+ DformImagePicker: DformImagePicker,
76
+ DformFile: DformFile,
77
+ Accordion: Accordion
78
+ };
79
+ export var mobileExtend = {
80
+ DformInput: 'DForm',
81
+ DformTextArea: 'DForm',
82
+ DformInputNumber: 'DForm',
83
+ DformRadio: 'DForm',
84
+ DCheckbox: 'DForm',
85
+ DformPicker: 'DForm',
86
+ DMultiplePicker: 'DForm',
87
+ DformSelect: 'DForm',
88
+ DAddressPicker: 'DForm',
89
+ DformDate: 'DForm',
90
+ DformRangePicker: 'DForm',
91
+ DformSwitch: 'DForm',
92
+ DformImagePicker: 'DForm',
93
+ DformFile: 'DForm'
94
+ };
95
+ export var MOBILE_ASSETS_COMPONENT_LIST = objToListByGroupsName(Object.values(MOBILE_ASSETS_CSS_TPL));
96
+ export function getMobileItemByType(type) {
97
+ var com = MOBILE_ASSETS_CSS_TPL[type];
98
+ if (!type || !com) return {
99
+ tpl: ''
100
+ };
101
+ return com;
102
+ }
103
+ export function px2rem(obj) {
104
+ var remObj = {};
105
+ for (var key in obj) {
106
+ if (obj.hasOwnProperty(key)) {
107
+ var value = obj[key];
108
+ if (value) {
109
+ var _value;
110
+ var values = (_value = value) === null || _value === void 0 ? void 0 : _value.split(' ');
111
+ if (values.length > 0) {
112
+ var remValues = values.map(function (val) {
113
+ if (val.includes('px')) {
114
+ var parsedValue = parseFloat(val);
115
+ return "".concat(parsedValue / 50, "rem");
116
+ }
117
+ return val;
118
+ });
119
+ value = remValues.join(' ');
120
+ } else if (value.includes('px')) {
121
+ var parsedValue = parseFloat(value);
122
+ value = "".concat(parsedValue / 50, "rem");
123
+ }
124
+ }
125
+ remObj[key] = value;
126
+ }
127
+ }
128
+ return remObj;
129
+ }
130
+ export function rem2px(rem) {
131
+ // TODO: 这个方法不对,现在没用到就没有修改
132
+ var str = rem.split('rem');
133
+ if (!str[0]) return '0';
134
+ return "".concat((Number.parseFloat(str[0]) * 100).toFixed(1), "px");
135
+ }
136
+ export function parseValueRem(values) {
137
+ Object.keys(values).map(function (key) {
138
+ var _values$key;
139
+ if ((_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.includes('rem')) {
140
+ values[key] = rem2px(values[key]);
141
+ }
142
+ return key;
143
+ });
144
+ return values;
145
+ }
146
+
147
+ // 临时解决方案,将只对它有影响的值,生成继承的样式
148
+ export function stringifyMobileCssByTypePreview(type, values) {
149
+ if (mobileExtend[type]) {
150
+ var cfg = getMobileItemByType(mobileExtend[type]);
151
+ var _item = getMobileItemByType(type);
152
+ return stringifyCss(cfg.tpl, px2rem(_objectSpread(_objectSpread({}, cfg.defaultValue[0]), values))) + stringifyCss(_item.tpl, px2rem(values));
153
+ }
154
+ var item = getMobileItemByType(type);
155
+ return stringifyCss(item.tpl, px2rem(values));
156
+ }
157
+ export function stringifyMobileCssByType(type, values) {
158
+ var item = getMobileItemByType(type);
159
+ return stringifyCss(item.tpl, px2rem(values));
160
+ }
161
+ export function parseMobileCssByType(type, css) {
162
+ var item = getMobileItemByType(type);
163
+ return parseValueRem(parseCss(item.tpl, css));
164
+ }
165
+ export function prefixMobileCSS(type, values, prefix) {
166
+ if (mobileExtend[type]) {
167
+ var _cfg$itemCustomTpl;
168
+ var cfg = getMobileItemByType(mobileExtend[type]);
169
+ var _item2 = getMobileItemByType(type);
170
+ return prefixAnyCSS(stringifyCss((_cfg$itemCustomTpl = cfg === null || cfg === void 0 ? void 0 : cfg.itemCustomTpl) !== null && _cfg$itemCustomTpl !== void 0 ? _cfg$itemCustomTpl : cfg === null || cfg === void 0 ? void 0 : cfg.tpl, px2rem(_objectSpread(_objectSpread({}, cfg.defaultValue[0]), values))), prefix, cfg === null || cfg === void 0 ? void 0 : cfg.hasPrefixClass) + prefixAnyCSS(stringifyCss(_item2.tpl, px2rem(values)), prefix, _item2 === null || _item2 === void 0 ? void 0 : _item2.hasPrefixClass);
171
+ }
172
+ var item = getMobileItemByType(type);
173
+ return prefixAnyCSS(stringifyCss(item.tpl, px2rem(values)), prefix, item === null || item === void 0 ? void 0 : item.hasPrefixClass);
174
+ }
package/dist/lx.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ export declare const THEME_KEYS_TITLE: {
2
+ '@primary-color': string;
3
+ '@font-size-base': string;
4
+ '@heading-color': string;
5
+ '@text-color': string;
6
+ '@text-color-secondary': string;
7
+ '@disabled-color': string;
8
+ '@border-radius-base': string;
9
+ '@padding': string;
10
+ '@border-color-base': string;
11
+ '@box-shadow-base': string;
12
+ '@link-color': string;
13
+ '@success-color': string;
14
+ '@warning-color': string;
15
+ '@error-color': string;
16
+ };
17
+ export declare const ASSETS_CSS_TPL: any;
18
+ export declare const pcExtend: any;
19
+ export declare const ASSETS_COMPONENT_LIST: unknown[];
20
+ export declare function getItemByType(type: string): any;
21
+ export declare function stringifyCssByType(type: string, values: any): string;
22
+ export declare function stringifyCssByTypePreview(type: string, values: any): string;
23
+ export declare function parseCssByType(type: string, css: string): any;
24
+ export declare function prefixCSS(type: string, values: any, prefix: string): string;
package/dist/lx.js ADDED
@@ -0,0 +1,139 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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 { stringifyCss, parseCss, prefixAnyCSS } from "./css";
8
+ import { objToListByGroupsName } from "./utils";
9
+ import { Button } from "./config/Button";
10
+ // 文本放在不同的组件下,会有不同的效果,暂不支持配置
11
+ // import { Text } from './config/Text';
12
+ import { Icon } from "./config/Icon";
13
+ import { Link } from "./config/Link";
14
+ import { Container } from "./config/Container";
15
+ import { Form } from "./config/Form";
16
+ import { Input } from "./config/Input";
17
+ import { Card } from "./config/Card";
18
+ import { Collapse } from "./config/Collapse";
19
+ import { Tabs } from "./config/Tabs";
20
+ import { TextArea } from "./config/TextArea";
21
+ import { InputNumber } from "./config/InputNumber";
22
+ import { Radio } from "./config/Radio";
23
+ import { CheckboxGroup } from "./config/CheckboxGroup";
24
+ import { Checkbox } from "./config/Checkbox";
25
+ import { Select } from "./config/Select";
26
+ import { MultipleSelect } from "./config/MultipleSelect";
27
+ import { DatePicker } from "./config/DatePicker";
28
+ import { TimePicker } from "./config/TimePicker";
29
+ import { RangePicker } from "./config/RangePicker";
30
+ import { TreeSelect } from "./config/TreeSelect";
31
+ import { Cascader } from "./config/Cascader";
32
+ import { Switch } from "./config/Switch";
33
+ import { StdUpload } from "./config/StdUpload";
34
+ import { Table } from "./config/Table";
35
+ import { Tag } from "./config/Tag";
36
+ import { Tree } from "./config/Tree";
37
+ import { Description } from "./config/Description";
38
+ export var THEME_KEYS_TITLE = {
39
+ '@primary-color': '主题色',
40
+ '@font-size-base': '主字号',
41
+ '@heading-color': '标题色',
42
+ '@text-color': '主文本色',
43
+ '@text-color-secondary': '次文本色',
44
+ '@disabled-color': '失效色',
45
+ '@border-radius-base': '圆角',
46
+ '@padding': '边距',
47
+ '@border-color-base': '边框颜色',
48
+ '@box-shadow-base': '浮层阴影',
49
+ '@link-color': '链接色',
50
+ '@success-color': '成功色',
51
+ '@warning-color': '警告色',
52
+ '@error-color': '错误色'
53
+ };
54
+ export var ASSETS_CSS_TPL = {
55
+ Button: Button,
56
+ Container: Container,
57
+ Form: Form,
58
+ Card: Card,
59
+ Collapse: Collapse,
60
+ Tabs: Tabs,
61
+ Icon: Icon,
62
+ Link: Link,
63
+ Input: Input,
64
+ TextArea: TextArea,
65
+ InputNumber: InputNumber,
66
+ Radio: Radio,
67
+ CheckboxGroup: CheckboxGroup,
68
+ Checkbox: Checkbox,
69
+ Select: Select,
70
+ MultipleSelect: MultipleSelect,
71
+ DatePicker: DatePicker,
72
+ TimePicker: TimePicker,
73
+ RangePicker: RangePicker,
74
+ TreeSelect: TreeSelect,
75
+ Cascader: Cascader,
76
+ Switch: Switch,
77
+ StdUpload: StdUpload,
78
+ Table: Table,
79
+ Tag: Tag,
80
+ Tree: Tree,
81
+ Description: Description
82
+ };
83
+ export var pcExtend = {
84
+ Input: 'Form',
85
+ TextArea: 'Form',
86
+ InputNumber: 'Form',
87
+ Radio: 'Form',
88
+ CheckboxGroup: 'Form',
89
+ Checkbox: 'Form',
90
+ Select: 'Form',
91
+ MultipleSelect: 'Form',
92
+ DatePicker: 'Form',
93
+ TimePicker: 'Form',
94
+ RangePicker: 'Form',
95
+ TreeSelect: 'Form',
96
+ Cascader: 'Form',
97
+ Switch: 'Form',
98
+ StdUpload: 'Form',
99
+ Table: 'Container',
100
+ Card: 'Container',
101
+ Collapse: 'Container'
102
+ };
103
+ export var ASSETS_COMPONENT_LIST = objToListByGroupsName(Object.values(ASSETS_CSS_TPL));
104
+ export function getItemByType(type) {
105
+ var com = ASSETS_CSS_TPL[type];
106
+ if (!type || !com) return {
107
+ tpl: ''
108
+ };
109
+ return com;
110
+ }
111
+ export function stringifyCssByType(type, values) {
112
+ var item = getItemByType(type);
113
+ return stringifyCss(item.tpl, values);
114
+ }
115
+
116
+ // 临时解决方案,将只对它有影响的值,生成继承的样式
117
+ export function stringifyCssByTypePreview(type, values) {
118
+ if (pcExtend[type]) {
119
+ var cfg = getItemByType(pcExtend[type]);
120
+ var _item = getItemByType(type);
121
+ return stringifyCss(cfg.tpl, _objectSpread(_objectSpread({}, cfg.defaultValue[0]), values)) + stringifyCss(_item.tpl, values);
122
+ }
123
+ var item = getItemByType(type);
124
+ return stringifyCss(item.tpl, values);
125
+ }
126
+ export function parseCssByType(type, css) {
127
+ var item = getItemByType(type);
128
+ return parseCss(item.tpl, css);
129
+ }
130
+ export function prefixCSS(type, values, prefix) {
131
+ if (pcExtend[type]) {
132
+ var _cfg$itemCustomTpl;
133
+ var cfg = getItemByType(pcExtend[type]);
134
+ var _item2 = getItemByType(type);
135
+ return prefixAnyCSS(stringifyCss((_cfg$itemCustomTpl = cfg === null || cfg === void 0 ? void 0 : cfg.itemCustomTpl) !== null && _cfg$itemCustomTpl !== void 0 ? _cfg$itemCustomTpl : cfg === null || cfg === void 0 ? void 0 : cfg.tpl, _objectSpread(_objectSpread({}, cfg.defaultValue[0]), values)), prefix, cfg !== null && cfg !== void 0 && cfg.hasCustomNoPrefixClass ? false : cfg === null || cfg === void 0 ? void 0 : cfg.hasPrefixClass) + prefixAnyCSS(stringifyCss(_item2.tpl, values), prefix, _item2 === null || _item2 === void 0 ? void 0 : _item2.hasPrefixClass);
136
+ }
137
+ var item = getItemByType(type);
138
+ return prefixAnyCSS(stringifyCss(item.tpl, values), prefix, item === null || item === void 0 ? void 0 : item.hasPrefixClass);
139
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 根据 groupsName 将对象分成数组
3
+ * @param obj
4
+ * @returns
5
+ */
6
+ export declare function objToListByGroupsName(obj: any): unknown[];
7
+ /**
8
+ * (内部方法) 根据 groupsName 将对象分成数组
9
+ * @param obj
10
+ * @returns
11
+ */
12
+ export declare function __objToListByGroupsName(obj: any): unknown[];
package/dist/utils.js ADDED
@@ -0,0 +1,67 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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
+ /**
8
+ * 根据 groupsName 将对象分成数组
9
+ * @param obj
10
+ * @returns
11
+ */
12
+ export function objToListByGroupsName(obj) {
13
+ var groups = {};
14
+
15
+ // 遍历对象,根据groupsName属性进行分组
16
+ // eslint-disable-next-line guard-for-in
17
+ for (var key in obj) {
18
+ var item = obj[key];
19
+ var groupName = item.groupsName;
20
+ if (!groups[groupName]) {
21
+ groups[groupName] = {
22
+ groupName: groupName,
23
+ id: Object.keys(groups).length + 1,
24
+ items: []
25
+ };
26
+ }
27
+ groups[groupName].items.push(_objectSpread({
28
+ key: key
29
+ }, item));
30
+ }
31
+
32
+ // 将分组转换为数组
33
+ var result = Object.values(groups);
34
+ return result;
35
+ }
36
+
37
+ /**
38
+ * (内部方法) 根据 groupsName 将对象分成数组
39
+ * @param obj
40
+ * @returns
41
+ */
42
+ export function __objToListByGroupsName(obj) {
43
+ var groups = {};
44
+
45
+ // 遍历对象,根据groupsName属性进行分组
46
+ // eslint-disable-next-line guard-for-in
47
+ for (var key in obj) {
48
+ var item = obj[key];
49
+ var groupName = item.groupsName;
50
+ if (!groups[groupName]) {
51
+ groups[groupName] = {
52
+ groupName: groupName,
53
+ id: Object.keys(groups).length + 1,
54
+ items: []
55
+ };
56
+ }
57
+ groups[groupName].items.push({
58
+ key: key,
59
+ type: item.type,
60
+ icon: item.icon
61
+ });
62
+ }
63
+
64
+ // 将分组转换为数组
65
+ var result = Object.values(groups);
66
+ return result;
67
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/theme-utils",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",