@uxf/ui 1.0.0-beta.112 → 1.0.0-beta.113
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/css/pagination.css +66 -5
- package/css/select.css +18 -2
- package/package.json +1 -1
- package/pagination/index.d.ts +1 -0
- package/pagination/index.js +5 -0
- package/pagination/pagination.d.ts +3 -0
- package/pagination/pagination.js +3 -1
- package/pagination/pagination.stories.d.ts +7 -0
- package/pagination/pagination.stories.js +24 -3
- package/pagination/theme.d.ts +7 -0
- package/pagination/theme.js +2 -0
- package/select/select.d.ts +2 -0
- package/select/select.js +2 -2
- package/select/select.stories.js +4 -1
- package/select/theme.d.ts +5 -0
- package/select/theme.js +2 -0
package/css/pagination.css
CHANGED
|
@@ -2,11 +2,26 @@
|
|
|
2
2
|
@apply isolate inline-flex rounded-md -space-x-px;
|
|
3
3
|
|
|
4
4
|
&__button {
|
|
5
|
-
@apply relative inline-flex items-center border
|
|
6
|
-
|
|
5
|
+
@apply relative inline-flex items-center border text-sm font-medium focus:z-10 cursor-pointer;
|
|
6
|
+
|
|
7
|
+
:root .light & {
|
|
8
|
+
@apply border-gray-300 bg-white text-gray-500 hover:bg-gray-50;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:root .dark & {
|
|
12
|
+
@apply border-gray-600 bg-gray-900 text-gray-200 hover:bg-gray-800;
|
|
13
|
+
}
|
|
7
14
|
|
|
8
15
|
&.is-selected {
|
|
9
|
-
@apply z-10
|
|
16
|
+
@apply z-10;
|
|
17
|
+
|
|
18
|
+
:root .light & {
|
|
19
|
+
@apply bg-indigo-50 border border-primary-500 text-primary-600;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:root .dark & {
|
|
23
|
+
@apply bg-indigo-900/20 border border-primary-700 text-primary-300;
|
|
24
|
+
}
|
|
10
25
|
}
|
|
11
26
|
|
|
12
27
|
&.is-first {
|
|
@@ -18,11 +33,57 @@
|
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
&.is-disabled {
|
|
21
|
-
@apply
|
|
36
|
+
@apply cursor-not-allowed;
|
|
37
|
+
|
|
38
|
+
:root .light & {
|
|
39
|
+
@apply text-neutral-300 hover:bg-white;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:root .dark & {
|
|
43
|
+
@apply text-neutral-500 hover:bg-gray-800;
|
|
44
|
+
}
|
|
22
45
|
}
|
|
23
46
|
|
|
24
47
|
&.is-ellipsis {
|
|
25
|
-
@apply
|
|
48
|
+
@apply pointer-events-none;
|
|
49
|
+
|
|
50
|
+
:root .light & {
|
|
51
|
+
@apply text-neutral-300 hover:bg-white;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:root .dark & {
|
|
55
|
+
@apply text-neutral-500 hover:bg-gray-800;
|
|
56
|
+
}
|
|
26
57
|
}
|
|
27
58
|
}
|
|
59
|
+
|
|
60
|
+
&--size-xs .uxf-pagination__button {
|
|
61
|
+
height: theme("inputSize.xs");
|
|
62
|
+
|
|
63
|
+
@apply px-2;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&--size-sm .uxf-pagination__button {
|
|
67
|
+
height: theme("inputSize.sm");
|
|
68
|
+
|
|
69
|
+
@apply px-3;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&--size-default .uxf-pagination__button {
|
|
73
|
+
height: theme("inputSize.default");
|
|
74
|
+
|
|
75
|
+
@apply px-4;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--size-lg .uxf-pagination__button {
|
|
79
|
+
height: theme("inputSize.lg");
|
|
80
|
+
|
|
81
|
+
@apply px-5;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&--size-xl .uxf-pagination__button {
|
|
85
|
+
height: theme("inputSize.xl");
|
|
86
|
+
|
|
87
|
+
@apply px-6;
|
|
88
|
+
}
|
|
28
89
|
}
|
package/css/select.css
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
@apply relative;
|
|
3
3
|
|
|
4
4
|
&__button {
|
|
5
|
-
height: theme("inputSize.default");
|
|
6
|
-
|
|
7
5
|
@apply relative flex w-full cursor-default flex-row items-center rounded-lg px-4 text-left shadow-sm
|
|
8
6
|
outline-none focus-visible:ring-2 before:absolute before:inset-0 before:pointer-events-none before:border
|
|
9
7
|
before:rounded-lg;
|
|
@@ -69,4 +67,22 @@
|
|
|
69
67
|
@apply -scale-y-100;
|
|
70
68
|
}
|
|
71
69
|
}
|
|
70
|
+
|
|
71
|
+
&--size-sm .uxf-select__button {
|
|
72
|
+
height: theme("inputSize.sm");
|
|
73
|
+
|
|
74
|
+
@apply text-sm;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&--size-default .uxf-select__button {
|
|
78
|
+
height: theme("inputSize.default");
|
|
79
|
+
|
|
80
|
+
@apply text-base;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&--size-lg .uxf-select__button {
|
|
84
|
+
height: theme("inputSize.lg");
|
|
85
|
+
|
|
86
|
+
@apply text-lg;
|
|
87
|
+
}
|
|
72
88
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Pagination } from "./pagination";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pagination = void 0;
|
|
4
|
+
var pagination_1 = require("./pagination");
|
|
5
|
+
Object.defineProperty(exports, "Pagination", { enumerable: true, get: function () { return pagination_1.Pagination; } });
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
+
import { PaginationSizes } from "@uxf/ui/pagination/theme";
|
|
2
3
|
export interface PaginationProps {
|
|
3
4
|
count: number;
|
|
4
5
|
page: number;
|
|
5
6
|
onPageChange: (index: number) => void;
|
|
7
|
+
size?: keyof PaginationSizes;
|
|
8
|
+
className?: string;
|
|
6
9
|
}
|
|
7
10
|
export declare const Pagination: FC<PaginationProps>;
|
package/pagination/pagination.js
CHANGED
|
@@ -9,8 +9,10 @@ const icon_1 = require("../icon");
|
|
|
9
9
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
10
10
|
const usePagination_1 = require("@uxf/core/hooks/usePagination");
|
|
11
11
|
const Pagination = (props) => {
|
|
12
|
+
var _a;
|
|
12
13
|
const isCurrentPageFirst = props.page === 1;
|
|
13
14
|
const isCurrentPageLast = props.page === props.count;
|
|
15
|
+
const className = (0, cx_1.cx)("uxf-pagination", `uxf-pagination--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, props.className);
|
|
14
16
|
const pagination = (0, usePagination_1.usePagination)({
|
|
15
17
|
count: props.count,
|
|
16
18
|
page: props.page,
|
|
@@ -32,7 +34,7 @@ const Pagination = (props) => {
|
|
|
32
34
|
return props.onPageChange(props.count);
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
|
-
return (react_1.default.createElement("nav", { className:
|
|
37
|
+
return (react_1.default.createElement("nav", { className: className }, pagination.map((item, index) => {
|
|
36
38
|
const isDisabled = ((item === "first" || item === "previous") && isCurrentPageFirst) ||
|
|
37
39
|
((item === "last" || item === "next") && isCurrentPageLast);
|
|
38
40
|
return (react_1.default.createElement("a", { key: item, onClick: isDisabled ? undefined : () => onClick(item), className: (0, cx_1.cx)("uxf-pagination__button", isDisabled && "is-disabled", (item === "start-ellipsis" || item === "end-ellipsis") && "is-ellipsis", item === props.page && "is-selected", index === 0 && "is-first", index === pagination.length - 1 && "is-last") }, item === "first" ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/// <reference types="mdx" />
|
|
1
2
|
import React from "react";
|
|
3
|
+
import Docs from "./pagination.docs.mdx";
|
|
2
4
|
declare const _default: {
|
|
3
5
|
title: string;
|
|
4
6
|
component: React.FC<import("./pagination").PaginationProps>;
|
|
7
|
+
parameters: {
|
|
8
|
+
docs: {
|
|
9
|
+
page: typeof Docs;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
5
12
|
};
|
|
6
13
|
export default _default;
|
|
7
14
|
export declare function Default(): JSX.Element;
|
|
@@ -22,18 +22,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.Default = void 0;
|
|
27
30
|
const pagination_1 = require("./pagination");
|
|
28
31
|
const react_1 = __importStar(require("react"));
|
|
32
|
+
const pagination_docs_mdx_1 = __importDefault(require("./pagination.docs.mdx"));
|
|
29
33
|
exports.default = {
|
|
30
34
|
title: "UI/Pagination",
|
|
31
35
|
component: pagination_1.Pagination,
|
|
36
|
+
parameters: {
|
|
37
|
+
docs: {
|
|
38
|
+
page: pagination_docs_mdx_1.default,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
32
41
|
};
|
|
33
42
|
function Default() {
|
|
34
43
|
const [page, setPage] = (0, react_1.useState)(1);
|
|
35
|
-
return (react_1.default.createElement("div",
|
|
36
|
-
react_1.default.createElement("p",
|
|
44
|
+
return (react_1.default.createElement("div", null,
|
|
45
|
+
react_1.default.createElement("p", { className: "pb-4" },
|
|
37
46
|
"Je pot\u0159eba ikona ",
|
|
38
47
|
react_1.default.createElement("b", null, "chevronsLeft"),
|
|
39
48
|
", ",
|
|
@@ -42,6 +51,18 @@ function Default() {
|
|
|
42
51
|
react_1.default.createElement("b", null, "chevronRight"),
|
|
43
52
|
" a ",
|
|
44
53
|
react_1.default.createElement("b", null, "chevronsRight")),
|
|
45
|
-
react_1.default.createElement(
|
|
54
|
+
react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
55
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" },
|
|
56
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "xs" }),
|
|
57
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "sm" }),
|
|
58
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "default" }),
|
|
59
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "lg" }),
|
|
60
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "xl" })),
|
|
61
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 text-white lg:w-1/2" },
|
|
62
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "xs" }),
|
|
63
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "sm" }),
|
|
64
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "default" }),
|
|
65
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "lg" }),
|
|
66
|
+
react_1.default.createElement(pagination_1.Pagination, { count: 10, page: page, onPageChange: setPage, size: "xl" })))));
|
|
46
67
|
}
|
|
47
68
|
exports.Default = Default;
|
package/select/select.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Placement } from "@floating-ui/react";
|
|
|
2
2
|
import React, { ReactNode } from "react";
|
|
3
3
|
import { IconsSet } from "../icon/theme";
|
|
4
4
|
import { FormControlProps } from "../types";
|
|
5
|
+
import { SelectSizes } from "@uxf/ui/select/theme";
|
|
5
6
|
export declare type SelectValue = number | string;
|
|
6
7
|
export declare type SelectOption<T = SelectValue> = {
|
|
7
8
|
disabled?: boolean;
|
|
@@ -20,5 +21,6 @@ export interface SelectProps<Value = SelectValue, Option = SelectOption<Value>>
|
|
|
20
21
|
options: Option[];
|
|
21
22
|
placeholder?: string;
|
|
22
23
|
renderOption?: (option: Option) => ReactNode;
|
|
24
|
+
size?: keyof SelectSizes;
|
|
23
25
|
}
|
|
24
26
|
export declare const Select: React.ForwardRefExoticComponent<SelectProps<SelectValue, SelectOption<SelectValue>> & React.RefAttributes<HTMLDivElement>>;
|
package/select/select.js
CHANGED
|
@@ -35,7 +35,7 @@ const use_dropdown_1 = require("../hooks/use-dropdown");
|
|
|
35
35
|
const icon_1 = require("../icon");
|
|
36
36
|
const label_1 = require("../label");
|
|
37
37
|
exports.Select = (0, forwardRef_1.forwardRef)("Select", (props, ref) => {
|
|
38
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
39
|
const generatedId = (0, react_2.useId)();
|
|
40
40
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
41
41
|
const selectedOption = props.options.find((option) => option.id === props.value);
|
|
@@ -45,7 +45,7 @@ exports.Select = (0, forwardRef_1.forwardRef)("Select", (props, ref) => {
|
|
|
45
45
|
const dropdown = (0, use_dropdown_1.useDropdown)((_b = props.dropdownPlacement) !== null && _b !== void 0 ? _b : "bottom", true);
|
|
46
46
|
const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
|
|
47
47
|
const iconName = (_c = props.iconName) !== null && _c !== void 0 ? _c : "chevronDown";
|
|
48
|
-
return (react_2.default.createElement(react_1.Listbox, { as: "div", className: (0, cx_1.cx)("uxf-select", 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,
|
|
48
|
+
return (react_2.default.createElement(react_1.Listbox, { as: "div", className: (0, cx_1.cx)("uxf-select", `uxf-select--size-${(_d = props.size) !== null && _d !== void 0 ? _d : "default"}`, 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,
|
|
49
49
|
react_2.default.createElement(react_1.Listbox.Label, { as: label_1.Label, isHidden: props.hiddenLabel, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label),
|
|
50
50
|
react_2.default.createElement(react_1.Listbox.Button, { as: "div", className: (0, cx_1.cx)("uxf-select__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 && "is-open"), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
|
|
51
51
|
react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-select__button-text", !(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) && "is-empty") }, (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || props.placeholder),
|
package/select/select.stories.js
CHANGED
|
@@ -62,7 +62,10 @@ function Default() {
|
|
|
62
62
|
react_1.default.createElement(index_1.Select, { helperText: "Helper text", isReadOnly: true, label: "Read only select", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value }),
|
|
63
63
|
react_1.default.createElement(index_1.Select, { helperText: "Helper text", isRequired: true, label: "Required select", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value }),
|
|
64
64
|
react_1.default.createElement(index_1.Select, { dropdownPlacement: "top", isRequired: true, label: "Select with dropdown top", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value }),
|
|
65
|
-
react_1.default.createElement(index_1.Select, { helperText: "Helper text of Select with hidden label", hiddenLabel: true, label: "Hidden label", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value })
|
|
65
|
+
react_1.default.createElement(index_1.Select, { helperText: "Helper text of Select with hidden label", hiddenLabel: true, label: "Hidden label", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value }),
|
|
66
|
+
react_1.default.createElement(index_1.Select, { label: "Size sm", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value, size: "sm" }),
|
|
67
|
+
react_1.default.createElement(index_1.Select, { label: "Size default", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value }),
|
|
68
|
+
react_1.default.createElement(index_1.Select, { label: "Size lg", onChange: handleChange, options: options, placeholder: "Vyberte ..", value: value, size: "lg" })));
|
|
66
69
|
return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
67
70
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storySelects),
|
|
68
71
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storySelects)));
|
package/select/theme.js
ADDED