@uxf/ui 1.0.0-beta.91 → 1.0.0-beta.93
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/checkbox/checkbox.d.ts +2 -1
- package/checkbox/checkbox.js +2 -2
- package/checkbox-visual/checkbox-visual.d.ts +1 -0
- package/checkbox-visual/checkbox-visual.js +2 -2
- package/combobox/combobox.js +1 -1
- package/combobox/combobox.stories.d.ts +1 -1
- package/combobox/combobox.stories.js +4 -3
- package/css/checkbox.css +6 -1
- package/css/chip.css +1 -1
- package/css/combobox.css +3 -3
- package/css/date-picker-input.css +3 -1
- package/css/label.css +1 -1
- package/css/multi-combobox.css +72 -0
- package/css/paper.css +3 -0
- package/css/time-picker-input.css +3 -1
- package/date-picker-input/date-picker-input.stories.js +4 -4
- package/mutli-combobox/index.d.ts +1 -0
- package/mutli-combobox/index.js +17 -0
- package/mutli-combobox/multi-combobox.d.ts +27 -0
- package/mutli-combobox/multi-combobox.js +94 -0
- package/mutli-combobox/multi-combobox.stories.d.ts +10 -0
- package/mutli-combobox/multi-combobox.stories.js +71 -0
- package/package.json +1 -1
- package/paper/paper.d.ts +5 -0
- package/paper/paper.js +13 -0
- package/paper/paper.stories.d.ts +7 -0
- package/paper/paper.stories.js +18 -0
- package/time-picker-input/time-picker-input.stories.js +4 -4
- package/utils/tailwind-config.js +3 -0
package/checkbox/checkbox.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import { FormControlProps } from "../types";
|
|
3
2
|
import { CheckboxSizes } from "../checkbox-visual/theme";
|
|
3
|
+
import { FormControlProps } from "../types";
|
|
4
4
|
export declare type CheckboxSize = keyof CheckboxSizes;
|
|
5
5
|
export interface CheckboxProps extends FormControlProps<boolean> {
|
|
6
6
|
className?: string;
|
|
7
7
|
indeterminate?: boolean;
|
|
8
|
+
isFocused?: boolean;
|
|
8
9
|
label: ReactNode;
|
|
9
10
|
size?: CheckboxSize;
|
|
10
11
|
style?: Partial<CSSProperties>;
|
package/checkbox/checkbox.js
CHANGED
|
@@ -5,14 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Checkbox = void 0;
|
|
7
7
|
const react_1 = require("@headlessui/react");
|
|
8
|
-
const react_2 = __importDefault(require("react"));
|
|
9
8
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
9
|
+
const react_2 = __importDefault(require("react"));
|
|
10
10
|
const checkbox_visual_1 = require("../checkbox-visual");
|
|
11
11
|
exports.Checkbox = (0, forwardRef_1.forwardRef)("Checkbox", (props, ref) => {
|
|
12
12
|
var _a;
|
|
13
13
|
return (react_2.default.createElement(react_1.Switch.Group, null,
|
|
14
14
|
react_2.default.createElement("div", { className: `uxf-checkbox__wrapper ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
|
|
15
15
|
react_2.default.createElement(react_1.Switch, { checked: props.value, className: "uxf-checkbox-visual-wrapper", disabled: props.isDisabled, name: props.name, onChange: props.onChange, ref: ref, style: props.style },
|
|
16
|
-
react_2.default.createElement(checkbox_visual_1.CheckboxVisual, { indeterminate: props.indeterminate, isDisabled: props.isDisabled, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, size: props.size, value: props.value })),
|
|
16
|
+
react_2.default.createElement(checkbox_visual_1.CheckboxVisual, { indeterminate: props.indeterminate, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, size: props.size, value: props.value })),
|
|
17
17
|
react_2.default.createElement(react_1.Switch.Label, { className: "uxf-checkbox__label" }, props.label))));
|
|
18
18
|
});
|
|
@@ -4,6 +4,7 @@ import { CheckboxSizes } from "./theme";
|
|
|
4
4
|
export declare type CheckboxSize = keyof CheckboxSizes;
|
|
5
5
|
export interface CheckboxVisualProps extends FormControlProps<boolean> {
|
|
6
6
|
indeterminate?: boolean;
|
|
7
|
+
isFocused?: boolean;
|
|
7
8
|
size?: CheckboxSize;
|
|
8
9
|
}
|
|
9
10
|
export declare const CheckboxVisual: React.ForwardRefExoticComponent<CheckboxVisualProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CheckboxVisual = void 0;
|
|
7
7
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
8
8
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
9
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
11
|
const icon_1 = require("../icon");
|
|
12
12
|
exports.CheckboxVisual = (0, forwardRef_1.forwardRef)("CheckboxVisual", (props, ref) => {
|
|
13
13
|
var _a;
|
|
14
|
-
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-checkbox", `uxf-checkbox--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, props.indeterminate && classes_1.CLASSES.IS_INDETERMINATE, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.value && classes_1.CLASSES.IS_SELECTED), onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, !props.value); }, ref: ref },
|
|
14
|
+
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-checkbox", `uxf-checkbox--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, props.indeterminate && classes_1.CLASSES.IS_INDETERMINATE, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isFocused && classes_1.CLASSES.IS_FOCUSED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.value && classes_1.CLASSES.IS_SELECTED), onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, !props.value); }, ref: ref },
|
|
15
15
|
react_1.default.createElement("span", { className: "uxf-checkbox__icon" },
|
|
16
16
|
react_1.default.createElement(icon_1.Icon, { name: "check" }))));
|
|
17
17
|
});
|
package/combobox/combobox.js
CHANGED
|
@@ -50,7 +50,7 @@ exports.Combobox = (0, forwardRef_1.forwardRef)("Combobox", (props, ref) => {
|
|
|
50
50
|
const iconName = (_c = props.iconName) !== null && _c !== void 0 ? _c : "chevronDown";
|
|
51
51
|
return (react_2.default.createElement(react_1.Combobox, { as: "div", className: (0, cx_1.cx)("uxf-combobox", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isRequired && classes_1.CLASSES.IS_REQUIRED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.className), onChange: (v) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v.id); }, value: selectedOption, disabled: props.isDisabled || props.isReadOnly }, (renderProps) => (react_2.default.createElement(react_2.default.Fragment, null,
|
|
52
52
|
react_2.default.createElement(react_1.Combobox.Label, { as: label_1.Label, isHidden: props.hiddenLabel, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label),
|
|
53
|
-
react_2.default.createElement(react_1.Combobox.Button, { as: "div", className: (0, cx_1.cx)("uxf-combobox__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID, dropdown.placement === "bottom" && "is-open--bottom", dropdown.placement === "top" && "is-open--top", renderProps.open &&
|
|
53
|
+
react_2.default.createElement(react_1.Combobox.Button, { as: "div", className: (0, cx_1.cx)("uxf-combobox__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID, dropdown.placement === "bottom" && "is-open--bottom", dropdown.placement === "top" && "is-open--top", renderProps.open && classes_1.CLASSES.IS_OPEN), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
|
|
54
54
|
react_2.default.createElement(react_1.Combobox.Input, { className: (0, cx_1.cx)("uxf-combobox__input"), displayValue: (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; }, onBlur: props.onBlur, onChange: (event) => setQuery(event.target.value), placeholder: props.placeholder, ref: stableRef, type: "text" }),
|
|
55
55
|
react_2.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-select__button-icon", renderProps.open && "is-open"), name: iconName })),
|
|
56
56
|
react_2.default.createElement(react_1.Combobox.Options, { className: (0, cx_1.cx)("uxf-dropdown", dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top"), ref: dropdown.floating }, filteredData.map((option) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComboboxValue } from "./combobox";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import { ComboboxValue } from "./combobox";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: React.ForwardRefExoticComponent<import("./combobox").ComboboxProps<ComboboxValue, import("./combobox").ComboboxOption<ComboboxValue>> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -28,16 +28,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ComponentStructure = exports.Default = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const index_1 = require("./index");
|
|
32
31
|
const component_structure_analyzer_1 = __importDefault(require("../utils/component-structure-analyzer"));
|
|
32
|
+
const index_1 = require("./index");
|
|
33
33
|
exports.default = {
|
|
34
34
|
title: "UI/Combobox",
|
|
35
35
|
component: index_1.Combobox,
|
|
36
36
|
};
|
|
37
37
|
const options = [
|
|
38
|
-
{ id: "one", label: "Option one
|
|
39
|
-
{ id: "two", label: "Option two
|
|
38
|
+
{ id: "one", label: "Option one" },
|
|
39
|
+
{ id: "two", label: "Option two" },
|
|
40
40
|
{ id: "three", label: "Option three" },
|
|
41
|
+
{ id: "four", label: "Option with diacritics (ěščřžýáíé)" },
|
|
41
42
|
];
|
|
42
43
|
function Default() {
|
|
43
44
|
const [value, setValue] = (0, react_1.useState)();
|
package/css/checkbox.css
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.uxf-checkbox {
|
|
15
|
-
@apply shrink-0 flex items-center justify-center rounded
|
|
15
|
+
@apply shrink-0 flex items-center justify-center rounded transition outline-none border
|
|
16
|
+
;
|
|
16
17
|
|
|
17
18
|
&__wrapper {
|
|
18
19
|
@apply flex items-center justify-between space-x-3;
|
|
@@ -56,6 +57,10 @@
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
&.is-focused {
|
|
61
|
+
@apply ring-offset-2 ring-2;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
:root .light & {
|
|
60
65
|
@apply border-gray-400;
|
|
61
66
|
|
package/css/chip.css
CHANGED
package/css/combobox.css
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
.uxf-combobox {
|
|
2
|
-
@apply relative
|
|
2
|
+
@apply relative;
|
|
3
3
|
|
|
4
4
|
&__button {
|
|
5
5
|
height: theme("inputSize.default");
|
|
6
6
|
|
|
7
|
-
@apply relative flex w-full cursor-default flex-row items-center rounded-lg px-4 text-left
|
|
8
|
-
outline-none
|
|
7
|
+
@apply relative flex w-full cursor-default flex-row items-center rounded-lg px-4 text-left shadow-sm
|
|
8
|
+
outline-none before:absolute before:inset-0 before:pointer-events-none before:border before:rounded-lg;
|
|
9
9
|
|
|
10
10
|
.uxf-icon {
|
|
11
11
|
@apply h-3;
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
&__wrapper {
|
|
25
|
-
|
|
25
|
+
height: theme("inputSize.default");
|
|
26
|
+
|
|
27
|
+
@apply flex items-center w-full rounded-lg border px-4;
|
|
26
28
|
|
|
27
29
|
:root .light & {
|
|
28
30
|
@apply bg-gray-100 text-gray-900 border-gray-200;
|
package/css/label.css
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.uxf-multi-combobox {
|
|
2
|
+
@apply relative;
|
|
3
|
+
|
|
4
|
+
&__button {
|
|
5
|
+
@apply relative flex flex-row w-full cursor-default flex-wrap items-center rounded-lg pl-4 pr-8 pb-2 text-left
|
|
6
|
+
outline-none before:absolute before:inset-0 before:pointer-events-none before:border before:rounded-lg;
|
|
7
|
+
|
|
8
|
+
.uxf-icon {
|
|
9
|
+
@apply absolute top-3 right-4 h-4;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:root .light & {
|
|
13
|
+
@apply bg-white text-lightHigh before:border-gray-200;
|
|
14
|
+
|
|
15
|
+
.is-empty {
|
|
16
|
+
@apply text-lightLow;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:root .dark & {
|
|
21
|
+
@apply bg-gray-800 text-darkHigh before:border-gray-700;
|
|
22
|
+
|
|
23
|
+
.is-empty {
|
|
24
|
+
@apply text-darkLow;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.is-focused {
|
|
29
|
+
@apply ring-2;
|
|
30
|
+
|
|
31
|
+
:root .light & {
|
|
32
|
+
@apply before:border-none ring-primary-500;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:root .dark & {
|
|
36
|
+
@apply ring-primary-500;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.is-invalid {
|
|
41
|
+
@apply ring-1;
|
|
42
|
+
|
|
43
|
+
:root .light & {
|
|
44
|
+
@apply ring-error-500 text-error-500;
|
|
45
|
+
|
|
46
|
+
.uxf-combobox__input {
|
|
47
|
+
@apply placeholder:text-error-500;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:root .dark & {
|
|
52
|
+
@apply ring-error-500 text-error-500;
|
|
53
|
+
|
|
54
|
+
.uxf-combobox__input {
|
|
55
|
+
@apply placeholder:text-error-500;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__input {
|
|
62
|
+
@apply bg-inherit focus-visible:ring-0 focus-visible:border-0 focus-visible:outline-none;
|
|
63
|
+
|
|
64
|
+
:root .light & {
|
|
65
|
+
@apply placeholder:text-lightLow;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:root .dark & {
|
|
69
|
+
@apply placeholder:text-darkLow;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/css/paper.css
ADDED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
&__wrapper {
|
|
28
|
-
|
|
28
|
+
height: theme("inputSize.default");
|
|
29
|
+
|
|
30
|
+
@apply flex items-center w-full rounded-lg border px-4;
|
|
29
31
|
|
|
30
32
|
:root .light & {
|
|
31
33
|
@apply bg-gray-100 text-gray-900 border-gray-200;
|
|
@@ -43,10 +43,10 @@ exports.default = {
|
|
|
43
43
|
function Default() {
|
|
44
44
|
const [date, setDate] = (0, react_1.useState)(null);
|
|
45
45
|
const testDatePickers = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
-
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test", name: "date", label: "Datum \u010Dehokoliv", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size:
|
|
47
|
-
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-disabled", name: "date-disabled", label: "Datum disabled", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size:
|
|
48
|
-
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-readonly", name: "date-readonly", label: "Datum readonly", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size:
|
|
49
|
-
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-invalid", name: "date-invalid", label: "Datum invalid", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size:
|
|
46
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test", name: "date", label: "Datum \u010Dehokoliv", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size: 20 }), value: date, onChange: (data) => setDate(data !== null && data !== void 0 ? data : null) }),
|
|
47
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-disabled", name: "date-disabled", label: "Datum disabled", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size: 20 }), value: date, onChange: (data) => setDate(data !== null && data !== void 0 ? data : null), isDisabled: true }),
|
|
48
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-readonly", name: "date-readonly", label: "Datum readonly", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size: 20 }), value: date, onChange: (data) => setDate(data !== null && data !== void 0 ? data : null), isReadOnly: true }),
|
|
49
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-invalid", name: "date-invalid", label: "Datum invalid", rightElement: react_1.default.createElement(icon_1.Icon, { name: "calendar", size: 20 }), value: date, onChange: (data) => setDate(data !== null && data !== void 0 ? data : null), isInvalid: true })));
|
|
50
50
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
51
|
react_1.default.createElement("div", { className: "light max-w-[640px] space-y-4 rounded bg-white p-8" }, testDatePickers),
|
|
52
52
|
react_1.default.createElement("div", { className: "dark max-w-[640px] space-y-4 rounded bg-gray-900 p-8 text-white" }, testDatePickers)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./multi-combobox";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./multi-combobox"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Placement } from "@floating-ui/react-dom";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
import { ChipColor } from "../chip";
|
|
4
|
+
import { IconsSet } from "../icon/theme";
|
|
5
|
+
import { FormControlProps } from "../types";
|
|
6
|
+
export declare type MultiComboboxValue = number | string;
|
|
7
|
+
export declare type MultiComboboxOption<T = MultiComboboxValue> = {
|
|
8
|
+
color?: ChipColor;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
id: T;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
13
|
+
export interface MultiComboboxProps<Value = MultiComboboxValue[], Option = MultiComboboxOption> extends FormControlProps<Value | null> {
|
|
14
|
+
className?: string;
|
|
15
|
+
dropdownPlacement?: Placement;
|
|
16
|
+
helperText?: ReactNode;
|
|
17
|
+
hiddenLabel?: boolean;
|
|
18
|
+
iconName?: keyof IconsSet;
|
|
19
|
+
id?: string;
|
|
20
|
+
keyExtractor?: (option: Option) => string | number;
|
|
21
|
+
label: string;
|
|
22
|
+
options: Option[];
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
renderOption?: (option: Option) => ReactNode;
|
|
25
|
+
withCheckboxes?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const MultiCombobox: React.ForwardRefExoticComponent<MultiComboboxProps<MultiComboboxValue[], MultiComboboxOption<MultiComboboxValue>> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.MultiCombobox = void 0;
|
|
27
|
+
const react_1 = require("@headlessui/react");
|
|
28
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
29
|
+
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
30
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
31
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
|
+
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
33
|
+
const slugify_1 = require("@uxf/core/utils/slugify");
|
|
34
|
+
const react_2 = __importStar(require("react"));
|
|
35
|
+
const checkbox_1 = require("../checkbox");
|
|
36
|
+
const chip_1 = require("../chip");
|
|
37
|
+
const use_dropdown_1 = require("../hooks/use-dropdown");
|
|
38
|
+
const icon_1 = require("../icon");
|
|
39
|
+
const label_1 = require("../label");
|
|
40
|
+
exports.MultiCombobox = (0, forwardRef_1.forwardRef)("MultiCombobox", (props, ref) => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
const generatedId = (0, react_2.useId)();
|
|
43
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
44
|
+
const [query, setQuery] = (0, react_2.useState)("");
|
|
45
|
+
const selectedOptions = props.options.filter((option) => { var _a; return (_a = props.value) === null || _a === void 0 ? void 0 : _a.includes(option.id); });
|
|
46
|
+
const filteredData = props.options.filter((item) => {
|
|
47
|
+
var _a;
|
|
48
|
+
return (!((_a = props.value) === null || _a === void 0 ? void 0 : _a.includes(item.id)) || props.withCheckboxes) &&
|
|
49
|
+
(query === "" || (0, slugify_1.slugify)(item.label).includes((0, slugify_1.slugify)(query)));
|
|
50
|
+
});
|
|
51
|
+
const innerRef = (0, react_2.useRef)(null);
|
|
52
|
+
const errorId = props.isInvalid ? `${id}--error-message` : undefined;
|
|
53
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, props.onBlur, props.onFocus);
|
|
54
|
+
const dropdown = (0, use_dropdown_1.useDropdown)((_b = props.dropdownPlacement) !== null && _b !== void 0 ? _b : "bottom", true);
|
|
55
|
+
const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
|
|
56
|
+
const iconName = (_c = props.iconName) !== null && _c !== void 0 ? _c : "chevronDown";
|
|
57
|
+
const handleRemove = (value) => () => {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.filter((v) => v !== value)) !== null && _c !== void 0 ? _c : []);
|
|
60
|
+
};
|
|
61
|
+
const handleCheckboxChange = (value) => (checked) => {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
if (((_a = props.value) === null || _a === void 0 ? void 0 : _a.includes(value)) && !checked) {
|
|
64
|
+
handleRemove(value)();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!((_b = props.value) === null || _b === void 0 ? void 0 : _b.includes(value)) && checked) {
|
|
68
|
+
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, [...((_d = props.value) !== null && _d !== void 0 ? _d : []), value]);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const handleInputKeyDown = (event) => {
|
|
72
|
+
if (event.key === "Backspace" && query === "" && selectedOptions.length > 0) {
|
|
73
|
+
handleRemove(selectedOptions[selectedOptions.length - 1].id)();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleInputChange = (event) => setQuery(event.target.value);
|
|
77
|
+
const handleComboboxValueChange = (v) => {
|
|
78
|
+
var _a;
|
|
79
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v.map((option) => option.id));
|
|
80
|
+
setQuery("");
|
|
81
|
+
};
|
|
82
|
+
return (react_2.default.createElement(react_1.Combobox, { as: "div", className: (0, cx_1.cx)("uxf-combobox", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isRequired && classes_1.CLASSES.IS_REQUIRED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.className), disabled: props.isDisabled || props.isReadOnly, multiple: true, onChange: handleComboboxValueChange, value: selectedOptions }, (renderProps) => (react_2.default.createElement(react_2.default.Fragment, null,
|
|
83
|
+
react_2.default.createElement(react_1.Combobox.Label, { as: label_1.Label, isHidden: props.hiddenLabel, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label),
|
|
84
|
+
react_2.default.createElement(react_1.Combobox.Button, { as: "div", className: (0, cx_1.cx)("uxf-multi-combobox__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID, dropdown.placement === "bottom" && "is-open--bottom", dropdown.placement === "top" && "is-open--top", renderProps.open && classes_1.CLASSES.IS_OPEN), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
|
|
85
|
+
selectedOptions.map((item) => (react_2.default.createElement(chip_1.Chip, { className: "mr-2 mt-2", color: item.color, key: item.id, onClose: handleRemove(item.id), size: "large" }, item.label))),
|
|
86
|
+
react_2.default.createElement(react_1.Combobox.Input, { className: (0, cx_1.cx)("uxf-multi-combobox__input", "mt-2"), onBlur: props.onBlur, onChange: handleInputChange, onKeyDown: handleInputKeyDown, placeholder: props.placeholder, ref: stableRef, type: "text", value: query }),
|
|
87
|
+
react_2.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-select__button-icon", renderProps.open && "is-open"), name: iconName })),
|
|
88
|
+
react_2.default.createElement(react_1.Combobox.Options, { className: (0, cx_1.cx)("uxf-dropdown", dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top"), ref: dropdown.floating }, filteredData.map((option) => {
|
|
89
|
+
var _a, _b, _c, _d;
|
|
90
|
+
const label = (_b = (_a = props.renderOption) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : option.label;
|
|
91
|
+
return (react_2.default.createElement(react_1.Combobox.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && !props.withCheckboxes && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), key: (_d = (_c = props.keyExtractor) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.id, value: option }, (optionState) => (react_2.default.createElement(react_2.default.Fragment, null, props.withCheckboxes ? (react_2.default.createElement(checkbox_1.Checkbox, { isDisabled: optionState.disabled, isFocused: optionState.active, label: label, onChange: handleCheckboxChange(option.id), value: optionState.selected })) : (label)))));
|
|
92
|
+
})),
|
|
93
|
+
props.helperText && (react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText))))));
|
|
94
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MultiComboboxOption } from "./index";
|
|
3
|
+
import { MultiComboboxValue } from "./multi-combobox";
|
|
4
|
+
declare const _default: {
|
|
5
|
+
title: string;
|
|
6
|
+
component: React.ForwardRefExoticComponent<import("./multi-combobox").MultiComboboxProps<MultiComboboxValue[], MultiComboboxOption<MultiComboboxValue>> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
export declare function Default(): JSX.Element;
|
|
10
|
+
export declare function ComponentStructure(): JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ComponentStructure = exports.Default = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const component_structure_analyzer_1 = __importDefault(require("../utils/component-structure-analyzer"));
|
|
32
|
+
const index_1 = require("./index");
|
|
33
|
+
exports.default = {
|
|
34
|
+
title: "UI/MultiCombobox",
|
|
35
|
+
component: index_1.MultiCombobox,
|
|
36
|
+
};
|
|
37
|
+
const options = [
|
|
38
|
+
{ id: "one", label: "Option red", color: "red" },
|
|
39
|
+
{ id: "two", label: "Option blue", color: "blue" },
|
|
40
|
+
{ id: "three", label: "Option green", color: "green" },
|
|
41
|
+
{ id: "four", label: "Option four" },
|
|
42
|
+
{ id: "five", label: "Option five" },
|
|
43
|
+
{ id: "six", label: "Option with diacritics (ěščřžýáíé)" },
|
|
44
|
+
];
|
|
45
|
+
function Default() {
|
|
46
|
+
const [values, setValues] = (0, react_1.useState)();
|
|
47
|
+
const handleChange = (v) => {
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
console.log("Select values: ", v);
|
|
50
|
+
setValues(v);
|
|
51
|
+
};
|
|
52
|
+
const storyComboboxes = (react_1.default.createElement("div", { className: "space-y-8" },
|
|
53
|
+
react_1.default.createElement(index_1.MultiCombobox, { id: "multi-combobox-1", label: "MultiCombobox", name: "multi-combobox", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: values }),
|
|
54
|
+
react_1.default.createElement(index_1.MultiCombobox, { id: "multi-combobox-1", label: "MultiCombobox with checkboxes", name: "multi-combobox", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: values, withCheckboxes: true }),
|
|
55
|
+
react_1.default.createElement(index_1.MultiCombobox, { helperText: "Start typing to see options...", id: "multi-combobox-1", label: "MultiCombobox with helper text", name: "multi-combobox", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: values }),
|
|
56
|
+
react_1.default.createElement(index_1.MultiCombobox, { helperText: "Error message", id: "multi-combobox-1", isInvalid: true, isRequired: true, label: "MultiCombobox invalid", name: "multi-combobox", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: values }),
|
|
57
|
+
react_1.default.createElement(index_1.MultiCombobox, { dropdownPlacement: "top", id: "multi-combobox-1", label: "MultiCombobox with dropdown top", name: "multi-combobox", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: values })));
|
|
58
|
+
return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
59
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyComboboxes),
|
|
60
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyComboboxes)));
|
|
61
|
+
}
|
|
62
|
+
exports.Default = Default;
|
|
63
|
+
function ComponentStructure() {
|
|
64
|
+
const [values, setValues] = (0, react_1.useState)(null);
|
|
65
|
+
const handleChange = (v) => {
|
|
66
|
+
setValues(v);
|
|
67
|
+
};
|
|
68
|
+
return (react_1.default.createElement(component_structure_analyzer_1.default, null,
|
|
69
|
+
react_1.default.createElement(index_1.MultiCombobox, { id: "multi-combobox-structure", name: "multi-combobox", label: "MultiCombobox with helper text", options: options, onChange: handleChange, value: values, helperText: "Start typing to see options..." })));
|
|
70
|
+
}
|
|
71
|
+
exports.ComponentStructure = ComponentStructure;
|
package/package.json
CHANGED
package/paper/paper.d.ts
ADDED
package/paper/paper.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Paper = void 0;
|
|
7
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
10
|
+
exports.Paper = (0, forwardRef_1.forwardRef)("Paper", (props, ref) => {
|
|
11
|
+
const paperClassName = (0, cx_1.cx)("uxf-paper", props.className);
|
|
12
|
+
return (react_1.default.createElement("div", { ref: ref, className: paperClassName }, props.children));
|
|
13
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Default = void 0;
|
|
7
|
+
const paper_1 = require("./paper");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
exports.default = {
|
|
10
|
+
title: "UI/Paper",
|
|
11
|
+
component: paper_1.Paper,
|
|
12
|
+
};
|
|
13
|
+
function Default() {
|
|
14
|
+
return (react_1.default.createElement("div", { className: "flex items-center justify-center bg-gray-100" },
|
|
15
|
+
react_1.default.createElement(paper_1.Paper, null,
|
|
16
|
+
react_1.default.createElement("div", { className: "flex items-center justify-center p-24" }, "Paper default"))));
|
|
17
|
+
}
|
|
18
|
+
exports.Default = Default;
|
|
@@ -34,10 +34,10 @@ exports.default = {
|
|
|
34
34
|
function Default() {
|
|
35
35
|
const [time, setTime] = (0, react_1.useState)(null);
|
|
36
36
|
const testTimePickers = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
|
-
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test", name: "time", label: "\u010Cas \u010Dehokoliv", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size:
|
|
38
|
-
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test-disabled", name: "time-disabled", label: "\u010Cas disabled", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size:
|
|
39
|
-
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test-readonly", name: "time-readonly", label: "\u010Cas readonly", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size:
|
|
40
|
-
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test-invalid", name: "time-invalid", label: "\u010Cas invalid", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size:
|
|
37
|
+
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test", name: "time", label: "\u010Cas \u010Dehokoliv", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size: 20 }), value: time, onChange: (data) => setTime(data) }),
|
|
38
|
+
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test-disabled", name: "time-disabled", label: "\u010Cas disabled", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size: 20 }), value: time, onChange: (data) => setTime(data), isDisabled: true }),
|
|
39
|
+
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test-readonly", name: "time-readonly", label: "\u010Cas readonly", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size: 20 }), value: time, onChange: (data) => setTime(data), isReadOnly: true }),
|
|
40
|
+
react_1.default.createElement(time_picker_input_1.TimePickerInput, { id: "time-test-invalid", name: "time-invalid", label: "\u010Cas invalid", rightElement: react_1.default.createElement(icon_1.Icon, { name: "clock", size: 20 }), value: time, onChange: (data) => setTime(data), isInvalid: true })));
|
|
41
41
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
42
42
|
react_1.default.createElement("div", { className: "light max-w-[640px] space-y-4 rounded bg-white p-8" }, testTimePickers),
|
|
43
43
|
react_1.default.createElement("div", { className: "dark max-w-[640px] space-y-4 rounded bg-gray-900 p-8 text-white" }, testTimePickers)));
|