one-design-next 0.0.63 → 0.0.65

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.
@@ -0,0 +1,256 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
6
+ import _toArray from "@babel/runtime/helpers/esm/toArray";
7
+ /** 与 rc-select getSeparatedContent 对齐:任一分隔符命中才拆分 */
8
+ export function readClipboardText(clipboardData) {
9
+ if (!clipboardData) {
10
+ return '';
11
+ }
12
+ return clipboardData.getData('text/plain') || clipboardData.getData('text') || '';
13
+ }
14
+ export function splitByTokenSeparators(text, separators) {
15
+ if (!(separators !== null && separators !== void 0 && separators.length) || !text) {
16
+ return null;
17
+ }
18
+ var matched = false;
19
+ var separate = function separate(str, tokens) {
20
+ if (!tokens.length) {
21
+ return [str];
22
+ }
23
+ var _tokens = _toArray(tokens),
24
+ token = _tokens[0],
25
+ rest = _tokens.slice(1);
26
+ var list = str.split(token);
27
+ matched = matched || list.length > 1;
28
+ return list.reduce(function (prev, unit) {
29
+ return prev.concat(separate(unit, rest));
30
+ }, []).filter(Boolean);
31
+ };
32
+ var list = separate(text, separators);
33
+ return matched ? list.map(function (s) {
34
+ return s.trim();
35
+ }).filter(Boolean) : null;
36
+ }
37
+ export function flattenSelectOptions() {
38
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
39
+ var result = [];
40
+ var walk = function walk(list) {
41
+ list.forEach(function (opt) {
42
+ var _opt$options;
43
+ if ((_opt$options = opt.options) !== null && _opt$options !== void 0 && _opt$options.length) {
44
+ walk(opt.options);
45
+ return;
46
+ }
47
+ result.push(opt);
48
+ });
49
+ };
50
+ walk(options);
51
+ return result;
52
+ }
53
+ export function matchOptionByToken(token, options) {
54
+ var _flat$find;
55
+ var normalized = token.trim().toLowerCase();
56
+ if (!normalized) {
57
+ return null;
58
+ }
59
+ var flat = flattenSelectOptions(options);
60
+ return (_flat$find = flat.find(function (opt) {
61
+ var value = opt.value;
62
+ var label = opt.label;
63
+ return String(value).toLowerCase() === normalized || String(label !== null && label !== void 0 ? label : '').toLowerCase() === normalized;
64
+ })) !== null && _flat$find !== void 0 ? _flat$find : null;
65
+ }
66
+ export function toRawValueList(value) {
67
+ if (value === undefined || value === null || value === '') {
68
+ return [];
69
+ }
70
+ if (Array.isArray(value)) {
71
+ return value.map(function (item) {
72
+ if (item !== null && _typeof(item) === 'object' && 'value' in item) {
73
+ return item.value;
74
+ }
75
+ return item;
76
+ });
77
+ }
78
+ if (_typeof(value) === 'object' && value !== null && 'value' in value) {
79
+ return [value.value];
80
+ }
81
+ return [value];
82
+ }
83
+ export function resolveTokenPaste(_x) {
84
+ return _resolveTokenPaste.apply(this, arguments);
85
+ }
86
+ function _resolveTokenPaste() {
87
+ _resolveTokenPaste = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
88
+ var tokens, currentValue, currentInvalid, options, tokenMismatch, maxCount, validateTokens, validated, nextValue, nextInvalid, added, duplicated, invalid, hasValue, _iterator, _step, _loop, _ret;
89
+ return _regeneratorRuntime().wrap(function _callee$(_context2) {
90
+ while (1) switch (_context2.prev = _context2.next) {
91
+ case 0:
92
+ tokens = params.tokens, currentValue = params.currentValue, currentInvalid = params.currentInvalid, options = params.options, tokenMismatch = params.tokenMismatch, maxCount = params.maxCount, validateTokens = params.validateTokens;
93
+ if (!validateTokens) {
94
+ _context2.next = 7;
95
+ break;
96
+ }
97
+ _context2.next = 4;
98
+ return validateTokens(tokens);
99
+ case 4:
100
+ _context2.t0 = _context2.sent;
101
+ _context2.next = 8;
102
+ break;
103
+ case 7:
104
+ _context2.t0 = tokens.map(function (token) {
105
+ var hit = matchOptionByToken(token, options);
106
+ return hit ? {
107
+ token: token,
108
+ value: hit.value,
109
+ label: hit.label,
110
+ valid: true
111
+ } : {
112
+ token: token,
113
+ value: token,
114
+ label: token,
115
+ valid: false
116
+ };
117
+ });
118
+ case 8:
119
+ validated = _context2.t0;
120
+ nextValue = _toConsumableArray(currentValue);
121
+ nextInvalid = _toConsumableArray(currentInvalid);
122
+ added = [];
123
+ duplicated = [];
124
+ invalid = [];
125
+ hasValue = function hasValue(v) {
126
+ return nextValue.some(function (item) {
127
+ return String(item) === String(v);
128
+ });
129
+ };
130
+ _iterator = _createForOfIteratorHelper(validated);
131
+ _context2.prev = 16;
132
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
133
+ var _item$value2;
134
+ var item, _item$value, _value, idx, value;
135
+ return _regeneratorRuntime().wrap(function _loop$(_context) {
136
+ while (1) switch (_context.prev = _context.next) {
137
+ case 0:
138
+ item = _step.value;
139
+ if (!(typeof maxCount === 'number' && nextValue.length >= maxCount)) {
140
+ _context.next = 3;
141
+ break;
142
+ }
143
+ return _context.abrupt("return", 0);
144
+ case 3:
145
+ if (!item.valid) {
146
+ _context.next = 13;
147
+ break;
148
+ }
149
+ _value = (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.token;
150
+ if (!hasValue(_value)) {
151
+ _context.next = 8;
152
+ break;
153
+ }
154
+ duplicated.push(item.token);
155
+ return _context.abrupt("return", 1);
156
+ case 8:
157
+ nextValue.push(_value);
158
+ added.push(_value);
159
+ // 若此前是 invalid,转正后移除
160
+ idx = nextInvalid.findIndex(function (v) {
161
+ return String(v) === String(_value);
162
+ });
163
+ if (idx >= 0) {
164
+ nextInvalid.splice(idx, 1);
165
+ }
166
+ return _context.abrupt("return", 1);
167
+ case 13:
168
+ // 未匹配
169
+ invalid.push(item.token);
170
+ if (!(tokenMismatch === 'drop')) {
171
+ _context.next = 16;
172
+ break;
173
+ }
174
+ return _context.abrupt("return", 1);
175
+ case 16:
176
+ value = (_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : item.token;
177
+ if (!hasValue(value)) {
178
+ _context.next = 20;
179
+ break;
180
+ }
181
+ duplicated.push(item.token);
182
+ return _context.abrupt("return", 1);
183
+ case 20:
184
+ nextValue.push(value);
185
+ added.push(value);
186
+ if (!nextInvalid.some(function (v) {
187
+ return String(v) === String(value);
188
+ })) {
189
+ nextInvalid.push(value);
190
+ }
191
+ case 23:
192
+ case "end":
193
+ return _context.stop();
194
+ }
195
+ }, _loop);
196
+ });
197
+ _iterator.s();
198
+ case 19:
199
+ if ((_step = _iterator.n()).done) {
200
+ _context2.next = 28;
201
+ break;
202
+ }
203
+ return _context2.delegateYield(_loop(), "t1", 21);
204
+ case 21:
205
+ _ret = _context2.t1;
206
+ if (!(_ret === 0)) {
207
+ _context2.next = 24;
208
+ break;
209
+ }
210
+ return _context2.abrupt("break", 28);
211
+ case 24:
212
+ if (!(_ret === 1)) {
213
+ _context2.next = 26;
214
+ break;
215
+ }
216
+ return _context2.abrupt("continue", 26);
217
+ case 26:
218
+ _context2.next = 19;
219
+ break;
220
+ case 28:
221
+ _context2.next = 33;
222
+ break;
223
+ case 30:
224
+ _context2.prev = 30;
225
+ _context2.t2 = _context2["catch"](16);
226
+ _iterator.e(_context2.t2);
227
+ case 33:
228
+ _context2.prev = 33;
229
+ _iterator.f();
230
+ return _context2.finish(33);
231
+ case 36:
232
+ return _context2.abrupt("return", {
233
+ added: added,
234
+ duplicated: duplicated,
235
+ invalid: invalid,
236
+ nextValue: nextValue,
237
+ nextInvalid: nextInvalid
238
+ });
239
+ case 37:
240
+ case "end":
241
+ return _context2.stop();
242
+ }
243
+ }, _callee, null, [[16, 30, 33, 36]]);
244
+ }));
245
+ return _resolveTokenPaste.apply(this, arguments);
246
+ }
247
+ export function formatTokenPasteFeedback(result) {
248
+ var parts = ["\u5DF2\u6DFB\u52A0 ".concat(result.added.length, " \u9879")];
249
+ if (result.duplicated.length) {
250
+ parts.push("\u5FFD\u7565\u91CD\u590D ".concat(result.duplicated.length, " \u9879"));
251
+ }
252
+ if (result.invalid.length) {
253
+ parts.push(result.nextInvalid.length ? "\u672A\u5339\u914D ".concat(result.invalid.length, " \u9879\u5DF2\u6807\u7EA2") : "\u672A\u5339\u914D ".concat(result.invalid.length, " \u9879\u5DF2\u5FFD\u7565"));
254
+ }
255
+ return parts.join(' · ');
256
+ }
package/package.json CHANGED
@@ -1,56 +1,52 @@
1
1
  {
2
2
  "name": "one-design-next",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "One Design Next from TAD@tencent.com",
5
- "packageManager": "pnpm@11.8.0",
5
+ "license": "MIT",
6
+ "type": "module",
6
7
  "module": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
8
- "type": "module",
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "scripts": {
10
- "start": "npm run dev",
11
- "dev": "npm run build:variables && npm run build:benchmark && npm run build:feedback && dumi dev",
12
- "dev:recover": "bash scripts/after-git-switch.sh && npm run dev",
13
+ "benchmark": "node scripts/run-benchmark.mjs",
14
+ "benchmark:auto": "node scripts/run-benchmark.mjs --auto-only",
15
+ "benchmark:compare": "node scripts/run-benchmark.mjs --compare",
13
16
  "build": "father build && npm run build:styles",
17
+ "build:benchmark": "node scripts/build-benchmark.mjs",
18
+ "build:feedback": "node scripts/build-feedback.mjs",
14
19
  "build:skills": "bash skills/build.sh",
15
- "build:watch": "father dev",
16
20
  "build:styles": "node scripts/build-styles.js",
17
21
  "build:variables": "node scripts/build-variables.js",
18
- "generate:llms": "node scripts/generate-llms.mjs",
22
+ "build:watch": "father dev",
23
+ "create-component": "node scripts/create-component.js",
24
+ "create-skill": "node scripts/create-skill.mjs",
25
+ "dev": "npm run build:variables && npm run build:benchmark && npm run build:feedback && dumi dev",
26
+ "dev:recover": "bash scripts/after-git-switch.sh && npm run dev",
19
27
  "docs:build": "npm run build:variables && npm run build:benchmark && npm run build:feedback && npm run generate:llms && dumi build",
20
28
  "docs:preview": "dumi preview",
21
- "prepare": "husky install && dumi setup",
22
29
  "doctor": "father doctor",
30
+ "feedback:server": "node scripts/feedback-server.mjs",
31
+ "feedback:submit": "node scripts/feedback-submit.mjs",
32
+ "gen:test": "node scripts/gen-test.mjs",
33
+ "generate:llms": "node scripts/generate-llms.mjs",
23
34
  "lint": "npm run lint:es && npm run lint:css",
24
35
  "lint:css": "stylelint \"{components,test}/**/*.{css,scss}\"",
25
36
  "lint:es": "eslint \"{components,test}/**/*.{js,jsx,ts,tsx}\"",
37
+ "prepare": "husky install && dumi setup",
26
38
  "prepublishOnly": "father doctor && npm run build",
27
- "create-component": "node scripts/create-component.js",
28
- "gen:test": "node scripts/gen-test.mjs",
39
+ "release": "node scripts/release.mjs",
40
+ "start": "npm run dev",
29
41
  "test": "vitest",
42
+ "test:a11y": "echo 'axe-core smoke run(待 P5 接入)'",
43
+ "test:changed": "vitest run --changed",
30
44
  "test:ci": "vitest run",
31
- "test:visual:update": "UPDATE_VISUAL=1 vitest run",
32
45
  "test:visual:docker": "bash scripts/visual-baseline-docker.sh",
46
+ "test:visual:update": "UPDATE_VISUAL=1 vitest run",
33
47
  "test:visual:update:docker": "bash scripts/visual-baseline-docker.sh update",
34
- "test:changed": "vitest run --changed",
35
- "test:a11y": "echo 'axe-core smoke run(待 P5 接入)'",
36
- "typecheck": "tsc -p tsconfig.ci.json",
37
- "build:benchmark": "node scripts/build-benchmark.mjs",
38
- "benchmark": "node scripts/run-benchmark.mjs",
39
- "benchmark:compare": "node scripts/run-benchmark.mjs --compare",
40
- "benchmark:auto": "node scripts/run-benchmark.mjs --auto-only",
41
- "create-skill": "node scripts/create-skill.mjs",
42
- "build:feedback": "node scripts/build-feedback.mjs",
43
- "feedback:server": "node scripts/feedback-server.mjs",
44
- "feedback:submit": "node scripts/feedback-submit.mjs",
45
- "release": "node scripts/release.mjs"
48
+ "typecheck": "tsc -p tsconfig.ci.json"
46
49
  },
47
- "authors": [
48
- "yijiejiang@tencent.com"
49
- ],
50
- "license": "MIT",
51
- "files": [
52
- "dist"
53
- ],
54
50
  "commitlint": {
55
51
  "extends": [
56
52
  "@commitlint/config-conventional"
@@ -64,24 +60,39 @@
64
60
  "stylelint --fix",
65
61
  "prettier --write"
66
62
  ],
67
- "*.{js,jsx}": [
63
+ "{components,test}/**/*.{js,jsx}": [
68
64
  "eslint --fix",
69
65
  "prettier --write"
70
66
  ],
71
- "*.{ts,tsx}": [
67
+ "{components,test}/**/*.{ts,tsx}": [
72
68
  "eslint --fix",
73
69
  "prettier --parser=typescript --write"
74
70
  ]
75
71
  },
76
- "publishConfig": {
77
- "access": "public"
78
- },
79
- "engines": {
80
- "node": ">=16.0.0"
81
- },
82
- "peerDependencies": {
83
- "react": "~16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
84
- "react-dom": "~16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
72
+ "dependencies": {
73
+ "@babel/runtime": "^7.29.2",
74
+ "@base-ui/react": "^1.6.0",
75
+ "@daypicker/react": "^10.0.1",
76
+ "@floating-ui/react": "^0.27.19",
77
+ "@number-flow/react": "^0.6.0",
78
+ "@paper-design/shaders-react": "^0.0.76",
79
+ "@radix-ui/react-slot": "^1.3.0",
80
+ "classnames": "^2.5.1",
81
+ "clsx": "^2.1.1",
82
+ "echarts-for-react": "^3.0.6",
83
+ "ldrs": "^1.1.9",
84
+ "motion": "^12.40.0",
85
+ "rc-cascader": "^3.34.0",
86
+ "rc-select": "^14.16.8",
87
+ "rc-slider": "^11.1.9",
88
+ "rc-table": "^7.55.1",
89
+ "rc-tree": "^5.13.1",
90
+ "rc-tree-select": "^5.27.0",
91
+ "rc-util": "^5.44.4",
92
+ "rc-virtual-list": "^3.19.2",
93
+ "react-d3-cloud": "^1.0.6",
94
+ "react-markdown": "^10.1.0",
95
+ "remark-gfm": "^4.0.1"
85
96
  },
86
97
  "devDependencies": {
87
98
  "@commitlint/cli": "^17.1.2",
@@ -146,29 +157,18 @@
146
157
  "vite": "^8.0.16",
147
158
  "vitest": "^4.1.9"
148
159
  },
149
- "dependencies": {
150
- "@babel/runtime": "^7.29.2",
151
- "@base-ui/react": "^1.6.0",
152
- "@daypicker/react": "^10.0.1",
153
- "@floating-ui/react": "^0.27.19",
154
- "@number-flow/react": "^0.6.0",
155
- "@paper-design/shaders-react": "^0.0.76",
156
- "@radix-ui/react-slot": "^1.3.0",
157
- "classnames": "^2.5.1",
158
- "clsx": "^2.1.1",
159
- "echarts-for-react": "^3.0.6",
160
- "ldrs": "^1.1.9",
161
- "motion": "^12.40.0",
162
- "rc-cascader": "^3.34.0",
163
- "rc-select": "^14.16.8",
164
- "rc-slider": "^11.1.9",
165
- "rc-table": "^7.55.1",
166
- "rc-tree": "^5.13.1",
167
- "rc-tree-select": "^5.27.0",
168
- "rc-util": "^5.44.4",
169
- "rc-virtual-list": "^3.19.2",
170
- "react-d3-cloud": "^1.0.6",
171
- "react-markdown": "^10.1.0",
172
- "remark-gfm": "^4.0.1"
173
- }
160
+ "peerDependencies": {
161
+ "react": "~16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
162
+ "react-dom": "~16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
163
+ },
164
+ "packageManager": "pnpm@11.8.0",
165
+ "engines": {
166
+ "node": ">=16.0.0"
167
+ },
168
+ "publishConfig": {
169
+ "access": "public"
170
+ },
171
+ "authors": [
172
+ "yijiejiang@tencent.com"
173
+ ]
174
174
  }