@assembly-js/design-system 3.1.12 → 3.1.15

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 (48) hide show
  1. package/dist/esm/components/Button/Base.js +2 -1
  2. package/dist/esm/components/UserCompanySelector/SelectedValueChip.js +5 -1
  3. package/dist/esm/components/UserCompanySelector/UserCompanySelector.js +32 -44
  4. package/dist/esm/components/UserCompanySelector/__tests__/getClassNames.test.js +81 -0
  5. package/dist/esm/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.js +115 -0
  6. package/dist/esm/components/UserCompanySelector/data.js +17 -15
  7. package/dist/esm/components/UserCompanySelector/getClassNames.js +44 -0
  8. package/dist/esm/components/UserCompanySelector/getOptionRelevanceScore.js +33 -0
  9. package/dist/esm/types/components/Button/Base.d.ts +1 -1
  10. package/dist/esm/types/components/Button/Button.stories.d.ts +1 -0
  11. package/dist/esm/types/components/UserCompanySelector/UserCompanySelector.stories.d.ts +2 -0
  12. package/dist/esm/types/components/UserCompanySelector/__tests__/getClassNames.test.d.ts +1 -0
  13. package/dist/esm/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts +1 -0
  14. package/dist/esm/types/components/UserCompanySelector/getClassNames.d.ts +11 -0
  15. package/dist/esm/types/components/UserCompanySelector/getOptionRelevanceScore.d.ts +14 -0
  16. package/dist/esm/types/components/UserCompanySelector/types.d.ts +10 -0
  17. package/dist/esm/types/index.d.ts +1 -1
  18. package/dist/esm/types/tsconfig.tsbuildinfo +1 -1
  19. package/dist/styles/main.css +1 -1
  20. package/dist/types/components/Button/Base.d.ts +1 -1
  21. package/dist/types/components/Button/Button.stories.d.ts +1 -0
  22. package/dist/types/components/UserCompanySelector/UserCompanySelector.stories.d.ts +2 -0
  23. package/dist/types/components/UserCompanySelector/__tests__/getClassNames.test.d.ts +1 -0
  24. package/dist/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts +1 -0
  25. package/dist/types/components/UserCompanySelector/getClassNames.d.ts +11 -0
  26. package/dist/types/components/UserCompanySelector/getOptionRelevanceScore.d.ts +14 -0
  27. package/dist/types/components/UserCompanySelector/types.d.ts +10 -0
  28. package/dist/types/index.d.ts +1 -1
  29. package/dist/types/tsconfig.tsbuildinfo +1 -1
  30. package/dist/umd/components/Button/Base.js +2 -1
  31. package/dist/umd/components/UserCompanySelector/SelectedValueChip.js +5 -1
  32. package/dist/umd/components/UserCompanySelector/UserCompanySelector.js +34 -48
  33. package/dist/umd/components/UserCompanySelector/__tests__/getClassNames.test.js +96 -0
  34. package/dist/umd/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.js +130 -0
  35. package/dist/umd/components/UserCompanySelector/data.js +17 -15
  36. package/dist/umd/components/UserCompanySelector/getClassNames.js +64 -0
  37. package/dist/umd/components/UserCompanySelector/getOptionRelevanceScore.js +53 -0
  38. package/dist/umd/types/components/Button/Base.d.ts +1 -1
  39. package/dist/umd/types/components/Button/Button.stories.d.ts +1 -0
  40. package/dist/umd/types/components/UserCompanySelector/UserCompanySelector.stories.d.ts +2 -0
  41. package/dist/umd/types/components/UserCompanySelector/__tests__/getClassNames.test.d.ts +1 -0
  42. package/dist/umd/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts +1 -0
  43. package/dist/umd/types/components/UserCompanySelector/getClassNames.d.ts +11 -0
  44. package/dist/umd/types/components/UserCompanySelector/getOptionRelevanceScore.d.ts +14 -0
  45. package/dist/umd/types/components/UserCompanySelector/types.d.ts +10 -0
  46. package/dist/umd/types/index.d.ts +1 -1
  47. package/dist/umd/types/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +1 -1
@@ -31,7 +31,8 @@
31
31
  variant: {
32
32
  primary: (0, _clsx["default"])('cop-bg-button-primary cop-text-white cop-border-primary', 'hover:cop-bg-[#6B6F76] hover:cop-border-[#00000012]', 'disabled:cop-bg-secondary disabled:cop-border-[#00000012]'),
33
33
  secondary: 'cop-bg-white cop-text-primary cop-border-[#00000012] hover:cop-bg-[#F8F9FB]',
34
- minimal: 'cop-bg-transparent cop-border-transparent cop-text-primary hover:cop-bg-[#F8F9FB] hover:cop-border-[#F8F9FB]'
34
+ minimal: 'cop-bg-transparent cop-border-transparent cop-text-primary hover:cop-bg-[#F8F9FB] hover:cop-border-[#F8F9FB]',
35
+ studio: (0, _clsx["default"])('cop-bg-studio-green cop-text-black cop-border-transparent', 'hover:cop-bg-studio-green-hover', 'disabled:cop-opacity-50')
35
36
  }
36
37
  },
37
38
  defaultVariants: {
@@ -39,8 +39,12 @@
39
39
  }
40
40
  };
41
41
  return /*#__PURE__*/_react["default"].createElement(_Chip.Chip, {
42
- className: "!cop-rounded cop-border cop-border-solid cop-py-[5px] cop-max-w-[200px]",
42
+ className: "cop-max-w-[200px] !cop-rounded cop-border cop-border-solid cop-py-[5px]",
43
43
  variant: "outlined",
44
+ onClick: function onClick() {
45
+ return null;
46
+ } // passing onclick would allow showing the hover state - this is a temporary solution avoiding doing big changes in the chip component might causing regressions
47
+ ,
44
48
  truncate: true,
45
49
  onClose: handleRemove,
46
50
  prefixIcon: option.type === 'company' ? /*#__PURE__*/_react["default"].createElement(_Avatar.Avatar, {
@@ -2,17 +2,17 @@
2
2
  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); }
3
3
  (function (global, factory) {
4
4
  if (typeof define === "function" && define.amd) {
5
- define(["exports", "react", "react-select", "./ListItem", "../Typography", "./SelectedValueChip", "./LimitedOptionsList", "../../theme/colors"], factory);
5
+ define(["exports", "react", "react-select", "./ListItem", "../Typography", "./SelectedValueChip", "./LimitedOptionsList", "../../theme/colors", "./getClassNames", "./getOptionRelevanceScore"], factory);
6
6
  } else if (typeof exports !== "undefined") {
7
- factory(exports, require("react"), require("react-select"), require("./ListItem"), require("../Typography"), require("./SelectedValueChip"), require("./LimitedOptionsList"), require("../../theme/colors"));
7
+ factory(exports, require("react"), require("react-select"), require("./ListItem"), require("../Typography"), require("./SelectedValueChip"), require("./LimitedOptionsList"), require("../../theme/colors"), require("./getClassNames"), require("./getOptionRelevanceScore"));
8
8
  } else {
9
9
  var mod = {
10
10
  exports: {}
11
11
  };
12
- factory(mod.exports, global.react, global.reactSelect, global.ListItem, global.Typography, global.SelectedValueChip, global.LimitedOptionsList, global.colors);
12
+ factory(mod.exports, global.react, global.reactSelect, global.ListItem, global.Typography, global.SelectedValueChip, global.LimitedOptionsList, global.colors, global.getClassNames, global.getOptionRelevanceScore);
13
13
  global.UserCompanySelector = mod.exports;
14
14
  }
15
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _reactSelect, _ListItem, _Typography, _SelectedValueChip, _LimitedOptionsList, _colors) {
15
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _reactSelect, _ListItem, _Typography, _SelectedValueChip, _LimitedOptionsList, _colors, _getClassNames, _getOptionRelevanceScore) {
16
16
  "use strict";
17
17
  'use client';
18
18
 
@@ -22,7 +22,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
22
22
  _exports.UserCompanySelector = void 0;
23
23
  _react = _interopRequireWildcard(_react);
24
24
  _reactSelect = _interopRequireDefault(_reactSelect);
25
- var _excluded = ["autoFocus", "grouped", "name", "internalUsers", "clientUsers", "companies", "onChange", "onBlur", "placeholder", "styles", "ignoreCompanies", "ignoreFilterClientsByCompany", "limitSelectedOptions", "initialValue", "customLabels", "listHeading", "listClassName"];
25
+ var _excluded = ["autoFocus", "grouped", "name", "internalUsers", "clientUsers", "companies", "onChange", "onBlur", "placeholder", "styles", "ignoreCompanies", "ignoreFilterClientsByCompany", "limitSelectedOptions", "initialValue", "customLabels", "listHeading", "listClassName", "variant"];
26
26
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
27
27
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
28
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -94,6 +94,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
94
94
  customLabels = _ref.customLabels,
95
95
  listHeading = _ref.listHeading,
96
96
  listClassName = _ref.listClassName,
97
+ _ref$variant = _ref.variant,
98
+ variant = _ref$variant === void 0 ? 'default' : _ref$variant,
97
99
  others = _objectWithoutProperties(_ref, _excluded);
98
100
  var limitSelectedOptions = limitSelectedOptionsUnvalidated === 0 ? 1000 : Math.min(1000, limitSelectedOptionsUnvalidated);
99
101
  var companiesMap = (0, _react.useMemo)(function () {
@@ -117,29 +119,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
117
119
  _useState4 = _slicedToArray(_useState3, 2),
118
120
  inputValue = _useState4[0],
119
121
  setInputValue = _useState4[1];
120
-
121
- /**
122
- * Returns a relevance score for an option based on the input value.
123
- * Higher scores indicate more relevant matches (direct name matches > company name matches).
124
- * @param option - the option to score
125
- * @returns 2 for direct name match, 1 for company name match only, 0 for no match
126
- */
127
- var getOptionRelevanceScore = (0, _react.useCallback)(function (option) {
128
- if (!inputValue) {
129
- return 1; // Show all options when no input
130
- }
131
- var lowerInput = inputValue.toLowerCase();
132
- var nameMatches = option.label.toLowerCase().includes(lowerInput);
133
- if (option.type === 'client') {
134
- var _option$companyId, _company$label;
135
- var company = companiesMap.get((_option$companyId = option.companyId) !== null && _option$companyId !== void 0 ? _option$companyId : '');
136
- var companyMatches = company === null || company === void 0 || (_company$label = company.label) === null || _company$label === void 0 ? void 0 : _company$label.toLowerCase().includes(lowerInput);
137
- if (nameMatches) return 2; // Direct name match - highest priority
138
- if (companyMatches) return 1; // Company name match - lower priority
139
- return 0; // No match
140
- }
141
- return nameMatches ? 1 : 0;
142
- }, [inputValue, companiesMap]);
122
+ var scoreOption = (0, _react.useCallback)(function (option) {
123
+ return (0, _getOptionRelevanceScore.getOptionRelevanceScore)(option, inputValue, companiesMap, ignoreCompanies);
124
+ }, [inputValue, companiesMap, ignoreCompanies]);
143
125
  var isOptionSelected = (0, _react.useCallback)(function (option) {
144
126
  return selectedOptions.some(function (o) {
145
127
  return o.value === option.value;
@@ -183,7 +165,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
183
165
  options: group.options.map(function (opt) {
184
166
  return {
185
167
  opt: opt,
186
- score: getOptionRelevanceScore(opt)
168
+ score: scoreOption(opt)
187
169
  };
188
170
  }).filter(function (_ref2) {
189
171
  var score = _ref2.score;
@@ -199,7 +181,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
199
181
  var filteredFlatOptions = [].concat(_toConsumableArray(filteredInternalUsers), _toConsumableArray(filteredClients), _toConsumableArray(filteredCompanies)).map(function (opt) {
200
182
  return {
201
183
  opt: opt,
202
- score: getOptionRelevanceScore(opt)
184
+ score: scoreOption(opt)
203
185
  };
204
186
  }).filter(function (_ref4) {
205
187
  var score = _ref4.score;
@@ -214,7 +196,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
214
196
  // when grouped is true then we need to show the options list in a group manner.
215
197
  var opts = grouped ? filteredGroupedOptions : filteredFlatOptions;
216
198
  return opts;
217
- }, [internalUsers, clientUsers, companies, grouped, selectedOptions, ignoreFilterClientsByCompany, limitSelectedOptions, getOptionRelevanceScore, isOptionSelected, customLabels]);
199
+ }, [internalUsers, clientUsers, companies, grouped, selectedOptions, ignoreFilterClientsByCompany, limitSelectedOptions, scoreOption, isOptionSelected, customLabels]);
218
200
 
219
201
  /**
220
202
  * Handles the change of the selected options
@@ -269,8 +251,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
269
251
  * @returns the option with the company data
270
252
  */
271
253
  var getCompanyData = (0, _react.useCallback)(function (option) {
272
- var _option$companyId2, _clientToCompanyCount2, _option$value;
273
- var company = option.type === 'client' ? companiesMap.get((_option$companyId2 = option.companyId) !== null && _option$companyId2 !== void 0 ? _option$companyId2 : '') : undefined;
254
+ var _option$companyId, _clientToCompanyCount2, _option$value;
255
+ var company = option.type === 'client' ? companiesMap.get((_option$companyId = option.companyId) !== null && _option$companyId !== void 0 ? _option$companyId : '') : undefined;
274
256
 
275
257
  // only setup the company avatar data if the client is part of more than one company
276
258
  var clientsCount = (_clientToCompanyCount2 = clientToCompanyCount.get((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : '')) !== null && _clientToCompanyCount2 !== void 0 ? _clientToCompanyCount2 : 0;
@@ -281,11 +263,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
281
263
  } : {});
282
264
  }, [companiesMap, clientToCompanyCount]);
283
265
  var handleFilterOption = (0, _react.useCallback)(function (option, inputValue) {
266
+ var _option$data$label$to, _option$data$label;
284
267
  var lowerCaseInputValue = inputValue.toLowerCase();
285
268
  if (ignoreCompanies && option.data.type === 'company') {
286
269
  return false;
287
270
  }
288
- var optionLabel = option.data.label.toLowerCase();
271
+ var optionLabel = (_option$data$label$to = (_option$data$label = option.data.label) === null || _option$data$label === void 0 ? void 0 : _option$data$label.toLowerCase()) !== null && _option$data$label$to !== void 0 ? _option$data$label$to : '';
289
272
  // for clients option, we should filter by company name too
290
273
  // e.g. if a client company is ACME and the input is ACME, the result should
291
274
  // show the client with the company ACME and the client with the company name
@@ -348,6 +331,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
348
331
  }
349
332
  };
350
333
  }, [getCompanyData, listHeading, listClassName]);
334
+ var variantClassNames = (0, _react.useMemo)(function () {
335
+ return (0, _getClassNames.getClassNames)(variant);
336
+ }, [variant]);
351
337
  return /*#__PURE__*/_react["default"].createElement(_reactSelect["default"], _extends({
352
338
  autoFocus: autoFocus,
353
339
  isMulti: true,
@@ -361,7 +347,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
361
347
  placeholder: placeholder,
362
348
  filterOption: handleFilterOption,
363
349
  unstyled: true,
364
- styles: _objectSpread({
350
+ styles: _objectSpread(_objectSpread({
365
351
  clearIndicator: function clearIndicator() {
366
352
  return {
367
353
  display: 'none' // hide the clear button. Unfortunatelly, the class specificity is not enough to override the default styles.
@@ -372,20 +358,20 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
372
358
  color: _colors.colors.gray[500]
373
359
  });
374
360
  }
375
- }, styles),
376
- classNames: {
377
- valueContainer: function valueContainer() {
378
- return 'cop-flex cop-gap-1';
379
- },
380
- input: function input() {
381
- return 'cop-text-base cop-text-primary hover:cop-cursor-text';
382
- },
383
- menuList: function menuList() {
384
- return 'cop-relative cop-bg-white cop-shadow-popover-50 cop-rounded cop-border cop-border-solid cop-border-secondary cop-mt-1';
385
- },
386
- control: function control() {
387
- return 'cop-border-solid cop-border-[1px] cop-border-secondary focus-within:cop-border-primary cop-px-3 cop-py-[2px] cop-rounded';
361
+ }, variant === 'unified' ? {
362
+ menu: function menu() {
363
+ return {
364
+ position: 'static'
365
+ };
388
366
  }
367
+ } : {}), styles),
368
+ classNames: {
369
+ container: variantClassNames.container,
370
+ valueContainer: variantClassNames.valueContainer,
371
+ input: variantClassNames.input,
372
+ placeholder: variantClassNames.placeholder,
373
+ menuList: variantClassNames.menuList,
374
+ control: variantClassNames.control
389
375
  },
390
376
  components: memoizedComponents,
391
377
  value: selectedOptions
@@ -0,0 +1,96 @@
1
+ // This file is generated by a script. Do not edit this file directly.
2
+ (function (global, factory) {
3
+ if (typeof define === "function" && define.amd) {
4
+ define(["../getClassNames"], factory);
5
+ } else if (typeof exports !== "undefined") {
6
+ factory(require("../getClassNames"));
7
+ } else {
8
+ var mod = {
9
+ exports: {}
10
+ };
11
+ factory(global.getClassNames);
12
+ global.getClassNamesTest = mod.exports;
13
+ }
14
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_getClassNames) {
15
+ "use strict";
16
+
17
+ describe('getClassNames', function () {
18
+ describe('default variant', function () {
19
+ var cls = (0, _getClassNames.getClassNames)('default');
20
+ it('control has outer border, rounded, and focus-within blue border', function () {
21
+ var control = cls.control();
22
+ expect(control).toContain('cop-border-solid');
23
+ expect(control).toContain('cop-border-[1px]');
24
+ expect(control).toContain('cop-border-secondary');
25
+ expect(control).toContain('cop-rounded');
26
+ expect(control).toContain('focus-within:cop-border-primary');
27
+ });
28
+ it('menuList has its own border, shadow, rounded, and top margin', function () {
29
+ var menuList = cls.menuList();
30
+ expect(menuList).toContain('cop-shadow-popover-50');
31
+ expect(menuList).toContain('cop-rounded');
32
+ expect(menuList).toContain('cop-border');
33
+ expect(menuList).toContain('cop-border-secondary');
34
+ expect(menuList).toContain('cop-mt-1');
35
+ });
36
+ it('container returns undefined (no outer wrapper in default)', function () {
37
+ expect(cls.container).toBeUndefined();
38
+ });
39
+ });
40
+ describe('unified variant', function () {
41
+ var cls = (0, _getClassNames.getClassNames)('unified');
42
+ it('container has border, rounded corners, and shadow', function () {
43
+ var _cls$container, _cls$container2;
44
+ var container = (_cls$container = (_cls$container2 = cls.container) === null || _cls$container2 === void 0 ? void 0 : _cls$container2.call(cls)) !== null && _cls$container !== void 0 ? _cls$container : '';
45
+ expect(container).toContain('cop-border');
46
+ expect(container).toContain('cop-border-secondary');
47
+ expect(container).toContain('cop-rounded');
48
+ expect(container).toContain('cop-shadow-popover-50');
49
+ expect(container).toContain('cop-overflow-hidden');
50
+ });
51
+ it('control has no border (outer container owns all border styling)', function () {
52
+ var control = cls.control();
53
+ expect(control).toContain('cop-px-3');
54
+ expect(control).toContain('cop-py-[2px]');
55
+ expect(control).not.toContain('cop-border');
56
+ expect(control).not.toContain('cop-rounded');
57
+ expect(control).not.toContain('focus-within:cop-border-primary');
58
+ });
59
+ it('menuList has no border, no shadow, no rounded, no top margin', function () {
60
+ var menuList = cls.menuList();
61
+ expect(menuList).not.toContain('cop-shadow-popover-50');
62
+ expect(menuList).not.toContain('cop-rounded');
63
+ expect(menuList).not.toContain('cop-border-solid');
64
+ expect(menuList).not.toContain('cop-border-secondary');
65
+ expect(menuList).not.toContain('cop-mt-1');
66
+ });
67
+ });
68
+ describe('shared across variants', function () {
69
+ it('input uses 13px font size with 20px line height in default', function () {
70
+ var input = (0, _getClassNames.getClassNames)('default').input();
71
+ expect(input).toContain('cop-text-[13px]');
72
+ expect(input).toContain('cop-leading-5');
73
+ });
74
+ it('input uses 13px font size with 20px line height in unified', function () {
75
+ var input = (0, _getClassNames.getClassNames)('unified').input();
76
+ expect(input).toContain('cop-text-[13px]');
77
+ expect(input).toContain('cop-leading-5');
78
+ });
79
+ it('placeholder uses 13px font size with 20px line height in default', function () {
80
+ var placeholder = (0, _getClassNames.getClassNames)('default').placeholder();
81
+ expect(placeholder).toContain('cop-text-[13px]');
82
+ expect(placeholder).toContain('cop-leading-5');
83
+ });
84
+ it('placeholder uses 13px font size with 20px line height in unified', function () {
85
+ var placeholder = (0, _getClassNames.getClassNames)('unified').placeholder();
86
+ expect(placeholder).toContain('cop-text-[13px]');
87
+ expect(placeholder).toContain('cop-leading-5');
88
+ });
89
+ it('valueContainer is the same flex gap class in both variants', function () {
90
+ expect((0, _getClassNames.getClassNames)('default').valueContainer()).toBe((0, _getClassNames.getClassNames)('unified').valueContainer());
91
+ expect((0, _getClassNames.getClassNames)('default').valueContainer()).toContain('cop-flex');
92
+ expect((0, _getClassNames.getClassNames)('default').valueContainer()).toContain('cop-gap-1');
93
+ });
94
+ });
95
+ });
96
+ });
@@ -0,0 +1,130 @@
1
+ // This file is generated by a script. Do not edit this file directly.
2
+ (function (global, factory) {
3
+ if (typeof define === "function" && define.amd) {
4
+ define(["../getOptionRelevanceScore"], factory);
5
+ } else if (typeof exports !== "undefined") {
6
+ factory(require("../getOptionRelevanceScore"));
7
+ } else {
8
+ var mod = {
9
+ exports: {}
10
+ };
11
+ factory(global.getOptionRelevanceScore);
12
+ global.getOptionRelevanceScoreTest = mod.exports;
13
+ }
14
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_getOptionRelevanceScore) {
15
+ "use strict";
16
+
17
+ 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); }
18
+ 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; }
19
+ 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; }
20
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
22
+ 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); }
23
+ var company = {
24
+ value: 'company-1',
25
+ label: 'Acme Inc',
26
+ type: 'company'
27
+ };
28
+ var client = {
29
+ value: 'client-1',
30
+ label: 'Jane Doe',
31
+ type: 'client',
32
+ companyId: 'company-1'
33
+ };
34
+ var internalUser = {
35
+ value: 'user-1',
36
+ label: 'John Smith',
37
+ type: 'internalUser'
38
+ };
39
+ var companiesMap = new Map([[company.value, company]]);
40
+ describe('getOptionRelevanceScore', function () {
41
+ describe('empty input', function () {
42
+ it('returns 1 (show all) when input is empty', function () {
43
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, '', companiesMap)).toBe(1);
44
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(company, '', companiesMap)).toBe(1);
45
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(internalUser, '', companiesMap)).toBe(1);
46
+ });
47
+ });
48
+ describe('client options', function () {
49
+ it('returns 2 for a direct name match', function () {
50
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'jane', companiesMap)).toBe(2);
51
+ });
52
+ it('returns 1 for a company name match only', function () {
53
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'acme', companiesMap)).toBe(1);
54
+ });
55
+ it('prefers the direct name match (2) over a company match', function () {
56
+ var acmeClient = _objectSpread(_objectSpread({}, client), {}, {
57
+ label: 'Acme Person'
58
+ });
59
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(acmeClient, 'acme', companiesMap)).toBe(2);
60
+ });
61
+ it('returns 0 when neither name nor company match', function () {
62
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'zzz', companiesMap)).toBe(0);
63
+ });
64
+ it('matches case-insensitively', function () {
65
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'JANE', companiesMap)).toBe(2);
66
+ });
67
+ it('returns 0 for a company match when the company is missing from the map', function () {
68
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'acme', new Map())).toBe(0);
69
+ });
70
+ });
71
+ describe('non-client options', function () {
72
+ it('returns 1 for a matching company', function () {
73
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(company, 'acme', companiesMap)).toBe(1);
74
+ });
75
+ it('returns 0 for a non-matching company', function () {
76
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(company, 'zzz', companiesMap)).toBe(0);
77
+ });
78
+ it('returns 1 for a matching internal user', function () {
79
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(internalUser, 'john', companiesMap)).toBe(1);
80
+ });
81
+ });
82
+ describe('ignoreCompanies', function () {
83
+ it('returns 0 for company options when ignoreCompanies is true, even on a match', function () {
84
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(company, 'acme', companiesMap, true)).toBe(0);
85
+ });
86
+ it('returns 0 for company options when ignoreCompanies is true and input is empty', function () {
87
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(company, '', companiesMap, true)).toBe(0);
88
+ });
89
+ it('still scores client options normally when ignoreCompanies is true', function () {
90
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'jane', companiesMap, true)).toBe(2);
91
+ });
92
+ });
93
+ describe('null-safety (bad runtime data)', function () {
94
+ it('does not throw and returns 0 when a client label is null', function () {
95
+ var badClient = _objectSpread(_objectSpread({}, client), {}, {
96
+ label: null
97
+ });
98
+ expect(function () {
99
+ return (0, _getOptionRelevanceScore.getOptionRelevanceScore)(badClient, 'jane', companiesMap);
100
+ }).not.toThrow();
101
+ // name does not match (null), company "Acme" does not match "jane" -> 0
102
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(badClient, 'jane', companiesMap)).toBe(0);
103
+ });
104
+ it('falls back to the company match when a client label is null', function () {
105
+ var badClient = _objectSpread(_objectSpread({}, client), {}, {
106
+ label: undefined
107
+ });
108
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(badClient, 'acme', companiesMap)).toBe(1);
109
+ });
110
+ it('does not throw and returns 0 when a company label is null', function () {
111
+ var badCompany = _objectSpread(_objectSpread({}, company), {}, {
112
+ label: null
113
+ });
114
+ expect(function () {
115
+ return (0, _getOptionRelevanceScore.getOptionRelevanceScore)(badCompany, 'acme', companiesMap);
116
+ }).not.toThrow();
117
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(badCompany, 'acme', companiesMap)).toBe(0);
118
+ });
119
+ it('does not throw when the matching company in the map has a null label', function () {
120
+ var mapWithBadCompany = new Map([[company.value, _objectSpread(_objectSpread({}, company), {}, {
121
+ label: null
122
+ })]]);
123
+ expect(function () {
124
+ return (0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'acme', mapWithBadCompany);
125
+ }).not.toThrow();
126
+ expect((0, _getOptionRelevanceScore.getOptionRelevanceScore)(client, 'acme', mapWithBadCompany)).toBe(0);
127
+ });
128
+ });
129
+ });
130
+ });
@@ -22,14 +22,19 @@
22
22
  * This file is used to generate the data for the combo select stories
23
23
  */
24
24
 
25
- function generateRandomSrc() {
26
- return "https://i.pravatar.cc/150?img=".concat(Math.floor(Math.random() * 70) + 1);
25
+ // Deterministic avatar src so Storybook/Chromatic snapshots are stable across builds.
26
+ // pravatar exposes images 1-70, so we cycle through that range based on the item index.
27
+ function generateSrc(index) {
28
+ return "https://i.pravatar.cc/150?img=".concat(index % 70 + 1);
27
29
  }
28
30
  var firstNames = ['John', 'Jane', 'Alice', 'Bob', 'Lara', 'Mike', 'Sarah', 'David', 'Emily', 'Daniel', 'Chris', 'Olivia', 'James', 'Sophia', 'Henry', 'Emma', 'Liam', 'Mia', 'Noah', 'Zoe'];
29
31
  var lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Miller', 'Davis', 'Garcia', 'Martinez', 'Lopez', 'Clark', 'Lewis', 'Walker', 'Young', 'Allen', 'King', 'Wright', 'Scott', 'Torres', 'Nguyen'];
30
32
 
31
- // Generate unique name combinations
33
+ // Generate unique name combinations deterministically.
34
+ // `offset` lets callers pick a different, non-overlapping slice of the same
35
+ // stable ordering so internal and client lists don't share identical names.
32
36
  function generateUniqueNames(count) {
37
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
33
38
  var combinations = [];
34
39
  for (var _i = 0, _firstNames = firstNames; _i < _firstNames.length; _i++) {
35
40
  var first = _firstNames[_i];
@@ -38,16 +43,12 @@
38
43
  combinations.push("".concat(first, " ").concat(last));
39
44
  }
40
45
  }
41
- // Shuffle and slice to the required count
42
- var shuffled = combinations.sort(function () {
43
- return 0.5 - Math.random();
44
- });
45
- return shuffled.slice(0, count);
46
+ return combinations.slice(offset, offset + count);
46
47
  }
47
48
 
48
- // Get 100 unique names for internal and client users
49
+ // Get 100 unique names for internal and client users (non-overlapping slices)
49
50
  var internalUserNames = generateUniqueNames(100);
50
- var clientUserNames = generateUniqueNames(100);
51
+ var clientUserNames = generateUniqueNames(100, 100);
51
52
 
52
53
  // Generate companies
53
54
  var companies = _exports.companies = Array.from({
@@ -56,7 +57,7 @@
56
57
  return {
57
58
  value: "company-".concat(i + 1),
58
59
  label: "Company ".concat(i + 1),
59
- avatarSrc: generateRandomSrc(),
60
+ avatarSrc: generateSrc(i),
60
61
  type: 'company'
61
62
  };
62
63
  });
@@ -66,20 +67,21 @@
66
67
  return {
67
68
  value: "internal-".concat(i + 1),
68
69
  label: name,
69
- avatarSrc: generateRandomSrc(),
70
+ avatarSrc: generateSrc(i),
70
71
  type: 'internalUser'
71
72
  };
72
73
  });
73
74
 
74
75
  // Generate client users (with valid companyIds)
75
76
  var clientUsers = _exports.clientUsers = clientUserNames.map(function (name, i) {
76
- var _companies$Math$floor;
77
+ var _companies;
77
78
  return {
78
79
  value: "client-".concat(i + 1),
79
80
  label: name,
80
- avatarSrc: generateRandomSrc(),
81
+ avatarSrc: generateSrc(i),
81
82
  type: 'client',
82
- companyId: (_companies$Math$floor = companies[Math.floor(Math.random() * companies.length)]) === null || _companies$Math$floor === void 0 ? void 0 : _companies$Math$floor.value
83
+ // Deterministically distribute clients across companies for stable snapshots.
84
+ companyId: (_companies = companies[i % companies.length]) === null || _companies === void 0 ? void 0 : _companies.value
83
85
  };
84
86
  });
85
87
  });
@@ -0,0 +1,64 @@
1
+ // This file is generated by a script. Do not edit this file directly.
2
+ (function (global, factory) {
3
+ if (typeof define === "function" && define.amd) {
4
+ define(["exports"], factory);
5
+ } else if (typeof exports !== "undefined") {
6
+ factory(exports);
7
+ } else {
8
+ var mod = {
9
+ exports: {}
10
+ };
11
+ factory(mod.exports);
12
+ global.getClassNames = mod.exports;
13
+ }
14
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
15
+ "use strict";
16
+
17
+ Object.defineProperty(_exports, "__esModule", {
18
+ value: true
19
+ });
20
+ _exports.getClassNames = void 0;
21
+ 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); }
22
+ 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; }
23
+ 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; }
24
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
+ 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); }
27
+ var INPUT_CLASSES = 'cop-text-[13px] cop-leading-5 cop-text-primary hover:cop-cursor-text';
28
+ var PLACEHOLDER_CLASSES = 'cop-text-[13px] cop-leading-5';
29
+ var VALUE_CONTAINER_CLASSES = 'cop-flex cop-gap-1';
30
+ var getClassNames = _exports.getClassNames = function getClassNames(variant) {
31
+ var shared = {
32
+ input: function input() {
33
+ return INPUT_CLASSES;
34
+ },
35
+ placeholder: function placeholder() {
36
+ return PLACEHOLDER_CLASSES;
37
+ },
38
+ valueContainer: function valueContainer() {
39
+ return VALUE_CONTAINER_CLASSES;
40
+ }
41
+ };
42
+ if (variant === 'unified') {
43
+ return _objectSpread(_objectSpread({}, shared), {}, {
44
+ container: function container() {
45
+ return 'cop-border cop-border-solid cop-border-secondary cop-rounded cop-shadow-popover-50 cop-overflow-hidden';
46
+ },
47
+ control: function control() {
48
+ return 'cop-px-3 cop-py-[2px]';
49
+ },
50
+ menuList: function menuList() {
51
+ return 'cop-relative cop-bg-white';
52
+ }
53
+ });
54
+ }
55
+ return _objectSpread(_objectSpread({}, shared), {}, {
56
+ control: function control() {
57
+ return 'cop-border-solid cop-border-[1px] cop-border-secondary focus-within:cop-border-primary cop-px-3 cop-py-[2px] cop-rounded';
58
+ },
59
+ menuList: function menuList() {
60
+ return 'cop-relative cop-bg-white cop-shadow-popover-50 cop-rounded cop-border cop-border-solid cop-border-secondary cop-mt-1';
61
+ }
62
+ });
63
+ };
64
+ });
@@ -0,0 +1,53 @@
1
+ // This file is generated by a script. Do not edit this file directly.
2
+ (function (global, factory) {
3
+ if (typeof define === "function" && define.amd) {
4
+ define(["exports"], factory);
5
+ } else if (typeof exports !== "undefined") {
6
+ factory(exports);
7
+ } else {
8
+ var mod = {
9
+ exports: {}
10
+ };
11
+ factory(mod.exports);
12
+ global.getOptionRelevanceScore = mod.exports;
13
+ }
14
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
15
+ "use strict";
16
+
17
+ Object.defineProperty(_exports, "__esModule", {
18
+ value: true
19
+ });
20
+ _exports.getOptionRelevanceScore = void 0;
21
+ /**
22
+ * Returns a relevance score for an option based on the input value.
23
+ * Higher scores indicate more relevant matches (direct name matches > company name matches).
24
+ *
25
+ * This is a pure function so it can be unit-tested in isolation.
26
+ *
27
+ * @param option - the option to score
28
+ * @param inputValue - the current search input
29
+ * @param companiesMap - lookup of company value -> company option (used to match clients by company name)
30
+ * @param ignoreCompanies - when true, company options are excluded from results entirely
31
+ * @returns 2 for direct name match, 1 for company name match only, 0 for no match
32
+ */
33
+ var getOptionRelevanceScore = _exports.getOptionRelevanceScore = function getOptionRelevanceScore(option, inputValue, companiesMap, ignoreCompanies) {
34
+ var _option$label$toLower, _option$label;
35
+ if (ignoreCompanies && option.type === 'company') {
36
+ return 0; // companies are hidden when ignoreCompanies is set
37
+ }
38
+ if (!inputValue) {
39
+ return 1; // Show all options when no input
40
+ }
41
+ var lowerInput = inputValue.toLowerCase();
42
+ var nameMatches = (_option$label$toLower = (_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.toLowerCase().includes(lowerInput)) !== null && _option$label$toLower !== void 0 ? _option$label$toLower : false;
43
+ if (option.type === 'client') {
44
+ var _option$companyId, _company$label$toLowe, _company$label;
45
+ var company = companiesMap.get((_option$companyId = option.companyId) !== null && _option$companyId !== void 0 ? _option$companyId : '');
46
+ var companyMatches = (_company$label$toLowe = company === null || company === void 0 || (_company$label = company.label) === null || _company$label === void 0 ? void 0 : _company$label.toLowerCase().includes(lowerInput)) !== null && _company$label$toLowe !== void 0 ? _company$label$toLowe : false;
47
+ if (nameMatches) return 2; // Direct name match - highest priority
48
+ if (companyMatches) return 1; // Company name match - lower priority
49
+ return 0; // No match
50
+ }
51
+ return nameMatches ? 1 : 0;
52
+ };
53
+ });
@@ -1,7 +1,7 @@
1
1
  import { type VariantProps } from 'cva';
2
2
  import type { ButtonHTMLAttributes } from 'react';
3
3
  declare const baseButtonVariants: (props?: ({
4
- variant?: "primary" | "secondary" | "minimal" | undefined;
4
+ variant?: "primary" | "studio" | "secondary" | "minimal" | undefined;
5
5
  } & ({
6
6
  class?: import("cva").ClassValue;
7
7
  className?: undefined;
@@ -21,3 +21,4 @@ export declare const TextVariant: Story;
21
21
  export declare const Disabled: Story;
22
22
  export declare const Small: Story;
23
23
  export declare const Loading: Story;
24
+ export declare const StudioVariant: Story;