@rainbow-oh/yee-c 0.4.2 → 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.
Files changed (105) hide show
  1. package/dist/cjs/Cascader/cascader.js +53 -62
  2. package/dist/cjs/Cascader/interface.d.ts +19 -2
  3. package/dist/cjs/Cascader/node.js +11 -6
  4. package/dist/cjs/Cascader/search-list.js +2 -1
  5. package/dist/cjs/Cascader/utils/index.d.ts +58 -14
  6. package/dist/cjs/Cascader/utils/index.js +57 -73
  7. package/dist/cjs/Form/form-store.js +3 -0
  8. package/dist/cjs/Form/hooks/useWatch.js +4 -2
  9. package/dist/cjs/Input/style/index.less +19 -0
  10. package/dist/cjs/Popover/style/index.less +1 -0
  11. package/dist/cjs/Select/interface.d.ts +77 -0
  12. package/dist/cjs/Select/option.d.ts +2 -1
  13. package/dist/cjs/Select/option.js +6 -3
  14. package/dist/cjs/Select/options.d.ts +3 -2
  15. package/dist/cjs/Select/options.js +53 -47
  16. package/dist/cjs/Select/select.js +1 -1
  17. package/dist/cjs/Select/style/index.less +8 -0
  18. package/dist/cjs/Selector/interface.d.ts +4 -0
  19. package/dist/cjs/Selector/selector.js +3 -0
  20. package/dist/cjs/Selector/style/index.less +135 -116
  21. package/dist/cjs/Table/hooks/useFilter.js +1 -1
  22. package/dist/cjs/Table/interface.d.ts +4 -0
  23. package/dist/cjs/Table/style/index.less +2 -0
  24. package/dist/cjs/Table/theader/filter.js +2 -1
  25. package/dist/cjs/Tabs/demo/basic.js +8 -1
  26. package/dist/cjs/Tabs/tabs.js +3 -1
  27. package/dist/cjs/Tag/demo/checkable.js +1 -0
  28. package/dist/cjs/Tag/tag.js +1 -1
  29. package/dist/cjs/TextArea/textarea.js +0 -1
  30. package/dist/cjs/Trigger/trigger.js +1 -1
  31. package/dist/cjs/style/color.css +1 -1
  32. package/dist/cjs/style/size.css +10 -2
  33. package/dist/cjs/style/themes.css +1 -1
  34. package/dist/cjs/style/variables.css +12 -4
  35. package/dist/cjs/version.d.ts +1 -1
  36. package/dist/cjs/version.js +1 -1
  37. package/dist/esm/Cascader/cascader.js +49 -56
  38. package/dist/esm/Cascader/interface.d.ts +19 -2
  39. package/dist/esm/Cascader/node.js +8 -11
  40. package/dist/esm/Cascader/search-list.js +2 -1
  41. package/dist/esm/Cascader/utils/index.d.ts +58 -14
  42. package/dist/esm/Cascader/utils/index.js +124 -75
  43. package/dist/esm/Form/form-store.js +4 -0
  44. package/dist/esm/Form/hooks/useWatch.js +7 -2
  45. package/dist/esm/Input/style/index.less +19 -0
  46. package/dist/esm/Popover/style/index.less +1 -0
  47. package/dist/esm/Select/interface.d.ts +77 -0
  48. package/dist/esm/Select/option.d.ts +2 -1
  49. package/dist/esm/Select/option.js +11 -2
  50. package/dist/esm/Select/options.d.ts +3 -2
  51. package/dist/esm/Select/options.js +3 -1
  52. package/dist/esm/Select/select.js +1 -3
  53. package/dist/esm/Select/style/index.less +8 -0
  54. package/dist/esm/Selector/interface.d.ts +4 -0
  55. package/dist/esm/Selector/selector.js +4 -2
  56. package/dist/esm/Selector/style/index.less +135 -116
  57. package/dist/esm/Table/hooks/useFilter.js +1 -1
  58. package/dist/esm/Table/interface.d.ts +4 -0
  59. package/dist/esm/Table/style/index.less +2 -0
  60. package/dist/esm/Table/theader/filter.js +3 -4
  61. package/dist/esm/Tabs/demo/basic.js +4 -1
  62. package/dist/esm/Tabs/tabs.js +3 -1
  63. package/dist/esm/Tag/demo/checkable.js +1 -0
  64. package/dist/esm/Tag/tag.js +1 -1
  65. package/dist/esm/TextArea/textarea.js +0 -1
  66. package/dist/esm/Trigger/trigger.js +1 -1
  67. package/dist/esm/style/color.css +1 -1
  68. package/dist/esm/style/size.css +10 -2
  69. package/dist/esm/style/themes.css +1 -1
  70. package/dist/esm/style/variables.css +12 -4
  71. package/dist/esm/version.d.ts +1 -1
  72. package/dist/esm/version.js +1 -1
  73. package/dist/umd/yee-c.min.css +2 -2
  74. package/dist/umd/yee-c.min.js +1 -1
  75. package/package.json +1 -1
  76. package/src/Cascader/cascader.tsx +65 -62
  77. package/src/Cascader/interface.ts +19 -2
  78. package/src/Cascader/node.tsx +12 -7
  79. package/src/Cascader/search-list.tsx +1 -1
  80. package/src/Cascader/utils/index.ts +130 -68
  81. package/src/Form/form-store.ts +4 -0
  82. package/src/Form/hooks/useWatch.ts +9 -2
  83. package/src/Input/style/index.less +19 -0
  84. package/src/Popover/style/index.less +1 -0
  85. package/src/Select/interface.ts +87 -0
  86. package/src/Select/option.tsx +13 -4
  87. package/src/Select/options.tsx +49 -43
  88. package/src/Select/select.tsx +5 -2
  89. package/src/Select/style/index.less +8 -0
  90. package/src/Selector/interface.ts +4 -0
  91. package/src/Selector/selector.tsx +2 -0
  92. package/src/Selector/style/index.less +135 -116
  93. package/src/Table/hooks/useFilter.ts +1 -1
  94. package/src/Table/interface.ts +4 -0
  95. package/src/Table/style/index.less +2 -0
  96. package/src/Table/theader/filter.tsx +2 -2
  97. package/src/Tabs/demo/basic.tsx +7 -1
  98. package/src/Tabs/tabs.tsx +3 -2
  99. package/src/Tag/demo/checkable.tsx +1 -0
  100. package/src/Tag/tag.tsx +1 -1
  101. package/src/TextArea/textarea.tsx +0 -2
  102. package/src/Trigger/trigger.tsx +1 -1
  103. package/src/style/color.css +1 -1
  104. package/src/style/size.css +10 -2
  105. package/src/version.ts +1 -1
@@ -1,19 +1,9 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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); }
9
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
- 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."); }
13
- 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); }
14
6
  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; }
15
- 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; } }
16
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
7
  /**
18
8
  * Check if a data object has children
19
9
  * @param data - The data object to check
@@ -26,64 +16,99 @@ export function hasChild(data) {
26
16
  }
27
17
 
28
18
  /**
29
- * Get the next queue element for navigation
19
+ * Separator used to build a node's `uid` from its value path. A control
20
+ * character is used on purpose so it can never appear inside a user value —
21
+ * this prevents collisions like value `"a-1"` vs path `["a", "1"]` that a plain
22
+ * `'-'` separator would produce.
23
+ */
24
+ export var UID_SEP = '';
25
+
26
+ /**
27
+ * Build the canonical uid for a value path. Use this everywhere a path needs
28
+ * to be turned into a key (nodeMap lookups, selected keys, comparisons) so the
29
+ * format stays consistent with the `uid`/`pid` produced by `flattenOptions`.
30
+ * @param path - The value path
31
+ */
32
+ export var pathToUid = function pathToUid(path) {
33
+ return path.map(String).join(UID_SEP);
34
+ };
35
+
36
+ /**
37
+ * Get the direct flattened children of the node identified by `uid`.
38
+ *
39
+ * Flattened nodes intentionally do not carry a `children` reference (it used to
40
+ * point at the raw, un-flattened subtree and caused type lies). Derive children
41
+ * from the flat list via `pid` instead — single source of truth.
42
+ * @param data - The flattened options data
43
+ * @param uid - The parent node's uid
44
+ */
45
+ export var getChildren = function getChildren(data, uid) {
46
+ return data.filter(function (item) {
47
+ return item.pid === uid;
48
+ });
49
+ };
50
+
51
+ /**
52
+ * Find the node in `data` whose parent is `pid` and whose value is `value`.
30
53
  * @internal
31
54
  */
32
- var getNextQueueElement = function getNextQueueElement(data, value) {
33
- if (!Array.isArray(data)) {
34
- return [];
35
- }
36
- for (var i = 0; i < data.length; i++) {
37
- var item = data[i];
38
- if (item.uid === value) {
39
- var nexts = hasChild(item) ? item.children.filter(function (c) {
40
- return c.pid === value;
41
- }) : [];
42
- return [nexts, {
43
- id: item.value,
44
- text: item.label
45
- }];
46
- }
47
- }
48
- return [];
55
+ var findInColumn = function findInColumn(data, pid, value) {
56
+ return data.find(function (item) {
57
+ return item.pid === pid && item.value === value;
58
+ });
49
59
  };
50
60
 
51
61
  /**
52
- * Populate data into input fields and dropdown lists from a value array
53
- * @param arr - The value array representing the selected path
62
+ * Reconstruct cascade columns and the highlight path from a value path.
63
+ *
64
+ * Walks the flattened options level by level, matching each value segment
65
+ * against the correct parent column via `pid` + `value`. Returns:
66
+ * - `queue`: the columns to render (column 0 = root, then each matched
67
+ * node's children column).
68
+ * - `path`: the highlight breadcrumb shaped as `{ key: uid, label }`, so it
69
+ * aligns with `expandedPath[level].key === uid` in the node view.
70
+ *
71
+ * Stops safely at the last valid segment if the value path does not exist in
72
+ * the data source.
73
+ *
74
+ * @param arr - The selected path. In `multiple` mode the value is an array of
75
+ * paths; the first path is used to drive which columns get expanded.
54
76
  * @param data - The flattened options data
55
77
  * @param options - Optional configuration
56
- * @returns A tuple of [queue, path] where queue is the column data and path is the selected path info
78
+ * @returns A tuple of `[queue, path]`
57
79
  */
58
80
  export var changeToView = function changeToView(arr, data, options) {
59
81
  var _ref = options || {},
60
- needNext = _ref.needNext,
61
82
  multiple = _ref.multiple;
62
- var _queue = [];
63
- var _path = [];
64
- if (Array.isArray(arr)) {
65
- var i = 0;
66
- var _arr = arr;
67
- if (multiple) {
68
- _arr = Array.isArray(arr[0]) ? arr[0] : arr;
69
- }
70
- var _data = data.filter(function (item) {
71
- return item.level === 0;
83
+ var queue = [];
84
+ var path = [];
85
+
86
+ // Column 0 (root level) is always present so the popup can open even with
87
+ // no selection.
88
+ queue.push(data.filter(function (item) {
89
+ return item.level === 0;
90
+ }));
91
+ if (!Array.isArray(arr) || arr.length === 0) {
92
+ return [queue, path];
93
+ }
94
+
95
+ // In multiple mode the value is an array of paths; use the first one to
96
+ // drive column expansion.
97
+ var segments = multiple && Array.isArray(arr[0]) ? arr[0] : arr;
98
+ var currentPid = '';
99
+ for (var i = 0; i < segments.length; i++) {
100
+ var matched = findInColumn(data, currentPid, segments[i]);
101
+ if (!matched) break; // value path doesn't exist in the data source
102
+ path.push({
103
+ key: matched.uid,
104
+ label: matched.label
72
105
  });
73
- do {
74
- _queue.push(_data);
75
- var result = getNextQueueElement(_data, _arr[i]);
76
- if (result.length) {
77
- var _result = _slicedToArray(result, 2),
78
- _dataNext = _result[0],
79
- _pathItem = _result[1];
80
- _data = _dataNext;
81
- _path.push(_pathItem);
82
- }
83
- i++;
84
- } while (needNext ? i <= _arr.length : i < _arr.length);
106
+ if (!matched.isLeaf) {
107
+ queue.push(getChildren(data, matched.uid));
108
+ }
109
+ currentPid = matched.uid;
85
110
  }
86
- return [_queue, _path];
111
+ return [queue, path];
87
112
  };
88
113
 
89
114
  // Assemble Tags Options
@@ -306,12 +331,12 @@ export var changeToView = function changeToView(arr, data, options) {
306
331
  // }
307
332
 
308
333
  /**
309
- * Format a path array into a key string
334
+ * Format a value path into a key string. Alias of `pathToUid` so all path→key
335
+ * conversions share one collision-safe format.
310
336
  * @param val - The path array
311
- * @returns A string key joined by '-'
312
337
  */
313
338
  export var formatKey = function formatKey(val) {
314
- return val.join('-');
339
+ return pathToUid(val);
315
340
  };
316
341
 
317
342
  /**
@@ -333,11 +358,12 @@ export var isSamePrefixPath = function isSamePrefixPath(prefix, target) {
333
358
  * Determine if a node is fully selected or half selected (indeterminate)
334
359
  * @param value - The selected value paths
335
360
  * @param item - The flatten option node to check
361
+ * @param children - The node's direct flattened children (derive via `getChildren`)
336
362
  * @returns A tuple [checkedAll, indeterminate]
337
363
  */
338
- export function isHalfChecked(value, item) {
339
- if (!hasChild(item)) return [false, false];
340
- var total = item.children.length;
364
+ export function isHalfChecked(value, item, children) {
365
+ if (!children.length) return [false, false];
366
+ var total = children.length;
341
367
  var prefixPath = item.path;
342
368
  var filtered = value.filter(function (path) {
343
369
  return isSamePrefixPath(prefixPath, path);
@@ -349,12 +375,27 @@ export function isHalfChecked(value, item) {
349
375
  }
350
376
 
351
377
  /**
352
- * Flatten a tree structure into an array for easier searching and traversal
378
+ * Default maximum tree depth accepted by `flattenOptions`. Guards against
379
+ * stack overflow on pathological/deeply-nested input.
380
+ */
381
+ var DEFAULT_MAX_DEPTH = 100;
382
+
383
+ /**
384
+ * Flatten a tree structure into an array for easier searching and traversal.
385
+ *
386
+ * The flattened nodes intentionally do NOT carry a `children` field — use
387
+ * `getChildren(data, uid)` to read a node's children. `uid`/`pid` are built
388
+ * via `pathToUid` (collision-safe). Includes a depth cap and a cycle guard so
389
+ * malformed input (very deep or self-referencing trees) cannot overflow the
390
+ * stack.
391
+ *
353
392
  * @param tree - The tree data to flatten
354
393
  * @param fieldNames - Custom field names for label, value, and children
394
+ * @param maxDepth - Maximum nesting depth (default 100)
355
395
  * @returns An array of flattened options with additional metadata
356
396
  */
357
397
  export var flattenOptions = function flattenOptions(tree, fieldNames) {
398
+ var maxDepth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_MAX_DEPTH;
358
399
  var res = [];
359
400
  var _ref2 = fieldNames || {},
360
401
  _ref2$label = _ref2.label,
@@ -363,26 +404,34 @@ export var flattenOptions = function flattenOptions(tree, fieldNames) {
363
404
  value = _ref2$value === void 0 ? 'value' : _ref2$value,
364
405
  _ref2$children = _ref2.children,
365
406
  children = _ref2$children === void 0 ? 'children' : _ref2$children;
407
+ // Object-identity set of nodes on the current DFS path, for cycle detection.
408
+ var seen = new Set();
366
409
  var dfs = function dfs(nodes) {
367
410
  var parents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
411
+ var labelParents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
368
412
  nodes.forEach(function (node) {
369
- var wrappered = {
413
+ if (parents.length >= maxDepth) return; // depth guard
414
+ if (seen.has(node)) return; // cycle guard (back-edge to an ancestor)
415
+ var nodeLabel = node[label];
416
+ var path = [].concat(_toConsumableArray(parents), [node[value]]);
417
+ var labelPath = [].concat(_toConsumableArray(labelParents), [nodeLabel]);
418
+ var uid = pathToUid(path);
419
+ res.push({
370
420
  $source: node,
371
- label: node[label],
421
+ label: nodeLabel,
372
422
  value: node[value],
373
- children: node[children]
374
- };
375
- var path = [].concat(_toConsumableArray(parents), [wrappered['value']]);
376
- var uid = path.join('-');
377
- var pid = parents.join('-');
378
- res.push(_objectSpread(_objectSpread({}, wrappered), {}, {
379
- pid: pid,
423
+ pid: pathToUid(parents),
380
424
  uid: uid,
381
425
  path: path,
426
+ labelPath: labelPath,
382
427
  level: parents.length,
383
- isLeaf: !hasChild(wrappered)
384
- }));
385
- if (wrappered['children']) dfs(wrappered['children'], path);
428
+ isLeaf: !hasChild(node, children)
429
+ });
430
+ if (hasChild(node, children)) {
431
+ seen.add(node);
432
+ dfs(node[children], path, labelPath);
433
+ seen.delete(node);
434
+ }
386
435
  });
387
436
  };
388
437
  dfs(tree);
@@ -445,6 +445,10 @@ export var FormStore = /*#__PURE__*/function () {
445
445
  } else {
446
446
  _this.store = _objectSpread(_objectSpread({}, _this.store), {}, _defineProperty({}, normalizedName, value));
447
447
  }
448
+ // When value is not undefined, notify watchers to trigger re-rendering of useWatch
449
+ if (value !== undefined) {
450
+ _this.notifyWatchers(normalizedName);
451
+ }
448
452
  }
449
453
  }
450
454
  (_entity$onStoreChange = entity.onStoreChange) === null || _entity$onStoreChange === void 0 || _entity$onStoreChange.call(entity);
@@ -20,12 +20,17 @@ function useWatch(namePath, form) {
20
20
  var getWatchedValue = function getWatchedValue() {
21
21
  return isWatchAll ? formInstance.getFieldsValue() : formInstance.getFieldValue(Array.isArray(namePath) ? namePath.join('.') : namePath);
22
22
  };
23
- var unsubscribe = formInstance.subscribe(namePath, function () {
23
+ var update = function update() {
24
24
  var newValue = getWatchedValue();
25
25
  setValue(function (prev) {
26
26
  return prev === newValue ? prev : newValue;
27
27
  });
28
- });
28
+ };
29
+ var unsubscribe = formInstance.subscribe(namePath, update);
30
+ // Re-read immediately after subscribing: the parent's useWatch captured its
31
+ // initial snapshot before child Form.Field wrote its initialValue, and the
32
+ // subscription may not yet exist when that write happens. This covers the gap.
33
+ update();
29
34
  return unsubscribe;
30
35
  }, [formInstance, namePath]);
31
36
  return value;
@@ -69,6 +69,25 @@
69
69
  }
70
70
  }
71
71
 
72
+ // size
73
+ &-small {
74
+ height: var(--yee-input-small-height, 24px);
75
+ padding: var(--yee-input-small-padding, 0 6px);
76
+ font-size: var(--yee-input-small-font-size);
77
+ line-height: var(--yee-input-small-line-height);
78
+
79
+ &::placeholder {
80
+ font-size: var(--yee-input-small-font-size);
81
+ }
82
+ }
83
+
84
+ &-large {
85
+ height: var(--yee-input-large-height, 40px);
86
+ padding: var(--yee-input-large-padding, 4px 12px);
87
+ font-size: var(--yee-input-large-font-size);
88
+ line-height: var(--yee-input-large-line-height);
89
+ }
90
+
72
91
  &-password {
73
92
  flex: 1;
74
93
  outline: none;
@@ -6,6 +6,7 @@
6
6
  color: var(--yee-color-text);
7
7
  background-color: var(--yee-popover-bg-color);
8
8
  border-radius: var(--yee-popover-border-radius);
9
+ overflow: hidden;
9
10
 
10
11
  &-header {
11
12
  margin-bottom: var(--yee-popover-header-margin-bottom);
@@ -95,3 +95,80 @@ export interface SelectProps extends DataAttributeProps {
95
95
  */
96
96
  onFilter?: (value: string, options: Array<Option>) => Array<Option>;
97
97
  }
98
+ /**
99
+ * Props for the internal Option component (renders a single dropdown option).
100
+ */
101
+ export interface OptionProps {
102
+ /**
103
+ * Display label
104
+ */
105
+ label: string;
106
+ /**
107
+ * Value
108
+ */
109
+ value: string | number;
110
+ /**
111
+ * Whether disabled
112
+ */
113
+ disabled?: boolean;
114
+ /**
115
+ * Native title attribute
116
+ */
117
+ title?: string;
118
+ /**
119
+ * Test id forwarded to the option element
120
+ */
121
+ dataTestId?: string;
122
+ }
123
+ /**
124
+ * Context value shared between Options and each Option.
125
+ */
126
+ export interface OptionsContextValue {
127
+ prefixCls: string;
128
+ selectedKeys: Array<string | number>;
129
+ focusedKey: string | number;
130
+ multiple: boolean;
131
+ onSelect: (key: string | number, e?: React.MouseEvent | React.KeyboardEvent) => void;
132
+ }
133
+ /**
134
+ * Props for the internal Options (popup list) component.
135
+ */
136
+ export interface OptionsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
137
+ /**
138
+ * Custom class name prefix
139
+ */
140
+ prefixCls: string;
141
+ /**
142
+ * Dropdown options
143
+ */
144
+ options: Array<Option>;
145
+ /**
146
+ * Popup container class name
147
+ */
148
+ popupClassName?: string;
149
+ /**
150
+ * Popup container inline style
151
+ */
152
+ popupStyle?: React.CSSProperties;
153
+ /**
154
+ * Selected option values
155
+ */
156
+ selectedKeys: Array<string | number>;
157
+ /**
158
+ * Currently focused option value
159
+ */
160
+ focusedKey: string | number;
161
+ /**
162
+ * Test id prefix used to generate each option's test id.
163
+ * Accepts any `data-*` attribute value (see DataAttributeProps).
164
+ */
165
+ dataTestId?: string | number | boolean;
166
+ /**
167
+ * Whether multiple selection mode is active
168
+ */
169
+ multiple: boolean;
170
+ /**
171
+ * Callback when an option is selected
172
+ */
173
+ onSelect: (key: string | number, e?: React.MouseEvent | React.KeyboardEvent) => void;
174
+ }
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const Option: (props: any) => React.JSX.Element;
2
+ import type { OptionProps } from './interface';
3
+ declare const Option: (props: OptionProps) => React.JSX.Element;
3
4
  export default Option;
@@ -3,6 +3,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  import clsx from 'clsx';
6
+ import { Check } from 'lucide-react';
6
7
  import React, { useContext } from 'react';
7
8
  import { OptionsCtx } from "./options";
8
9
  var Option = function Option(props) {
@@ -15,6 +16,7 @@ var Option = function Option(props) {
15
16
  prefixCls = _useContext.prefixCls,
16
17
  selectedKeys = _useContext.selectedKeys,
17
18
  focusedKey = _useContext.focusedKey,
19
+ multiple = _useContext.multiple,
18
20
  onSelect = _useContext.onSelect;
19
21
  var handleClick = function handleClick(e) {
20
22
  if (!disabled) {
@@ -22,8 +24,9 @@ var Option = function Option(props) {
22
24
  }
23
25
  };
24
26
  var htmlTitle = title ? title : typeof label === 'string' ? label : undefined;
27
+ var selected = selectedKeys.includes(value);
25
28
  return /*#__PURE__*/React.createElement("div", {
26
- className: clsx("".concat(prefixCls, "-option"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-option-selected"), selectedKeys.includes(value)), "".concat(prefixCls, "-option-focused"), focusedKey === value), "".concat(prefixCls, "-option-disabled"), disabled)),
29
+ className: clsx("".concat(prefixCls, "-option"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-option-selected"), selected), "".concat(prefixCls, "-option-focused"), focusedKey === value), "".concat(prefixCls, "-option-disabled"), disabled)),
27
30
  "aria-label": "option",
28
31
  onClick: handleClick,
29
32
  onKeyDown: function onKeyDown(e) {
@@ -35,6 +38,12 @@ var Option = function Option(props) {
35
38
  tabIndex: disabled ? undefined : 0,
36
39
  title: htmlTitle,
37
40
  "data-testid": dataTestId
38
- }, label);
41
+ }, /*#__PURE__*/React.createElement("div", {
42
+ className: "".concat(prefixCls, "-option-content")
43
+ }, label), multiple && selected && /*#__PURE__*/React.createElement("span", {
44
+ className: "".concat(prefixCls, "-option-state")
45
+ }, /*#__PURE__*/React.createElement(Check, {
46
+ size: 16
47
+ })));
39
48
  };
40
49
  export default Option;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
- export declare const OptionsCtx: React.Context<any>;
3
- declare const Options: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<HTMLDivElement>>;
2
+ import type { OptionsContextValue, OptionsProps } from './interface';
3
+ export declare const OptionsCtx: React.Context<OptionsContextValue>;
4
+ declare const Options: React.ForwardRefExoticComponent<OptionsProps & React.RefAttributes<HTMLDivElement>>;
4
5
  export default Options;
@@ -1,4 +1,4 @@
1
- var _excluded = ["prefixCls", "options", "popupClassName", "popupStyle", "selectedKeys", "focusedKey", "dataTestId", "onSelect"];
1
+ var _excluded = ["prefixCls", "options", "popupClassName", "popupStyle", "selectedKeys", "focusedKey", "dataTestId", "multiple", "onSelect"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -18,6 +18,7 @@ var Options = /*#__PURE__*/forwardRef(function (props, ref) {
18
18
  selectedKeys = props.selectedKeys,
19
19
  focusedKey = props.focusedKey,
20
20
  dataTestId = props.dataTestId,
21
+ multiple = props.multiple,
21
22
  onSelect = props.onSelect,
22
23
  rest = _objectWithoutProperties(props, _excluded);
23
24
 
@@ -35,6 +36,7 @@ var Options = /*#__PURE__*/forwardRef(function (props, ref) {
35
36
  prefixCls: prefixCls,
36
37
  selectedKeys: selectedKeys,
37
38
  focusedKey: focusedKey,
39
+ multiple: multiple,
38
40
  onSelect: onSelect
39
41
  }
40
42
  }, options.map(function (option, index) {
@@ -156,14 +156,12 @@ var Select = function Select(baseprops) {
156
156
  onKeyDown = _useSelectKeyboard.onKeyDown;
157
157
  var popup = /*#__PURE__*/React.createElement(Options, {
158
158
  prefixCls: prefixCls,
159
+ multiple: mode === 'multiple' || mode === 'tags',
159
160
  options: filteredOpts,
160
161
  focusedKey: focusedKey,
161
162
  selectedKeys: mergedValue,
162
163
  dataTestId: rest['data-testid'],
163
164
  onSelect: handleSelect,
164
- onClose: function onClose() {
165
- return setOpen(false);
166
- },
167
165
  ref: popupRef
168
166
  });
169
167
  return /*#__PURE__*/React.createElement(Trigger, _extends({}, rest, {
@@ -9,12 +9,20 @@
9
9
  }
10
10
 
11
11
  &-option {
12
+ display: flex;
12
13
  padding: var(--yee-select-option-padding);
13
14
  overflow: hidden;
14
15
  white-space: nowrap;
15
16
  text-overflow: ellipsis;
16
17
  cursor: pointer;
17
18
 
19
+ &-content {
20
+ flex: 1;
21
+ overflow: hidden;
22
+ white-space: nowrap;
23
+ text-overflow: ellipsis;
24
+ }
25
+
18
26
  &:not(&-disabled):hover {
19
27
  background-color: var(--yee-select-option-hover-bg-color);
20
28
  }
@@ -38,6 +38,10 @@ export interface PureSelectorProps {
38
38
  * In multiple or tags mode, the maximum number of selectable items
39
39
  */
40
40
  maxCount?: number;
41
+ /**
42
+ * size
43
+ * */
44
+ size?: 'small' | 'default' | 'large';
41
45
  /**
42
46
  * Selection mode
43
47
  */
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["prefixCls", "mode", "className", "style", "optionLabelProp", "searchable", "disabled", "options", "selectedKeys", "allowClear", "placeholder", "closable", "suffix", "value", "open", "loading", "onSearch", "onRemove", "onClear", "onOpenChange", "onKeyDown"];
2
+ var _excluded = ["prefixCls", "mode", "className", "style", "optionLabelProp", "searchable", "disabled", "options", "selectedKeys", "allowClear", "placeholder", "closable", "suffix", "value", "open", "loading", "size", "onSearch", "onRemove", "onClear", "onOpenChange", "onKeyDown"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -46,6 +46,8 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
46
46
  value = props.value,
47
47
  open = props.open,
48
48
  loading = props.loading,
49
+ _props$size = props.size,
50
+ size = _props$size === void 0 ? 'default' : _props$size,
49
51
  onSearch = props.onSearch,
50
52
  onRemove = props.onRemove,
51
53
  onClear = props.onClear,
@@ -92,7 +94,7 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
92
94
  e.stopPropagation();
93
95
  onRemove === null || onRemove === void 0 || onRemove(option);
94
96
  };
95
- var cls = clsx(prefixCls, ["".concat(prefixCls, "-searchable")], ["".concat(prefixCls, "-").concat(mode || 'single')], _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-allow-clear"), allowClear), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-open"), open), className);
97
+ var cls = clsx(prefixCls, ["".concat(prefixCls, "-").concat(size)], ["".concat(prefixCls, "-searchable")], ["".concat(prefixCls, "-").concat(mode || 'single')], _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-allow-clear"), allowClear), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-open"), open), className);
96
98
  var renderSearch = function renderSearch() {
97
99
  return /*#__PURE__*/React.createElement("div", {
98
100
  className: clsx("".concat(prefixCls, "-input-wrapper"), {