@lingxiteam/theme-utils 0.1.3

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 (128) hide show
  1. package/README.md +83 -0
  2. package/dist/config/Button.d.ts +101 -0
  3. package/dist/config/Button.js +265 -0
  4. package/dist/config/Card.d.ts +137 -0
  5. package/dist/config/Card.js +149 -0
  6. package/dist/config/Cascader.d.ts +179 -0
  7. package/dist/config/Cascader.js +208 -0
  8. package/dist/config/Checkbox.d.ts +161 -0
  9. package/dist/config/Checkbox.js +161 -0
  10. package/dist/config/CheckboxGroup.d.ts +176 -0
  11. package/dist/config/CheckboxGroup.js +184 -0
  12. package/dist/config/Collapse.d.ts +170 -0
  13. package/dist/config/Collapse.js +308 -0
  14. package/dist/config/Container.d.ts +268 -0
  15. package/dist/config/Container.js +288 -0
  16. package/dist/config/DatePicker.d.ts +163 -0
  17. package/dist/config/DatePicker.js +163 -0
  18. package/dist/config/Description.d.ts +97 -0
  19. package/dist/config/Description.js +117 -0
  20. package/dist/config/Divider.d.ts +61 -0
  21. package/dist/config/Divider.js +61 -0
  22. package/dist/config/Form.d.ts +2700 -0
  23. package/dist/config/Form.js +1214 -0
  24. package/dist/config/Icon.d.ts +51 -0
  25. package/dist/config/Icon.js +51 -0
  26. package/dist/config/Input.d.ts +150 -0
  27. package/dist/config/Input.js +150 -0
  28. package/dist/config/InputNumber.d.ts +145 -0
  29. package/dist/config/InputNumber.js +145 -0
  30. package/dist/config/Link.d.ts +123 -0
  31. package/dist/config/Link.js +115 -0
  32. package/dist/config/MultipleSelect.d.ts +158 -0
  33. package/dist/config/MultipleSelect.js +166 -0
  34. package/dist/config/Radio.d.ts +171 -0
  35. package/dist/config/Radio.js +179 -0
  36. package/dist/config/RangePicker.d.ts +165 -0
  37. package/dist/config/RangePicker.js +165 -0
  38. package/dist/config/Select.d.ts +173 -0
  39. package/dist/config/Select.js +181 -0
  40. package/dist/config/StdUpload.d.ts +204 -0
  41. package/dist/config/StdUpload.js +208 -0
  42. package/dist/config/Switch.d.ts +137 -0
  43. package/dist/config/Switch.js +137 -0
  44. package/dist/config/Table.d.ts +398 -0
  45. package/dist/config/Table.js +527 -0
  46. package/dist/config/Tabs.d.ts +170 -0
  47. package/dist/config/Tabs.js +229 -0
  48. package/dist/config/Tag.d.ts +114 -0
  49. package/dist/config/Tag.js +314 -0
  50. package/dist/config/Text.d.ts +30 -0
  51. package/dist/config/Text.js +30 -0
  52. package/dist/config/TextArea.d.ts +142 -0
  53. package/dist/config/TextArea.js +142 -0
  54. package/dist/config/TimePicker.d.ts +164 -0
  55. package/dist/config/TimePicker.js +164 -0
  56. package/dist/config/Tree.d.ts +131 -0
  57. package/dist/config/Tree.js +175 -0
  58. package/dist/config/TreeSelect.d.ts +180 -0
  59. package/dist/config/TreeSelect.js +196 -0
  60. package/dist/css.d.ts +6 -0
  61. package/dist/css.js +121 -0
  62. package/dist/demo.d.ts +5 -0
  63. package/dist/demo.js +79 -0
  64. package/dist/h5config/Accordion.d.ts +338 -0
  65. package/dist/h5config/Accordion.js +445 -0
  66. package/dist/h5config/Button.d.ts +134 -0
  67. package/dist/h5config/Button.js +245 -0
  68. package/dist/h5config/Card.d.ts +268 -0
  69. package/dist/h5config/Card.js +425 -0
  70. package/dist/h5config/DAddressPicker.d.ts +196 -0
  71. package/dist/h5config/DAddressPicker.js +226 -0
  72. package/dist/h5config/DCheckbox.d.ts +203 -0
  73. package/dist/h5config/DCheckbox.js +237 -0
  74. package/dist/h5config/DForm.d.ts +1607 -0
  75. package/dist/h5config/DForm.js +897 -0
  76. package/dist/h5config/DMultiplePicker.d.ts +197 -0
  77. package/dist/h5config/DMultiplePicker.js +231 -0
  78. package/dist/h5config/DformDate.d.ts +199 -0
  79. package/dist/h5config/DformDate.js +229 -0
  80. package/dist/h5config/DformFile.d.ts +186 -0
  81. package/dist/h5config/DformFile.js +198 -0
  82. package/dist/h5config/DformImagePicker.d.ts +138 -0
  83. package/dist/h5config/DformImagePicker.js +150 -0
  84. package/dist/h5config/DformInput.d.ts +188 -0
  85. package/dist/h5config/DformInput.js +218 -0
  86. package/dist/h5config/DformInputNumber.d.ts +173 -0
  87. package/dist/h5config/DformInputNumber.js +203 -0
  88. package/dist/h5config/DformPicker.d.ts +198 -0
  89. package/dist/h5config/DformPicker.js +232 -0
  90. package/dist/h5config/DformRadio.d.ts +203 -0
  91. package/dist/h5config/DformRadio.js +237 -0
  92. package/dist/h5config/DformRangePicker.d.ts +199 -0
  93. package/dist/h5config/DformRangePicker.js +229 -0
  94. package/dist/h5config/DformSelect.d.ts +208 -0
  95. package/dist/h5config/DformSelect.js +260 -0
  96. package/dist/h5config/DformSwitch.d.ts +146 -0
  97. package/dist/h5config/DformSwitch.js +158 -0
  98. package/dist/h5config/DformTextArea.d.ts +184 -0
  99. package/dist/h5config/DformTextArea.js +214 -0
  100. package/dist/h5config/Divider.d.ts +53 -0
  101. package/dist/h5config/Divider.js +90 -0
  102. package/dist/h5config/FilterItems.d.ts +142 -0
  103. package/dist/h5config/FilterItems.js +181 -0
  104. package/dist/h5config/Grid.d.ts +117 -0
  105. package/dist/h5config/Grid.js +154 -0
  106. package/dist/h5config/Icon.d.ts +54 -0
  107. package/dist/h5config/Icon.js +54 -0
  108. package/dist/h5config/Link.d.ts +47 -0
  109. package/dist/h5config/Link.js +47 -0
  110. package/dist/h5config/LoadMore.d.ts +527 -0
  111. package/dist/h5config/LoadMore.js +940 -0
  112. package/dist/h5config/NoticeBarPlus.d.ts +104 -0
  113. package/dist/h5config/NoticeBarPlus.js +129 -0
  114. package/dist/h5config/SearchView.d.ts +128 -0
  115. package/dist/h5config/SearchView.js +163 -0
  116. package/dist/h5config/StaticTabs.d.ts +133 -0
  117. package/dist/h5config/StaticTabs.js +173 -0
  118. package/dist/h5config/Table.d.ts +182 -0
  119. package/dist/h5config/Table.js +566 -0
  120. package/dist/index.d.ts +4 -0
  121. package/dist/index.js +4 -0
  122. package/dist/lx-mobile.d.ts +9 -0
  123. package/dist/lx-mobile.js +153 -0
  124. package/dist/lx.d.ts +6 -0
  125. package/dist/lx.js +112 -0
  126. package/dist/utils.d.ts +12 -0
  127. package/dist/utils.js +65 -0
  128. package/package.json +38 -0
@@ -0,0 +1,153 @@
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 } from "./css";
8
+ import { objToListByGroupsName } from "./utils";
9
+ import { Button } from "./h5config/Button";
10
+ import { Table } 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 MOBILE_ASSETS_CSS_TPL = {
36
+ Icon: Icon,
37
+ ALink: ALink,
38
+ Button: Button,
39
+ // TODO: 分割线 style 写死,最后修改方案
40
+ // Divider,
41
+ Card: Card,
42
+ Table: Table,
43
+ FilterItems: FilterItems,
44
+ NoticeBarPlus: NoticeBarPlus,
45
+ StaticTabs: StaticTabs,
46
+ Grid: Grid,
47
+ SearchView: SearchView,
48
+ // TODO: 动态列表自己并没有样式才对
49
+ // LoadMore,
50
+ DForm: DForm,
51
+ DformInput: DformInput,
52
+ DformTextArea: DformTextArea,
53
+ DformInputNumber: DformInputNumber,
54
+ DformRadio: DformRadio,
55
+ DCheckbox: DCheckbox,
56
+ DformPicker: DformPicker,
57
+ DMultiplePicker: DMultiplePicker,
58
+ DformSelect: DformSelect,
59
+ DAddressPicker: DAddressPicker,
60
+ DformDate: DformDate,
61
+ DformRangePicker: DformRangePicker,
62
+ DformSwitch: DformSwitch,
63
+ DformImagePicker: DformImagePicker,
64
+ DformFile: DformFile,
65
+ Accordion: Accordion
66
+ };
67
+ var extend = {
68
+ DformInput: 'DForm',
69
+ DformTextArea: 'DForm',
70
+ DformInputNumber: 'DForm',
71
+ DformRadio: 'DForm',
72
+ DCheckbox: 'DForm',
73
+ DformPicker: 'DForm',
74
+ DMultiplePicker: 'DForm',
75
+ DformSelect: 'DForm',
76
+ DAddressPicker: 'DForm',
77
+ DformDate: 'DForm',
78
+ DformRangePicker: 'DForm',
79
+ DformSwitch: 'DForm',
80
+ DformImagePicker: 'DForm',
81
+ DformFile: 'DForm'
82
+ };
83
+ export var MOBILE_ASSETS_COMPONENT_LIST = objToListByGroupsName(Object.values(MOBILE_ASSETS_CSS_TPL));
84
+ export function getMobileItemByType(type) {
85
+ var com = MOBILE_ASSETS_CSS_TPL[type];
86
+ if (!type || !com) return {
87
+ tpl: ''
88
+ };
89
+ return com;
90
+ }
91
+ export function px2rem(obj) {
92
+ var remObj = {};
93
+ for (var key in obj) {
94
+ if (obj.hasOwnProperty(key)) {
95
+ var value = obj[key];
96
+ var values = value.split(' ');
97
+ if (values.length > 0) {
98
+ var remValues = values.map(function (val) {
99
+ if (val.includes('px')) {
100
+ var parsedValue = parseFloat(val);
101
+ return parsedValue / 50 + 'rem';
102
+ }
103
+ return val;
104
+ });
105
+ value = remValues.join(' ');
106
+ }
107
+ // 处理其他属性的值
108
+ else {
109
+ if (value.includes('px')) {
110
+ var parsedValue = parseFloat(value);
111
+ value = parsedValue / 50 + 'rem';
112
+ }
113
+ }
114
+ remObj[key] = value;
115
+ }
116
+ }
117
+ return remObj;
118
+ }
119
+ export function rem2px(rem) {
120
+ // TODO: 这个方法不对,现在没用到就没有修改
121
+ var str = rem.split('rem');
122
+ if (!str[0]) return '0';
123
+ return "".concat((Number.parseFloat(str[0]) * 100).toFixed(1), "px");
124
+ }
125
+ export function parseValueRem(values) {
126
+ Object.keys(values).map(function (key) {
127
+ var _values$key;
128
+ if ((_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.includes('rem')) {
129
+ values[key] = rem2px(values[key]);
130
+ }
131
+ });
132
+ return values;
133
+ }
134
+
135
+ // 临时解决方案,将只对它有影响的值,生成继承的样式
136
+ export function stringifyMobileCssByTypePreview(type, values) {
137
+ if (extend[type]) {
138
+ var cfg = getMobileItemByType(extend[type]);
139
+ var item = getMobileItemByType(type);
140
+ return stringifyCss(cfg.tpl, px2rem(_objectSpread(_objectSpread({}, cfg.defaultValue[0]), values))) + stringifyCss(item.tpl, px2rem(values));
141
+ } else {
142
+ var _item = getMobileItemByType(type);
143
+ return stringifyCss(_item.tpl, px2rem(values));
144
+ }
145
+ }
146
+ export function stringifyMobileCssByType(type, values) {
147
+ var item = getMobileItemByType(type);
148
+ return stringifyCss(item.tpl, px2rem(values));
149
+ }
150
+ export function parseMobileCssByType(type, css) {
151
+ var item = getMobileItemByType(type);
152
+ return parseValueRem(parseCss(item.tpl, css));
153
+ }
package/dist/lx.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const ASSETS_CSS_TPL: any;
2
+ export declare const ASSETS_COMPONENT_LIST: unknown[];
3
+ export declare function getItemByType(type: string): any;
4
+ export declare function stringifyCssByType(type: string, values: any): string;
5
+ export declare function stringifyCssByTypePreview(type: string, values: any): string;
6
+ export declare function parseCssByType(type: string, css: string): any;
package/dist/lx.js ADDED
@@ -0,0 +1,112 @@
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 } 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 ASSETS_CSS_TPL = {
39
+ Button: Button,
40
+ Container: Container,
41
+ Form: Form,
42
+ Card: Card,
43
+ Collapse: Collapse,
44
+ Tabs: Tabs,
45
+ Icon: Icon,
46
+ Link: Link,
47
+ Input: Input,
48
+ TextArea: TextArea,
49
+ InputNumber: InputNumber,
50
+ Radio: Radio,
51
+ CheckboxGroup: CheckboxGroup,
52
+ Checkbox: Checkbox,
53
+ Select: Select,
54
+ MultipleSelect: MultipleSelect,
55
+ DatePicker: DatePicker,
56
+ TimePicker: TimePicker,
57
+ RangePicker: RangePicker,
58
+ TreeSelect: TreeSelect,
59
+ Cascader: Cascader,
60
+ Switch: Switch,
61
+ StdUpload: StdUpload,
62
+ Table: Table,
63
+ Tag: Tag,
64
+ Tree: Tree,
65
+ Description: Description
66
+ };
67
+ var extend = {
68
+ Input: 'Form',
69
+ TextArea: 'Form',
70
+ InputNumber: 'Form',
71
+ Radio: 'Form',
72
+ CheckboxGroup: 'Form',
73
+ Checkbox: 'Form',
74
+ Select: 'Form',
75
+ MultipleSelect: 'Form',
76
+ DatePicker: 'Form',
77
+ TimePicker: 'Form',
78
+ RangePicker: 'Form',
79
+ TreeSelect: 'Form',
80
+ Cascader: 'Form',
81
+ Switch: 'Form',
82
+ StdUpload: 'Form',
83
+ Table: 'Container'
84
+ };
85
+ export var ASSETS_COMPONENT_LIST = objToListByGroupsName(Object.values(ASSETS_CSS_TPL));
86
+ export function getItemByType(type) {
87
+ var com = ASSETS_CSS_TPL[type];
88
+ if (!type || !com) return {
89
+ tpl: ''
90
+ };
91
+ return com;
92
+ }
93
+ export function stringifyCssByType(type, values) {
94
+ var item = getItemByType(type);
95
+ return stringifyCss(item.tpl, values);
96
+ }
97
+
98
+ // 临时解决方案,将只对它有影响的值,生成继承的样式
99
+ export function stringifyCssByTypePreview(type, values) {
100
+ if (extend[type]) {
101
+ var cfg = getItemByType(extend[type]);
102
+ var item = getItemByType(type);
103
+ return stringifyCss(cfg.tpl, _objectSpread(_objectSpread({}, cfg.defaultValue[0]), values)) + stringifyCss(item.tpl, values);
104
+ } else {
105
+ var _item = getItemByType(type);
106
+ return stringifyCss(_item.tpl, values);
107
+ }
108
+ }
109
+ export function parseCssByType(type, css) {
110
+ var item = getItemByType(type);
111
+ return parseCss(item.tpl, css);
112
+ }
@@ -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,65 @@
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
+ for (var key in obj) {
17
+ var item = obj[key];
18
+ var groupName = item.groupsName;
19
+ if (!groups[groupName]) {
20
+ groups[groupName] = {
21
+ groupName: groupName,
22
+ id: Object.keys(groups).length + 1,
23
+ items: []
24
+ };
25
+ }
26
+ groups[groupName].items.push(_objectSpread({
27
+ key: key
28
+ }, item));
29
+ }
30
+
31
+ // 将分组转换为数组
32
+ var result = Object.values(groups);
33
+ return result;
34
+ }
35
+
36
+ /**
37
+ * (内部方法) 根据 groupsName 将对象分成数组
38
+ * @param obj
39
+ * @returns
40
+ */
41
+ export function __objToListByGroupsName(obj) {
42
+ var groups = {};
43
+
44
+ // 遍历对象,根据groupsName属性进行分组
45
+ for (var key in obj) {
46
+ var item = obj[key];
47
+ var groupName = item.groupsName;
48
+ if (!groups[groupName]) {
49
+ groups[groupName] = {
50
+ groupName: groupName,
51
+ id: Object.keys(groups).length + 1,
52
+ items: []
53
+ };
54
+ }
55
+ groups[groupName].items.push({
56
+ key: key,
57
+ type: item.type,
58
+ icon: item.icon
59
+ });
60
+ }
61
+
62
+ // 将分组转换为数组
63
+ var result = Object.values(groups);
64
+ return result;
65
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@lingxiteam/theme-utils",
3
+ "version": "0.1.3",
4
+ "description": "",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "author": "",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "father build",
15
+ "dev": "father dev",
16
+ "format": "prettier --write .",
17
+ "g": "esno scripts/generateConfig",
18
+ "gp": "esno scripts/generatePage",
19
+ "test": "esno a.ts"
20
+ },
21
+ "dependencies": {
22
+ "stylis": "^4.3.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/stylis": "^4.2.0",
26
+ "esno": "^0.17.0",
27
+ "father": "^4.3.0",
28
+ "prettier": "^2.6.2",
29
+ "prettier-plugin-organize-imports": "^2.3.4",
30
+ "prettier-plugin-packagejson": "^2.2.18"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "peerDependencies": {
36
+ "antd": "4.18.8"
37
+ }
38
+ }