@assembly-js/design-system 3.1.11 → 3.1.14
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.
- package/dist/esm/components/UserCompanySelector/ListItem.js +12 -9
- package/dist/esm/components/UserCompanySelector/SelectedValueChip.js +5 -1
- package/dist/esm/components/UserCompanySelector/UserCompanySelector.js +36 -46
- package/dist/esm/components/UserCompanySelector/__tests__/getClassNames.test.js +81 -0
- package/dist/esm/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.js +115 -0
- package/dist/esm/components/UserCompanySelector/data.js +17 -15
- package/dist/esm/components/UserCompanySelector/getClassNames.js +44 -0
- package/dist/esm/components/UserCompanySelector/getOptionRelevanceScore.js +33 -0
- package/dist/esm/types/components/UserCompanySelector/ListItem.d.ts +8 -3
- package/dist/esm/types/components/UserCompanySelector/UserCompanySelector.stories.d.ts +2 -0
- package/dist/esm/types/components/UserCompanySelector/__tests__/getClassNames.test.d.ts +1 -0
- package/dist/esm/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts +1 -0
- package/dist/esm/types/components/UserCompanySelector/getClassNames.d.ts +11 -0
- package/dist/esm/types/components/UserCompanySelector/getOptionRelevanceScore.d.ts +14 -0
- package/dist/esm/types/components/UserCompanySelector/types.d.ts +11 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/types/tsconfig.tsbuildinfo +1 -1
- package/dist/styles/main.css +1 -1
- package/dist/types/components/UserCompanySelector/ListItem.d.ts +8 -3
- package/dist/types/components/UserCompanySelector/UserCompanySelector.stories.d.ts +2 -0
- package/dist/types/components/UserCompanySelector/__tests__/getClassNames.test.d.ts +1 -0
- package/dist/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts +1 -0
- package/dist/types/components/UserCompanySelector/getClassNames.d.ts +11 -0
- package/dist/types/components/UserCompanySelector/getOptionRelevanceScore.d.ts +14 -0
- package/dist/types/components/UserCompanySelector/types.d.ts +11 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/components/UserCompanySelector/ListItem.js +15 -12
- package/dist/umd/components/UserCompanySelector/SelectedValueChip.js +5 -1
- package/dist/umd/components/UserCompanySelector/UserCompanySelector.js +38 -50
- package/dist/umd/components/UserCompanySelector/__tests__/getClassNames.test.js +96 -0
- package/dist/umd/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.js +130 -0
- package/dist/umd/components/UserCompanySelector/data.js +17 -15
- package/dist/umd/components/UserCompanySelector/getClassNames.js +64 -0
- package/dist/umd/components/UserCompanySelector/getOptionRelevanceScore.js +53 -0
- package/dist/umd/types/components/UserCompanySelector/ListItem.d.ts +8 -3
- package/dist/umd/types/components/UserCompanySelector/UserCompanySelector.stories.d.ts +2 -0
- package/dist/umd/types/components/UserCompanySelector/__tests__/getClassNames.test.d.ts +1 -0
- package/dist/umd/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts +1 -0
- package/dist/umd/types/components/UserCompanySelector/getClassNames.d.ts +11 -0
- package/dist/umd/types/components/UserCompanySelector/getOptionRelevanceScore.d.ts +14 -0
- package/dist/umd/types/components/UserCompanySelector/types.d.ts +11 -0
- package/dist/umd/types/index.d.ts +1 -1
- package/dist/umd/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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,4 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type OptionWithCompanyMetadata } from './types';
|
|
3
|
-
import { type
|
|
4
|
-
|
|
2
|
+
import { type OptionWithCompanyMetadata, type UserCompanySelectorOption, type UserCompanySelectorGroupedOption } from './types';
|
|
3
|
+
import { type OptionProps } from 'react-select';
|
|
4
|
+
type ListItemProps = OptionProps<UserCompanySelectorOption, true, UserCompanySelectorGroupedOption> & {
|
|
5
|
+
data: OptionWithCompanyMetadata;
|
|
6
|
+
listClassName?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function ListItem(props: ListItemProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -17,3 +17,5 @@ export declare const WithCustomLabels: Story;
|
|
|
17
17
|
export declare const WithListHeading: Story;
|
|
18
18
|
export declare const WithAvatarFallbackColor: Story;
|
|
19
19
|
export declare const SelectClientInManyCompanies: Story;
|
|
20
|
+
export declare const UnifiedVariant: Story;
|
|
21
|
+
export declare const UnifiedVariantWithPlaceholder: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/umd/types/components/UserCompanySelector/__tests__/getOptionRelevanceScore.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type UserCompanySelectorVariant = 'default' | 'unified';
|
|
2
|
+
type ClassNamesResult = {
|
|
3
|
+
container?: () => string;
|
|
4
|
+
control: () => string;
|
|
5
|
+
menuList: () => string;
|
|
6
|
+
input: () => string;
|
|
7
|
+
placeholder: () => string;
|
|
8
|
+
valueContainer: () => string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getClassNames: (variant: UserCompanySelectorVariant) => ClassNamesResult;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UserCompanySelectorOption } from '../../components/UserCompanySelector/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a relevance score for an option based on the input value.
|
|
4
|
+
* Higher scores indicate more relevant matches (direct name matches > company name matches).
|
|
5
|
+
*
|
|
6
|
+
* This is a pure function so it can be unit-tested in isolation.
|
|
7
|
+
*
|
|
8
|
+
* @param option - the option to score
|
|
9
|
+
* @param inputValue - the current search input
|
|
10
|
+
* @param companiesMap - lookup of company value -> company option (used to match clients by company name)
|
|
11
|
+
* @param ignoreCompanies - when true, company options are excluded from results entirely
|
|
12
|
+
* @returns 2 for direct name match, 1 for company name match only, 0 for no match
|
|
13
|
+
*/
|
|
14
|
+
export declare const getOptionRelevanceScore: (option: UserCompanySelectorOption, inputValue: string, companiesMap: Map<string, UserCompanySelectorOption>, ignoreCompanies?: boolean) => number;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { UserCompanySelectorVariant } from './getClassNames';
|
|
2
|
+
export type { UserCompanySelectorVariant };
|
|
1
3
|
export type UserCompanySelectorObjectType = 'company' | 'internalUser' | 'client';
|
|
2
4
|
export type UserCompanySelectorOption = Prettify<{
|
|
3
5
|
value: string;
|
|
@@ -41,6 +43,15 @@ export type UserCompanySelectorProps = {
|
|
|
41
43
|
groupTermPlural: string;
|
|
42
44
|
};
|
|
43
45
|
listHeading?: string;
|
|
46
|
+
listClassName?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Controls the visual layout of the selector.
|
|
49
|
+
* - `'default'`: search input and options list are separate bordered boxes (current behavior).
|
|
50
|
+
* - `'unified'`: a single container wraps both with a divider line between them.
|
|
51
|
+
* @remarks When using `variant="unified"`, do not pass a `menu` key via the `styles` prop —
|
|
52
|
+
* it will override the `position: static` required for the inline layout.
|
|
53
|
+
*/
|
|
54
|
+
variant?: UserCompanySelectorVariant;
|
|
44
55
|
};
|
|
45
56
|
/**
|
|
46
57
|
* @deprecated Use Option instead
|
|
@@ -31,4 +31,4 @@ export * from './components/Callout/Callout';
|
|
|
31
31
|
export * from './components/Toolbar';
|
|
32
32
|
export * from './components/IconPicker';
|
|
33
33
|
export * from './components/UserCompanySelector/UserCompanySelector';
|
|
34
|
-
export type { UserCompanySelectorProps, UserCompanySelectorOption, } from './components/UserCompanySelector/types';
|
|
34
|
+
export type { UserCompanySelectorProps, UserCompanySelectorOption, UserCompanySelectorVariant, } from './components/UserCompanySelector/types';
|