techsbcn-storybook 2.11.2 → 2.12.0
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/components/fields/SelectFieldComponent/SelectAsyncField.d.ts +2 -1
- package/dist/components/fields/SelectFieldComponent/SelectField.d.ts +2 -0
- package/dist/components/fields/SelectFieldComponent/SelectOptionWithTag.d.ts +4 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/shared/SelectOptionTag.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SearchFilters } from '../../../interfaces';
|
|
2
|
+
import { SearchFilters, SelectOptionTag } from '../../../interfaces';
|
|
3
3
|
|
|
4
4
|
type MenuPlacement = 'bottom' | 'auto' | 'top';
|
|
5
5
|
interface SelectAsyncFieldProps {
|
|
@@ -22,6 +22,7 @@ interface SelectAsyncFieldProps {
|
|
|
22
22
|
menuPlacement?: MenuPlacement;
|
|
23
23
|
value?: any[];
|
|
24
24
|
getOptionLabel?: (option: any) => any;
|
|
25
|
+
getOptionTag?: (option: any) => SelectOptionTag | undefined;
|
|
25
26
|
noBorders?: boolean;
|
|
26
27
|
}
|
|
27
28
|
export declare const SelectAsyncField: React.FunctionComponent<SelectAsyncFieldProps>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { SelectOptionTag } from '../../../interfaces';
|
|
2
3
|
|
|
3
4
|
type MenuPlacement = 'bottom' | 'auto' | 'top';
|
|
4
5
|
interface SelectFieldProps {
|
|
@@ -22,6 +23,7 @@ interface SelectFieldProps {
|
|
|
22
23
|
isLoading?: boolean;
|
|
23
24
|
value?: any[];
|
|
24
25
|
getOptionLabel?: (option: any) => any;
|
|
26
|
+
getOptionTag?: (option: any) => SelectOptionTag | undefined;
|
|
25
27
|
addExtraOption?: any;
|
|
26
28
|
noBorders?: boolean;
|
|
27
29
|
}
|
package/dist/index.js
CHANGED
|
@@ -2147,6 +2147,27 @@ var selectFieldSx = (theme) => ({
|
|
|
2147
2147
|
}
|
|
2148
2148
|
}
|
|
2149
2149
|
});
|
|
2150
|
+
var buildFormatOptionLabel = (getOptionTag, getOptionLabel) => (option, meta) => {
|
|
2151
|
+
const optionLabel = getOptionLabel ? getOptionLabel(option) : option.label;
|
|
2152
|
+
const tag = getOptionTag && meta.context === "menu" ? getOptionTag(option) : void 0;
|
|
2153
|
+
if (!tag) return optionLabel;
|
|
2154
|
+
const color = tag.color ?? "primary";
|
|
2155
|
+
return /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: "select-option-with-tag", sx: { display: "flex", alignItems: "center", gap: 1 } }, /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { flex: 1, overflow: "hidden", textOverflow: "ellipsis" } }, optionLabel), /* @__PURE__ */ React10__default.default.createElement(
|
|
2156
|
+
material.Chip,
|
|
2157
|
+
{
|
|
2158
|
+
className: "select-option-tag",
|
|
2159
|
+
label: tag.label,
|
|
2160
|
+
size: "small",
|
|
2161
|
+
sx: (theme) => ({
|
|
2162
|
+
height: 20,
|
|
2163
|
+
borderRadius: 1,
|
|
2164
|
+
fontWeight: 600,
|
|
2165
|
+
color: `${theme.palette[color].main} !important`,
|
|
2166
|
+
backgroundColor: styles.alpha(theme.palette[color].main, 0.12)
|
|
2167
|
+
})
|
|
2168
|
+
}
|
|
2169
|
+
));
|
|
2170
|
+
};
|
|
2150
2171
|
|
|
2151
2172
|
// src/components/fields/SelectFieldComponent/SelectField.scss
|
|
2152
2173
|
var css16 = `.select-field .MuiFormLabel-root {
|
|
@@ -2218,6 +2239,7 @@ var SelectField = ({
|
|
|
2218
2239
|
menuPlacement: props.menuPlacement,
|
|
2219
2240
|
value: props.value,
|
|
2220
2241
|
getOptionLabel: props.getOptionLabel,
|
|
2242
|
+
formatOptionLabel: props.getOptionTag ? buildFormatOptionLabel(props.getOptionTag, props.getOptionLabel) : void 0,
|
|
2221
2243
|
theme: buildReactSelectTheme(theme),
|
|
2222
2244
|
styles: buildReactSelectStyles(theme)
|
|
2223
2245
|
}
|
|
@@ -2292,6 +2314,7 @@ var SelectAsyncField = ({
|
|
|
2292
2314
|
menuPlacement: props.menuPlacement,
|
|
2293
2315
|
value: props.value,
|
|
2294
2316
|
getOptionLabel: props.getOptionLabel,
|
|
2317
|
+
formatOptionLabel: props.getOptionTag ? buildFormatOptionLabel(props.getOptionTag, props.getOptionLabel) : void 0,
|
|
2295
2318
|
theme: buildReactSelectTheme(theme),
|
|
2296
2319
|
styles: buildReactSelectStyles(theme)
|
|
2297
2320
|
}
|