@veracity/vui 1.3.0 → 1.4.0-rc.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/cjs/checkbox/checkbox.d.ts.map +1 -1
- package/dist/cjs/checkbox/checkbox.js +1 -1
- package/dist/cjs/checkbox/checkbox.types.d.ts +1 -1
- package/dist/cjs/checkbox/checkbox.types.d.ts.map +1 -1
- package/dist/cjs/header/headerAccount.js +1 -1
- package/dist/cjs/radio/radio.d.ts.map +1 -1
- package/dist/cjs/radio/radio.js +1 -1
- package/dist/cjs/radio/radio.types.d.ts +1 -1
- package/dist/cjs/radio/radio.types.d.ts.map +1 -1
- package/dist/cjs/select/select.d.ts.map +1 -1
- package/dist/cjs/select/select.js +7 -6
- package/dist/cjs/select/select.types.d.ts +6 -3
- package/dist/cjs/select/select.types.d.ts.map +1 -1
- package/dist/cjs/select/selectButton.d.ts.map +1 -1
- package/dist/cjs/select/selectButton.js +1 -1
- package/dist/cjs/select/useSelect.d.ts +3 -2
- package/dist/cjs/select/useSelect.d.ts.map +1 -1
- package/dist/cjs/select/useSelect.js +17 -5
- package/dist/cjs/select/useSelect.types.d.ts +6 -1
- package/dist/cjs/select/useSelect.types.d.ts.map +1 -1
- package/dist/esm/checkbox/checkbox.d.ts.map +1 -1
- package/dist/esm/checkbox/checkbox.js +1 -1
- package/dist/esm/checkbox/checkbox.types.d.ts +1 -1
- package/dist/esm/checkbox/checkbox.types.d.ts.map +1 -1
- package/dist/esm/header/headerAccount.js +1 -1
- package/dist/esm/radio/radio.d.ts.map +1 -1
- package/dist/esm/radio/radio.js +1 -1
- package/dist/esm/radio/radio.types.d.ts +1 -1
- package/dist/esm/radio/radio.types.d.ts.map +1 -1
- package/dist/esm/select/select.d.ts.map +1 -1
- package/dist/esm/select/select.js +7 -6
- package/dist/esm/select/select.types.d.ts +6 -3
- package/dist/esm/select/select.types.d.ts.map +1 -1
- package/dist/esm/select/selectButton.d.ts.map +1 -1
- package/dist/esm/select/selectButton.js +1 -1
- package/dist/esm/select/useSelect.d.ts +3 -2
- package/dist/esm/select/useSelect.d.ts.map +1 -1
- package/dist/esm/select/useSelect.js +18 -6
- package/dist/esm/select/useSelect.types.d.ts +6 -1
- package/dist/esm/select/useSelect.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/checkbox/checkbox.tsx +1 -0
- package/src/checkbox/checkbox.types.ts +1 -1
- package/src/header/headerAccount.tsx +1 -1
- package/src/radio/radio.tsx +8 -1
- package/src/radio/radio.types.ts +1 -1
- package/src/select/select.tsx +10 -13
- package/src/select/select.types.ts +7 -3
- package/src/select/selectButton.tsx +1 -0
- package/src/select/useSelect.tsx +22 -6
- package/src/select/useSelect.types.ts +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAwBpE,eAAO,MAAM,YAAY,ulJAkBxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAwBpE,eAAO,MAAM,YAAY,ulJAkBxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,uDAoFnB,CAAA;AAEF,eAAe,QAAQ,CAAA"}
|
|
@@ -110,7 +110,7 @@ exports.Checkbox = (0, core_1.vui)((props, ref) => {
|
|
|
110
110
|
'aria-disabled': disabled
|
|
111
111
|
});
|
|
112
112
|
return (react_1.default.createElement(exports.CheckboxBase, Object.assign({ className: (0, utils_1.cs)('vui-checkbox', className), controlHoverColor: controlHoverColor, ref: ref }, styles.container, aliasedProps, rest),
|
|
113
|
-
react_1.default.createElement(CheckboxControl, Object.assign({ className: "vui-checkboxControl", color: color, focusWithinRing: 3, mr: controlMr }, controlStyles),
|
|
113
|
+
react_1.default.createElement(CheckboxControl, Object.assign({ bg: "white", className: "vui-checkboxControl", color: color, focusWithinRing: 3, mr: controlMr }, controlStyles),
|
|
114
114
|
react_1.default.createElement(CheckboxInput, Object.assign({ className: "vui-checkboxInput", onChange: handleOnChange, ref: inputRef, type: "checkbox" }, { checked, defaultChecked, disabled, id, name, required, value }, inputProps)),
|
|
115
115
|
react_1.default.createElement(icon_1.default, { className: "vui-checkboxIcon", h: "100%", name: icon, w: "100%" })), children !== null && children !== void 0 ? children : (label && (react_1.default.createElement(t_1.default, Object.assign({ className: "vui-checkboxLabel", lineHeight: "normal" }, styles.label), label)))));
|
|
116
116
|
});
|
|
@@ -22,7 +22,7 @@ export declare type CheckboxProps = SystemProps & ThemingProps<'Checkbox'> & {
|
|
|
22
22
|
inputRef?: React.MutableRefObject<HTMLInputElement | null> | null;
|
|
23
23
|
/** Displays the checkbox as indeterminate. */
|
|
24
24
|
isIndeterminate?: boolean;
|
|
25
|
-
/** Socket
|
|
25
|
+
/** Socket for the text next to the checkbox. */
|
|
26
26
|
label?: string;
|
|
27
27
|
/** Passed to the inner input. */
|
|
28
28
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.types.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEhE,oBAAY,aAAa,GAAG,WAAW,GACrC,YAAY,CAAC,UAAU,CA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AC3D,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,QAAQ,CAAA;IAC5B,sDAAsD;IACtD,UAAU,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAA;IAC7C,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACjE,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,iCAAiC;IACjC,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB,CAAA;AAEH,oBAAY,kBAAkB,GAAG;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA"}
|
|
@@ -57,7 +57,7 @@ function HeaderAccount(props) {
|
|
|
57
57
|
const popoverOptions = isMobile ? (0, utils_1.merge)(options, mobilePopoverOptions) : options;
|
|
58
58
|
const contentScreenProps = isMobile
|
|
59
59
|
? { h: `calc(100vh - ${headerHeight}px)`, left: 0, position: 'fixed', top: headerHeight, w: '100vw' }
|
|
60
|
-
: { maxH: 360, py: 1,
|
|
60
|
+
: { maxH: 360, py: 1, minW: 320, w: 'auto' };
|
|
61
61
|
const name = (0, utils_1.isObject)(userInfo) ? userInfo.displayName : '';
|
|
62
62
|
return (react_1.default.createElement(popover_1.default, Object.assign({ isLazy: false, offset: [0, 8], options: popoverOptions, placement: "bottom-end" }, rest),
|
|
63
63
|
react_1.default.createElement(popover_1.default.Trigger, Object.assign({ as: avatar_1.default, className: "vui-headerAccountTrigger", colorScheme: "prussian", isInteractive: true, ml: 2, name: name, title: "Account", variant: "solid" }, styles.trigger, triggerProps)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAuB3D,eAAO,MAAM,SAAS,olJAkBrB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAuB3D,eAAO,MAAM,SAAS,olJAkBrB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,oDA4FhB,CAAA;AAEF,eAAe,KAAK,CAAA"}
|
package/dist/cjs/radio/radio.js
CHANGED
|
@@ -115,7 +115,7 @@ exports.Radio = (0, core_1.vui)((props, ref) => {
|
|
|
115
115
|
'aria-disabled': disabled
|
|
116
116
|
});
|
|
117
117
|
return (react_1.default.createElement(exports.RadioBase, Object.assign({ className: (0, utils_1.cs)('vui-radio', className), controlHoverColor: controlHoverColor, ref: ref }, styles.container, aliasedProps, rest),
|
|
118
|
-
react_1.default.createElement(RadioControl, Object.assign({ className: "vui-radioControl", color: color, focusWithinRing: 3, mr: controlMr }, controlStyles),
|
|
118
|
+
react_1.default.createElement(RadioControl, Object.assign({ bg: "white", className: "vui-radioControl", color: color, focusWithinRing: 3, mr: controlMr }, controlStyles),
|
|
119
119
|
react_1.default.createElement(RadioInput, Object.assign({ className: "vui-radioInput", onChange: handleOnChange, ref: inputRef, type: "radio" }, { checked, defaultChecked, disabled, id, name, required, value }, inputProps)),
|
|
120
120
|
react_1.default.createElement(icon_1.default, { className: "vui-radioIcon", h: "100%", name: icon, w: "100%" })), children !== null && children !== void 0 ? children : (label && (react_1.default.createElement(t_1.default, Object.assign({ className: "vui-radioLabel", lineHeight: "normal" }, styles.label), label)))));
|
|
121
121
|
});
|
|
@@ -18,7 +18,7 @@ export declare type RadioProps = SystemProps & ThemingProps<'Radio'> & {
|
|
|
18
18
|
inputProps?: HTMLAttributes<HTMLInputElement>;
|
|
19
19
|
/** Ref passed to the inner input element. */
|
|
20
20
|
inputRef?: React.MutableRefObject<HTMLInputElement | null> | null;
|
|
21
|
-
/** Socket
|
|
21
|
+
/** Socket for the text next to the item. */
|
|
22
22
|
label?: string;
|
|
23
23
|
/** Passed to the inner input. */
|
|
24
24
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.types.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEhE,oBAAY,UAAU,GAAG,WAAW,GAClC,YAAY,CAAC,OAAO,CAAC,GAAG;IACtB,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,0DAA0D;IAC1D,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,sDAAsD;IACtD,UAAU,CAAC,EAAE,cAAc,CAAC,g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IACjC,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB,CAAA;AAEH,oBAAY,eAAe,GAAG;IAC5B,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/select/select.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAO5C;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/select/select.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAO5C;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,eAoDxC;yBApDe,MAAM;;;;;;;;;AA2DtB,eAAe,MAAM,CAAA"}
|
|
@@ -30,8 +30,9 @@ const useSelect_1 = __importDefault(require("./useSelect"));
|
|
|
30
30
|
* Supports single select and multi select, as well as controlled and uncontrolled modes.
|
|
31
31
|
*/
|
|
32
32
|
function Select(props) {
|
|
33
|
-
|
|
34
|
-
const
|
|
33
|
+
var _a;
|
|
34
|
+
const { children, defaultValue, disabled, isInvalid, isMultiple, name, onChange, options, placeholder = 'Please select', readOnly, selectButton, size, value, variant } = props, rest = __rest(props, ["children", "defaultValue", "disabled", "isInvalid", "isMultiple", "name", "onChange", "options", "placeholder", "readOnly", "selectButton", "size", "value", "variant"]);
|
|
35
|
+
const selectProps = (0, useSelect_1.default)({ defaultValue, isMultiple, onChange, value, options, children });
|
|
35
36
|
if (utils_1.__DEV__ && isMultiple && !Array.isArray(selectProps.value)) {
|
|
36
37
|
console.error('<Select /> is used with isMultiple but its value is not an array: ', value);
|
|
37
38
|
}
|
|
@@ -45,10 +46,10 @@ function Select(props) {
|
|
|
45
46
|
size,
|
|
46
47
|
variant }, selectProps);
|
|
47
48
|
return (react_1.default.createElement(context_1.SelectProvider, { value: context },
|
|
48
|
-
react_1.default.createElement(popover_1.Popover, Object.assign({ matchWidth: true }, rest),
|
|
49
|
-
react_1.default.createElement(selectButton_1.default, null),
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
react_1.default.createElement(popover_1.Popover, Object.assign({ matchWidth: true }, rest),
|
|
50
|
+
react_1.default.createElement(react_1.default.Fragment, null, selectButton !== null && selectButton !== void 0 ? selectButton : react_1.default.createElement(selectButton_1.default, null),
|
|
51
|
+
react_1.default.createElement(selectContent_1.default, null,
|
|
52
|
+
react_1.default.createElement(selectGroup_1.default, null, children !== null && children !== void 0 ? children : (_a = options === null || options === void 0 ? void 0 : options.map) === null || _a === void 0 ? void 0 : _a.call(options, option => react_1.default.createElement(selectOption_1.default, Object.assign({ key: option.value }, option)))))))));
|
|
52
53
|
}
|
|
53
54
|
exports.Select = Select;
|
|
54
55
|
Select.Button = selectButton_1.default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ButtonProps } from '../button';
|
|
2
3
|
import { ListItemProps, ListProps } from '../list';
|
|
3
4
|
import { PopoverContentProps, PopoverProps } from '../popover';
|
|
@@ -16,19 +17,21 @@ export declare type SelectProps = ThemingProps<'Select'> & PopoverProps & UseSel
|
|
|
16
17
|
/** Name of the input. Used in custom change event to support form library integration. */
|
|
17
18
|
name?: string;
|
|
18
19
|
/** Data prop to display an array of options in the popover. */
|
|
19
|
-
options
|
|
20
|
+
options: SelectOptionData[];
|
|
20
21
|
/** Displayed inside the trigger when no value is selected. */
|
|
21
22
|
placeholder?: string;
|
|
22
23
|
/** Select cannot be opened and is styled accordingly. */
|
|
23
24
|
readOnly?: boolean;
|
|
25
|
+
/** Custom select button slot. */
|
|
26
|
+
selectButton?: ReactNode;
|
|
24
27
|
};
|
|
25
28
|
export declare type SelectOptionData = {
|
|
26
29
|
/** Option is displayed as disabled. */
|
|
27
30
|
disabled?: boolean;
|
|
28
31
|
/** Text label of the option. */
|
|
29
|
-
text
|
|
32
|
+
text: string;
|
|
30
33
|
/** Value of a given option. */
|
|
31
|
-
value
|
|
34
|
+
value: SelectValue;
|
|
32
35
|
};
|
|
33
36
|
export declare type SelectOptionProps = ListItemProps & {
|
|
34
37
|
/** Currently selected value. Can be a string/number or array of those when using 'isMultiple'. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.types.d.ts","sourceRoot":"","sources":["../../../src/select/select.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,oBAAY,iBAAiB,GAAG,WAAW,CAAA;AAE3C,oBAAY,kBAAkB,GAAG,mBAAmB,CAAA;AAEpD,oBAAY,aAAa,GAAG,IAAI,CAC9B,WAAW,EACX,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAC/G,GACC,mBAAmB,CAAA;AAErB,oBAAY,gBAAgB,GAAG,SAAS,CAAA;AAExC,oBAAY,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,GAC9C,YAAY,GACZ,cAAc,GAAG;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+DAA+D;IAC/D,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,CAAC,EAAE,OAAO,CAAA;IAClB,iCAAiC;IACjC,YAAY,CAAC,EAAE,SAAS,CAAA;CACzB,CAAA;AAEH,oBAAY,gBAAgB,GAAG;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,KAAK,EAAE,WAAW,CAAA;CACnB,CAAA;AAED,oBAAY,iBAAiB,GAAG,aAAa,GAAG;IAC9C,mGAAmG;IACnG,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB,CAAA;AAED,oBAAY,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectButton.d.ts","sourceRoot":"","sources":["../../../src/select/selectButton.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"selectButton.d.ts","sourceRoot":"","sources":["../../../src/select/selectButton.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,YAAY,2EAgDvB,CAAA;AAEF,eAAe,YAAY,CAAA"}
|
|
@@ -73,6 +73,6 @@ exports.SelectButton = (0, core_1.vui)((props, ref) => {
|
|
|
73
73
|
hoverBorderColor: 'red.80'
|
|
74
74
|
}
|
|
75
75
|
: {};
|
|
76
|
-
return (react_1.default.createElement(popover_1.PopoverTrigger, Object.assign({ as: button_1.LineButton, className: (0, utils_1.cs)('vui-selectButton', className), colorScheme: "prussian", disabled: disabled, focusRing: 2, fontWeight: "regular", iconRight: react_1.default.createElement(button_1.default.Icon, { color: iconColor, ml: "auto", name: "falAngleDown" }), isFullWidth: true, px: 1, ref: ref, text: react_1.default.createElement(button_1.default.Text, { color: textColor }, text), userSelect: "text" }, styles.button, readOnlyProps, isInvalidProps, rest)));
|
|
76
|
+
return (react_1.default.createElement(popover_1.PopoverTrigger, Object.assign({ as: button_1.LineButton, bg: "white", className: (0, utils_1.cs)('vui-selectButton', className), colorScheme: "prussian", disabled: disabled, focusRing: 2, fontWeight: "regular", iconRight: react_1.default.createElement(button_1.default.Icon, { color: iconColor, ml: "auto", name: "falAngleDown" }), isFullWidth: true, px: 1, ref: ref, text: react_1.default.createElement(button_1.default.Text, { color: textColor }, text), userSelect: "text" }, styles.button, readOnlyProps, isInvalidProps, rest)));
|
|
77
77
|
});
|
|
78
78
|
exports.default = exports.SelectButton;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ChangeEvent } from '../utils';
|
|
2
|
+
import { SelectValue } from './select.types';
|
|
2
3
|
import { UseSelectProps } from './useSelect.types';
|
|
3
4
|
/** Handles controlled/uncontrolled value state. Supports single and multiple values. */
|
|
4
5
|
export default function useSelect(props: UseSelectProps): {
|
|
5
6
|
onChange: (e: ChangeEvent) => void;
|
|
6
|
-
value:
|
|
7
|
-
valueText:
|
|
7
|
+
value: SelectValue | SelectValue[] | undefined;
|
|
8
|
+
valueText: SelectValue | undefined;
|
|
8
9
|
};
|
|
9
10
|
export declare type UseSelectReturnType = ReturnType<typeof useSelect>;
|
|
10
11
|
//# sourceMappingURL=useSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAA8B,MAAM,UAAU,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAA8B,MAAM,UAAU,CAAA;AAClE,OAAO,EAAoB,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAQlD,wFAAwF;AACxF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,cAAc;kBAiBjB,WAAW;;;EAiBhD;AAED,oBAAY,mBAAmB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
|
@@ -2,25 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
+
const getValueText = (value, options) => {
|
|
6
|
+
const option = options === null || options === void 0 ? void 0 : options.find((o) => (o === null || o === void 0 ? void 0 : o.value) === value);
|
|
7
|
+
return (option === null || option === void 0 ? void 0 : option.text) || value;
|
|
8
|
+
};
|
|
5
9
|
/** Handles controlled/uncontrolled value state. Supports single and multiple values. */
|
|
6
10
|
function useSelect(props) {
|
|
7
|
-
const { defaultValue, isMultiple, onChange: onChangeProp, value: valueProp } = props;
|
|
11
|
+
const { defaultValue, isMultiple, onChange: onChangeProp, value: valueProp, options = [], children } = props;
|
|
8
12
|
// Not using useControlled here, because we need custom value setter when uncontrolled
|
|
9
13
|
const [stateValue, setStateValue] = (0, react_1.useState)(defaultValue);
|
|
10
14
|
const isControlled = valueProp !== undefined;
|
|
11
15
|
const value = isControlled ? valueProp : stateValue;
|
|
16
|
+
// Iterating over the children to dynamically obtain the list of available options
|
|
17
|
+
const dynamicOptions = [];
|
|
18
|
+
react_1.Children.forEach(children, element => {
|
|
19
|
+
if (!(0, react_1.isValidElement)(element))
|
|
20
|
+
return;
|
|
21
|
+
const option = element.props;
|
|
22
|
+
if (option.text && option.value)
|
|
23
|
+
dynamicOptions.push(option);
|
|
24
|
+
});
|
|
12
25
|
/** Sends a change event to the external consumer, but internall keeps the actual value as primitive or array. */
|
|
13
26
|
const onChange = (0, utils_1.useCallbackRef)((e) => {
|
|
14
27
|
onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(e);
|
|
15
|
-
if (!isControlled)
|
|
28
|
+
if (!isControlled)
|
|
16
29
|
setStateValue(value => (Array.isArray(value) ? (0, utils_1.toggleItem)(value, e.target.value).sort() : e.target.value));
|
|
17
|
-
}
|
|
18
30
|
});
|
|
19
31
|
const valueText = isMultiple && Array.isArray(value)
|
|
20
32
|
? value[0]
|
|
21
|
-
? `${value[0]}${value.length > 1 ? ` (+${value.length - 1})` : ''}`
|
|
33
|
+
? `${getValueText(value[0], [...options, ...dynamicOptions])}${value.length > 1 ? ` (+${value.length - 1})` : ''}`
|
|
22
34
|
: undefined
|
|
23
|
-
: value;
|
|
35
|
+
: getValueText(value, [...options, ...dynamicOptions]);
|
|
24
36
|
return { onChange, value, valueText };
|
|
25
37
|
}
|
|
26
38
|
exports.default = useSelect;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ChangeEvent } from '../utils';
|
|
2
|
-
import { SelectValue } from './select.types';
|
|
3
|
+
import { SelectOptionData, SelectValue } from './select.types';
|
|
3
4
|
export declare type UseSelectProps = {
|
|
4
5
|
/** Currently selected value in controlled mode. */
|
|
5
6
|
value?: SelectValue | SelectValue[];
|
|
@@ -7,6 +8,10 @@ export declare type UseSelectProps = {
|
|
|
7
8
|
defaultValue?: SelectValue | SelectValue[];
|
|
8
9
|
/** Allows choosing multiple values. Popover won't close automatically on item click. */
|
|
9
10
|
isMultiple?: boolean;
|
|
11
|
+
/** List of all available options */
|
|
12
|
+
options?: SelectOptionData[];
|
|
13
|
+
/** Select children elements for dynamic handling */
|
|
14
|
+
children?: ReactNode;
|
|
10
15
|
/**
|
|
11
16
|
* Callback triggered when an option is selected.
|
|
12
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.types.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"useSelect.types.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE9D,oBAAY,cAAc,GAAG;IAC3B,mDAAmD;IACnD,KAAK,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IACnC,mDAAmD;IACnD,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAC1C,wFAAwF;IACxF,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oCAAoC;IACpC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;CACpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAwBpE,eAAO,MAAM,YAAY,ulJAkBxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAwBpE,eAAO,MAAM,YAAY,ulJAkBxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,uDAoFnB,CAAA;AAEF,eAAe,QAAQ,CAAA"}
|
|
@@ -69,7 +69,7 @@ export const Checkbox = vui((props, ref) => {
|
|
|
69
69
|
'aria-disabled': disabled
|
|
70
70
|
});
|
|
71
71
|
return (React.createElement(CheckboxBase, { className: cs('vui-checkbox', className), controlHoverColor: controlHoverColor, ref: ref, ...styles.container, ...aliasedProps, ...rest },
|
|
72
|
-
React.createElement(CheckboxControl, { className: "vui-checkboxControl", color: color, focusWithinRing: 3, mr: controlMr, ...controlStyles },
|
|
72
|
+
React.createElement(CheckboxControl, { bg: "white", className: "vui-checkboxControl", color: color, focusWithinRing: 3, mr: controlMr, ...controlStyles },
|
|
73
73
|
React.createElement(CheckboxInput, { className: "vui-checkboxInput", onChange: handleOnChange, ref: inputRef, type: "checkbox", ...{ checked, defaultChecked, disabled, id, name, required, value }, ...inputProps }),
|
|
74
74
|
React.createElement(Icon, { className: "vui-checkboxIcon", h: "100%", name: icon, w: "100%" })),
|
|
75
75
|
children ??
|
|
@@ -22,7 +22,7 @@ export declare type CheckboxProps = SystemProps & ThemingProps<'Checkbox'> & {
|
|
|
22
22
|
inputRef?: React.MutableRefObject<HTMLInputElement | null> | null;
|
|
23
23
|
/** Displays the checkbox as indeterminate. */
|
|
24
24
|
isIndeterminate?: boolean;
|
|
25
|
-
/** Socket
|
|
25
|
+
/** Socket for the text next to the checkbox. */
|
|
26
26
|
label?: string;
|
|
27
27
|
/** Passed to the inner input. */
|
|
28
28
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.types.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEhE,oBAAY,aAAa,GAAG,WAAW,GACrC,YAAY,CAAC,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DAA2D;IAC3D,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,QAAQ,CAAA;IAC5B,sDAAsD;IACtD,UAAU,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAA;IAC7C,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACjE,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,iCAAiC;IACjC,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB,CAAA;AAEH,oBAAY,kBAAkB,GAAG;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA"}
|
|
@@ -17,7 +17,7 @@ export function HeaderAccount(props) {
|
|
|
17
17
|
const popoverOptions = isMobile ? merge(options, mobilePopoverOptions) : options;
|
|
18
18
|
const contentScreenProps = isMobile
|
|
19
19
|
? { h: `calc(100vh - ${headerHeight}px)`, left: 0, position: 'fixed', top: headerHeight, w: '100vw' }
|
|
20
|
-
: { maxH: 360, py: 1,
|
|
20
|
+
: { maxH: 360, py: 1, minW: 320, w: 'auto' };
|
|
21
21
|
const name = isObject(userInfo) ? userInfo.displayName : '';
|
|
22
22
|
return (React.createElement(Popover, { isLazy: false, offset: [0, 8], options: popoverOptions, placement: "bottom-end", ...rest },
|
|
23
23
|
React.createElement(Popover.Trigger, { as: Avatar, className: "vui-headerAccountTrigger", colorScheme: "prussian", isInteractive: true, ml: 2, name: name, title: "Account", variant: "solid", ...styles.trigger, ...triggerProps }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAuB3D,eAAO,MAAM,SAAS,olJAkBrB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAuB3D,eAAO,MAAM,SAAS,olJAkBrB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,oDA4FhB,CAAA;AAEF,eAAe,KAAK,CAAA"}
|
package/dist/esm/radio/radio.js
CHANGED
|
@@ -74,7 +74,7 @@ export const Radio = vui((props, ref) => {
|
|
|
74
74
|
'aria-disabled': disabled
|
|
75
75
|
});
|
|
76
76
|
return (React.createElement(RadioBase, { className: cs('vui-radio', className), controlHoverColor: controlHoverColor, ref: ref, ...styles.container, ...aliasedProps, ...rest },
|
|
77
|
-
React.createElement(RadioControl, { className: "vui-radioControl", color: color, focusWithinRing: 3, mr: controlMr, ...controlStyles },
|
|
77
|
+
React.createElement(RadioControl, { bg: "white", className: "vui-radioControl", color: color, focusWithinRing: 3, mr: controlMr, ...controlStyles },
|
|
78
78
|
React.createElement(RadioInput, { className: "vui-radioInput", onChange: handleOnChange, ref: inputRef, type: "radio", ...{ checked, defaultChecked, disabled, id, name, required, value }, ...inputProps }),
|
|
79
79
|
React.createElement(Icon, { className: "vui-radioIcon", h: "100%", name: icon, w: "100%" })),
|
|
80
80
|
children ??
|
|
@@ -18,7 +18,7 @@ export declare type RadioProps = SystemProps & ThemingProps<'Radio'> & {
|
|
|
18
18
|
inputProps?: HTMLAttributes<HTMLInputElement>;
|
|
19
19
|
/** Ref passed to the inner input element. */
|
|
20
20
|
inputRef?: React.MutableRefObject<HTMLInputElement | null> | null;
|
|
21
|
-
/** Socket
|
|
21
|
+
/** Socket for the text next to the item. */
|
|
22
22
|
label?: string;
|
|
23
23
|
/** Passed to the inner input. */
|
|
24
24
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.types.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEhE,oBAAY,UAAU,GAAG,WAAW,GAClC,YAAY,CAAC,OAAO,CAAC,GAAG;IACtB,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,0DAA0D;IAC1D,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,sDAAsD;IACtD,UAAU,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAA;IAC7C,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACjE,
|
|
1
|
+
{"version":3,"file":"radio.types.d.ts","sourceRoot":"","sources":["../../../src/radio/radio.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D;IAC7D,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/select/select.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAO5C;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/select/select.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAO5C;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,eAoDxC;yBApDe,MAAM;;;;;;;;;AA2DtB,eAAe,MAAM,CAAA"}
|
|
@@ -13,8 +13,8 @@ import useSelect from './useSelect';
|
|
|
13
13
|
* Supports single select and multi select, as well as controlled and uncontrolled modes.
|
|
14
14
|
*/
|
|
15
15
|
export function Select(props) {
|
|
16
|
-
const { children, defaultValue, disabled, isInvalid, isMultiple, name, onChange, options, placeholder = 'Please select', readOnly, size, value, variant, ...rest } = props;
|
|
17
|
-
const selectProps = useSelect({ defaultValue, isMultiple, onChange, value });
|
|
16
|
+
const { children, defaultValue, disabled, isInvalid, isMultiple, name, onChange, options, placeholder = 'Please select', readOnly, selectButton, size, value, variant, ...rest } = props;
|
|
17
|
+
const selectProps = useSelect({ defaultValue, isMultiple, onChange, value, options, children });
|
|
18
18
|
if (__DEV__ && isMultiple && !Array.isArray(selectProps.value)) {
|
|
19
19
|
console.error('<Select /> is used with isMultiple but its value is not an array: ', value);
|
|
20
20
|
}
|
|
@@ -31,10 +31,11 @@ export function Select(props) {
|
|
|
31
31
|
...selectProps
|
|
32
32
|
};
|
|
33
33
|
return (React.createElement(SelectProvider, { value: context },
|
|
34
|
-
React.createElement(Popover, { matchWidth: true, ...rest },
|
|
35
|
-
React.createElement(
|
|
36
|
-
|
|
37
|
-
React.createElement(
|
|
34
|
+
React.createElement(Popover, { matchWidth: true, ...rest },
|
|
35
|
+
React.createElement(React.Fragment, null,
|
|
36
|
+
selectButton ?? React.createElement(SelectButton, null),
|
|
37
|
+
React.createElement(SelectContent, null,
|
|
38
|
+
React.createElement(SelectGroup, null, children ?? options?.map?.(option => React.createElement(SelectOption, { key: option.value, ...option }))))))));
|
|
38
39
|
}
|
|
39
40
|
Select.Button = SelectButton;
|
|
40
41
|
Select.Content = SelectContent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ButtonProps } from '../button';
|
|
2
3
|
import { ListItemProps, ListProps } from '../list';
|
|
3
4
|
import { PopoverContentProps, PopoverProps } from '../popover';
|
|
@@ -16,19 +17,21 @@ export declare type SelectProps = ThemingProps<'Select'> & PopoverProps & UseSel
|
|
|
16
17
|
/** Name of the input. Used in custom change event to support form library integration. */
|
|
17
18
|
name?: string;
|
|
18
19
|
/** Data prop to display an array of options in the popover. */
|
|
19
|
-
options
|
|
20
|
+
options: SelectOptionData[];
|
|
20
21
|
/** Displayed inside the trigger when no value is selected. */
|
|
21
22
|
placeholder?: string;
|
|
22
23
|
/** Select cannot be opened and is styled accordingly. */
|
|
23
24
|
readOnly?: boolean;
|
|
25
|
+
/** Custom select button slot. */
|
|
26
|
+
selectButton?: ReactNode;
|
|
24
27
|
};
|
|
25
28
|
export declare type SelectOptionData = {
|
|
26
29
|
/** Option is displayed as disabled. */
|
|
27
30
|
disabled?: boolean;
|
|
28
31
|
/** Text label of the option. */
|
|
29
|
-
text
|
|
32
|
+
text: string;
|
|
30
33
|
/** Value of a given option. */
|
|
31
|
-
value
|
|
34
|
+
value: SelectValue;
|
|
32
35
|
};
|
|
33
36
|
export declare type SelectOptionProps = ListItemProps & {
|
|
34
37
|
/** Currently selected value. Can be a string/number or array of those when using 'isMultiple'. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.types.d.ts","sourceRoot":"","sources":["../../../src/select/select.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,oBAAY,iBAAiB,GAAG,WAAW,CAAA;AAE3C,oBAAY,kBAAkB,GAAG,mBAAmB,CAAA;AAEpD,oBAAY,aAAa,GAAG,IAAI,CAC9B,WAAW,EACX,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAC/G,GACC,mBAAmB,CAAA;AAErB,oBAAY,gBAAgB,GAAG,SAAS,CAAA;AAExC,oBAAY,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,GAC9C,YAAY,GACZ,cAAc,GAAG;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,0FAA0F;IAC1F,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"select.types.d.ts","sourceRoot":"","sources":["../../../src/select/select.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CA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,MAAM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectButton.d.ts","sourceRoot":"","sources":["../../../src/select/selectButton.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"selectButton.d.ts","sourceRoot":"","sources":["../../../src/select/selectButton.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,YAAY,2EAgDvB,CAAA;AAEF,eAAe,YAAY,CAAA"}
|
|
@@ -32,6 +32,6 @@ export const SelectButton = vui((props, ref) => {
|
|
|
32
32
|
hoverBorderColor: 'red.80'
|
|
33
33
|
}
|
|
34
34
|
: {};
|
|
35
|
-
return (React.createElement(PopoverTrigger, { as: LineButton, className: cs('vui-selectButton', className), colorScheme: "prussian", disabled: disabled, focusRing: 2, fontWeight: "regular", iconRight: React.createElement(Button.Icon, { color: iconColor, ml: "auto", name: "falAngleDown" }), isFullWidth: true, px: 1, ref: ref, text: React.createElement(Button.Text, { color: textColor }, text), userSelect: "text", ...styles.button, ...readOnlyProps, ...isInvalidProps, ...rest }));
|
|
35
|
+
return (React.createElement(PopoverTrigger, { as: LineButton, bg: "white", className: cs('vui-selectButton', className), colorScheme: "prussian", disabled: disabled, focusRing: 2, fontWeight: "regular", iconRight: React.createElement(Button.Icon, { color: iconColor, ml: "auto", name: "falAngleDown" }), isFullWidth: true, px: 1, ref: ref, text: React.createElement(Button.Text, { color: textColor }, text), userSelect: "text", ...styles.button, ...readOnlyProps, ...isInvalidProps, ...rest }));
|
|
36
36
|
});
|
|
37
37
|
export default SelectButton;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ChangeEvent } from '../utils';
|
|
2
|
+
import { SelectValue } from './select.types';
|
|
2
3
|
import { UseSelectProps } from './useSelect.types';
|
|
3
4
|
/** Handles controlled/uncontrolled value state. Supports single and multiple values. */
|
|
4
5
|
export default function useSelect(props: UseSelectProps): {
|
|
5
6
|
onChange: (e: ChangeEvent) => void;
|
|
6
|
-
value:
|
|
7
|
-
valueText:
|
|
7
|
+
value: SelectValue | SelectValue[] | undefined;
|
|
8
|
+
valueText: SelectValue | undefined;
|
|
8
9
|
};
|
|
9
10
|
export declare type UseSelectReturnType = ReturnType<typeof useSelect>;
|
|
10
11
|
//# sourceMappingURL=useSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAA8B,MAAM,UAAU,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAA8B,MAAM,UAAU,CAAA;AAClE,OAAO,EAAoB,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAQlD,wFAAwF;AACxF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,cAAc;kBAiBjB,WAAW;;;EAiBhD;AAED,oBAAY,mBAAmB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
|
@@ -1,23 +1,35 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { Children, isValidElement, useState } from 'react';
|
|
2
2
|
import { toggleItem, useCallbackRef } from '../utils';
|
|
3
|
+
const getValueText = (value, options) => {
|
|
4
|
+
const option = options?.find((o) => o?.value === value);
|
|
5
|
+
return option?.text || value;
|
|
6
|
+
};
|
|
3
7
|
/** Handles controlled/uncontrolled value state. Supports single and multiple values. */
|
|
4
8
|
export default function useSelect(props) {
|
|
5
|
-
const { defaultValue, isMultiple, onChange: onChangeProp, value: valueProp } = props;
|
|
9
|
+
const { defaultValue, isMultiple, onChange: onChangeProp, value: valueProp, options = [], children } = props;
|
|
6
10
|
// Not using useControlled here, because we need custom value setter when uncontrolled
|
|
7
11
|
const [stateValue, setStateValue] = useState(defaultValue);
|
|
8
12
|
const isControlled = valueProp !== undefined;
|
|
9
13
|
const value = isControlled ? valueProp : stateValue;
|
|
14
|
+
// Iterating over the children to dynamically obtain the list of available options
|
|
15
|
+
const dynamicOptions = [];
|
|
16
|
+
Children.forEach(children, element => {
|
|
17
|
+
if (!isValidElement(element))
|
|
18
|
+
return;
|
|
19
|
+
const option = element.props;
|
|
20
|
+
if (option.text && option.value)
|
|
21
|
+
dynamicOptions.push(option);
|
|
22
|
+
});
|
|
10
23
|
/** Sends a change event to the external consumer, but internall keeps the actual value as primitive or array. */
|
|
11
24
|
const onChange = useCallbackRef((e) => {
|
|
12
25
|
onChangeProp?.(e);
|
|
13
|
-
if (!isControlled)
|
|
26
|
+
if (!isControlled)
|
|
14
27
|
setStateValue(value => (Array.isArray(value) ? toggleItem(value, e.target.value).sort() : e.target.value));
|
|
15
|
-
}
|
|
16
28
|
});
|
|
17
29
|
const valueText = isMultiple && Array.isArray(value)
|
|
18
30
|
? value[0]
|
|
19
|
-
? `${value[0]}${value.length > 1 ? ` (+${value.length - 1})` : ''}`
|
|
31
|
+
? `${getValueText(value[0], [...options, ...dynamicOptions])}${value.length > 1 ? ` (+${value.length - 1})` : ''}`
|
|
20
32
|
: undefined
|
|
21
|
-
: value;
|
|
33
|
+
: getValueText(value, [...options, ...dynamicOptions]);
|
|
22
34
|
return { onChange, value, valueText };
|
|
23
35
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ChangeEvent } from '../utils';
|
|
2
|
-
import { SelectValue } from './select.types';
|
|
3
|
+
import { SelectOptionData, SelectValue } from './select.types';
|
|
3
4
|
export declare type UseSelectProps = {
|
|
4
5
|
/** Currently selected value in controlled mode. */
|
|
5
6
|
value?: SelectValue | SelectValue[];
|
|
@@ -7,6 +8,10 @@ export declare type UseSelectProps = {
|
|
|
7
8
|
defaultValue?: SelectValue | SelectValue[];
|
|
8
9
|
/** Allows choosing multiple values. Popover won't close automatically on item click. */
|
|
9
10
|
isMultiple?: boolean;
|
|
11
|
+
/** List of all available options */
|
|
12
|
+
options?: SelectOptionData[];
|
|
13
|
+
/** Select children elements for dynamic handling */
|
|
14
|
+
children?: ReactNode;
|
|
10
15
|
/**
|
|
11
16
|
* Callback triggered when an option is selected.
|
|
12
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.types.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"useSelect.types.d.ts","sourceRoot":"","sources":["../../../src/select/useSelect.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE9D,oBAAY,cAAc,GAAG;IAC3B,mDAAmD;IACnD,KAAK,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IACnC,mDAAmD;IACnD,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAC1C,wFAAwF;IACxF,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oCAAoC;IACpC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;CACpC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veracity/vui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-rc.0",
|
|
4
4
|
"description": "Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -25,7 +25,7 @@ export type CheckboxProps = SystemProps &
|
|
|
25
25
|
inputRef?: React.MutableRefObject<HTMLInputElement | null> | null
|
|
26
26
|
/** Displays the checkbox as indeterminate. */
|
|
27
27
|
isIndeterminate?: boolean
|
|
28
|
-
/** Socket
|
|
28
|
+
/** Socket for the text next to the checkbox. */
|
|
29
29
|
label?: string
|
|
30
30
|
/** Passed to the inner input. */
|
|
31
31
|
name?: string
|
|
@@ -23,7 +23,7 @@ export function HeaderAccount(props: HeaderAccountProps) {
|
|
|
23
23
|
|
|
24
24
|
const contentScreenProps = isMobile
|
|
25
25
|
? { h: `calc(100vh - ${headerHeight}px)`, left: 0, position: 'fixed', top: headerHeight, w: '100vw' }
|
|
26
|
-
: { maxH: 360, py: 1,
|
|
26
|
+
: { maxH: 360, py: 1, minW: 320, w: 'auto' }
|
|
27
27
|
|
|
28
28
|
const name = isObject<HeaderAccountUserInfoData>(userInfo) ? userInfo.displayName : ''
|
|
29
29
|
|
package/src/radio/radio.tsx
CHANGED
|
@@ -116,7 +116,14 @@ export const Radio = vui<'span', RadioProps>((props, ref) => {
|
|
|
116
116
|
{...aliasedProps}
|
|
117
117
|
{...rest}
|
|
118
118
|
>
|
|
119
|
-
<RadioControl
|
|
119
|
+
<RadioControl
|
|
120
|
+
bg="white"
|
|
121
|
+
className="vui-radioControl"
|
|
122
|
+
color={color}
|
|
123
|
+
focusWithinRing={3}
|
|
124
|
+
mr={controlMr}
|
|
125
|
+
{...controlStyles}
|
|
126
|
+
>
|
|
120
127
|
<RadioInput
|
|
121
128
|
className="vui-radioInput"
|
|
122
129
|
onChange={handleOnChange}
|
package/src/radio/radio.types.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type RadioProps = SystemProps &
|
|
|
21
21
|
inputProps?: HTMLAttributes<HTMLInputElement>
|
|
22
22
|
/** Ref passed to the inner input element. */
|
|
23
23
|
inputRef?: React.MutableRefObject<HTMLInputElement | null> | null
|
|
24
|
-
/** Socket
|
|
24
|
+
/** Socket for the text next to the item. */
|
|
25
25
|
label?: string
|
|
26
26
|
/** Passed to the inner input. */
|
|
27
27
|
name?: string
|
package/src/select/select.tsx
CHANGED
|
@@ -27,13 +27,14 @@ export function Select(props: SelectProps) {
|
|
|
27
27
|
options,
|
|
28
28
|
placeholder = 'Please select',
|
|
29
29
|
readOnly,
|
|
30
|
+
selectButton,
|
|
30
31
|
size,
|
|
31
32
|
value,
|
|
32
33
|
variant,
|
|
33
34
|
...rest
|
|
34
35
|
} = props
|
|
35
36
|
|
|
36
|
-
const selectProps = useSelect({ defaultValue, isMultiple, onChange, value })
|
|
37
|
+
const selectProps = useSelect({ defaultValue, isMultiple, onChange, value, options, children })
|
|
37
38
|
|
|
38
39
|
if (__DEV__ && isMultiple && !Array.isArray(selectProps.value)) {
|
|
39
40
|
console.error('<Select /> is used with isMultiple but its value is not an array: ', value)
|
|
@@ -55,18 +56,14 @@ export function Select(props: SelectProps) {
|
|
|
55
56
|
return (
|
|
56
57
|
<SelectProvider value={context}>
|
|
57
58
|
<Popover matchWidth {...rest}>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</SelectGroup>
|
|
67
|
-
</SelectContent>
|
|
68
|
-
</>
|
|
69
|
-
)}
|
|
59
|
+
<>
|
|
60
|
+
{selectButton ?? <SelectButton />}
|
|
61
|
+
<SelectContent>
|
|
62
|
+
<SelectGroup>
|
|
63
|
+
{children ?? options?.map?.(option => <SelectOption key={option.value} {...option} />)}
|
|
64
|
+
</SelectGroup>
|
|
65
|
+
</SelectContent>
|
|
66
|
+
</>
|
|
70
67
|
</Popover>
|
|
71
68
|
</SelectProvider>
|
|
72
69
|
)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
1
3
|
import { ButtonProps } from '../button'
|
|
2
4
|
import { ListItemProps, ListProps } from '../list'
|
|
3
5
|
import { PopoverContentProps, PopoverProps } from '../popover'
|
|
@@ -27,20 +29,22 @@ export type SelectProps = ThemingProps<'Select'> &
|
|
|
27
29
|
/** Name of the input. Used in custom change event to support form library integration. */
|
|
28
30
|
name?: string
|
|
29
31
|
/** Data prop to display an array of options in the popover. */
|
|
30
|
-
options
|
|
32
|
+
options: SelectOptionData[]
|
|
31
33
|
/** Displayed inside the trigger when no value is selected. */
|
|
32
34
|
placeholder?: string
|
|
33
35
|
/** Select cannot be opened and is styled accordingly. */
|
|
34
36
|
readOnly?: boolean
|
|
37
|
+
/** Custom select button slot. */
|
|
38
|
+
selectButton?: ReactNode
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
export type SelectOptionData = {
|
|
38
42
|
/** Option is displayed as disabled. */
|
|
39
43
|
disabled?: boolean
|
|
40
44
|
/** Text label of the option. */
|
|
41
|
-
text
|
|
45
|
+
text: string
|
|
42
46
|
/** Value of a given option. */
|
|
43
|
-
value
|
|
47
|
+
value: SelectValue
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type SelectOptionProps = ListItemProps & {
|
package/src/select/useSelect.tsx
CHANGED
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
1
|
+
import { Children, isValidElement, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { ChangeEvent, toggleItem, useCallbackRef } from '../utils'
|
|
4
|
+
import { SelectOptionData, SelectValue } from './select.types'
|
|
4
5
|
import { UseSelectProps } from './useSelect.types'
|
|
5
6
|
|
|
7
|
+
const getValueText = (value: SelectValue, options: SelectOptionData[]) => {
|
|
8
|
+
const option = options?.find((o: SelectOptionData) => o?.value === value)
|
|
9
|
+
|
|
10
|
+
return option?.text || value
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
/** Handles controlled/uncontrolled value state. Supports single and multiple values. */
|
|
7
14
|
export default function useSelect(props: UseSelectProps) {
|
|
8
|
-
const { defaultValue, isMultiple, onChange: onChangeProp, value: valueProp } = props
|
|
15
|
+
const { defaultValue, isMultiple, onChange: onChangeProp, value: valueProp, options = [], children } = props
|
|
9
16
|
|
|
10
17
|
// Not using useControlled here, because we need custom value setter when uncontrolled
|
|
11
18
|
const [stateValue, setStateValue] = useState(defaultValue)
|
|
12
19
|
const isControlled = valueProp !== undefined
|
|
13
20
|
const value = isControlled ? valueProp : stateValue
|
|
14
21
|
|
|
22
|
+
// Iterating over the children to dynamically obtain the list of available options
|
|
23
|
+
const dynamicOptions: SelectOptionData[] = []
|
|
24
|
+
Children.forEach(children, element => {
|
|
25
|
+
if (!isValidElement(element)) return
|
|
26
|
+
const option: SelectOptionData = element.props as SelectOptionData
|
|
27
|
+
if (option.text && option.value) dynamicOptions.push(option)
|
|
28
|
+
})
|
|
29
|
+
|
|
15
30
|
/** Sends a change event to the external consumer, but internall keeps the actual value as primitive or array. */
|
|
16
31
|
const onChange = useCallbackRef((e: ChangeEvent) => {
|
|
17
32
|
onChangeProp?.(e)
|
|
18
33
|
|
|
19
|
-
if (!isControlled)
|
|
34
|
+
if (!isControlled)
|
|
20
35
|
setStateValue(value => (Array.isArray(value) ? toggleItem(value, e.target.value).sort() : e.target.value))
|
|
21
|
-
}
|
|
22
36
|
})
|
|
23
37
|
|
|
24
38
|
const valueText =
|
|
25
39
|
isMultiple && Array.isArray(value)
|
|
26
40
|
? value[0]
|
|
27
|
-
? `${value[0]
|
|
41
|
+
? `${getValueText(value[0], [...options, ...dynamicOptions])}${
|
|
42
|
+
value.length > 1 ? ` (+${value.length - 1})` : ''
|
|
43
|
+
}`
|
|
28
44
|
: undefined
|
|
29
|
-
: value
|
|
45
|
+
: getValueText(value as SelectValue, [...options, ...dynamicOptions])
|
|
30
46
|
|
|
31
47
|
return { onChange, value, valueText }
|
|
32
48
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
1
3
|
import { ChangeEvent } from '../utils'
|
|
2
|
-
import { SelectValue } from './select.types'
|
|
4
|
+
import { SelectOptionData, SelectValue } from './select.types'
|
|
3
5
|
|
|
4
6
|
export type UseSelectProps = {
|
|
5
7
|
/** Currently selected value in controlled mode. */
|
|
@@ -8,6 +10,10 @@ export type UseSelectProps = {
|
|
|
8
10
|
defaultValue?: SelectValue | SelectValue[]
|
|
9
11
|
/** Allows choosing multiple values. Popover won't close automatically on item click. */
|
|
10
12
|
isMultiple?: boolean
|
|
13
|
+
/** List of all available options */
|
|
14
|
+
options?: SelectOptionData[]
|
|
15
|
+
/** Select children elements for dynamic handling */
|
|
16
|
+
children?: ReactNode
|
|
11
17
|
/**
|
|
12
18
|
* Callback triggered when an option is selected.
|
|
13
19
|
*
|