@abydahana/aksara-ui 1.1.3 → 1.1.5
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/aksara.css +23140 -48
- package/dist/aksara.d.ts +23 -0
- package/dist/aksara.esm.js +148 -1
- package/dist/aksara.js +148 -1
- package/dist/aksara.min.css +1 -1
- package/dist/aksara.min.js +1 -1
- package/dist/components/buttons/button-group.d.ts +2 -1
- package/dist/components/buttons/button-group.js +2 -1
- package/dist/components/buttons/button.d.ts +2 -1
- package/dist/components/buttons/button.js +2 -1
- package/dist/components/buttons/close-button.d.ts +2 -0
- package/dist/components/buttons/close-button.js +3 -2
- package/dist/components/data/avatar.d.ts +2 -0
- package/dist/components/data/avatar.js +28 -6
- package/dist/components/data/empty-state.d.ts +13 -0
- package/dist/components/data/empty-state.js +35 -0
- package/dist/components/data/index.d.ts +2 -0
- package/dist/components/data/index.js +2 -0
- package/dist/components/data/user-item.d.ts +17 -0
- package/dist/components/data/user-item.js +53 -0
- package/dist/components/feedback/badge.d.ts +2 -0
- package/dist/components/feedback/badge.js +3 -2
- package/dist/components/feedback/spinner.d.ts +2 -1
- package/dist/components/feedback/spinner.js +2 -1
- package/dist/components/form/dropdown-select.d.ts +19 -0
- package/dist/components/form/dropdown-select.js +80 -0
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/form/input-group.d.ts +2 -1
- package/dist/components/form/input-group.js +2 -1
- package/dist/components/form/input.d.ts +2 -1
- package/dist/components/form/input.js +2 -1
- package/dist/components/form/select.d.ts +2 -1
- package/dist/components/form/select.js +2 -1
- package/dist/components/form/textarea.d.ts +2 -0
- package/dist/components/form/textarea.js +3 -2
- package/dist/components/navigation/index.d.ts +1 -0
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/pagination.d.ts +2 -1
- package/dist/components/navigation/pagination.js +2 -1
- package/dist/components/navigation/user-pill.d.ts +13 -0
- package/dist/components/navigation/user-pill.js +32 -0
- package/dist/components/utils.d.ts +1 -0
- package/dist/fonts/materialdesignicons-webfont.eot +0 -0
- package/dist/fonts/materialdesignicons-webfont.ttf +0 -0
- package/dist/fonts/materialdesignicons-webfont.woff +0 -0
- package/dist/fonts/materialdesignicons-webfont.woff2 +0 -0
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { classNames, toAttributes } from "../utils";
|
|
2
2
|
export function Spinner(props = {}) {
|
|
3
3
|
const { size, variant, label = "Loading...", className = "", attributes } = props;
|
|
4
|
-
const
|
|
4
|
+
const sizeClass = size ? `spinner-${size}` : "";
|
|
5
|
+
const classes = classNames("spinner", sizeClass, variant && `text-${variant}`, className);
|
|
5
6
|
const baseAttrs = toAttributes({
|
|
6
7
|
role: "status",
|
|
7
8
|
"aria-label": label,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ComponentSize } from "../utils";
|
|
2
|
+
export interface DropdownSelectOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconClass?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DropdownSelectProps {
|
|
9
|
+
name: string;
|
|
10
|
+
options: DropdownSelectOption[];
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
btnClassName?: string;
|
|
14
|
+
size?: ComponentSize;
|
|
15
|
+
variant?: "chip" | "form-select";
|
|
16
|
+
attributes?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare function DropdownSelect(props: DropdownSelectProps): string;
|
|
19
|
+
export declare const dropdownSelect: typeof DropdownSelect;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { classNames, escapeHtml } from "../utils";
|
|
2
|
+
import { Input } from "./input";
|
|
3
|
+
import { Button } from "../buttons/button";
|
|
4
|
+
import { Dropdown, DropdownItem, DropdownMenu } from "../overlay/dropdown";
|
|
5
|
+
export function DropdownSelect(props) {
|
|
6
|
+
const { name, options = [], defaultValue, className = "", btnClassName = "", size = props.variant === "form-select" ? "md" : "sm", variant = "chip", attributes } = props;
|
|
7
|
+
const selectedOption = options.find((opt) => opt.value === defaultValue) ?? options[0];
|
|
8
|
+
const isFormSelect = variant === "form-select";
|
|
9
|
+
const dropdownSizeClass = size ? `dropdown-${size}` : "dropdown-md";
|
|
10
|
+
const menuSizeClass = size && size !== "md" ? `dropdown-menu-${size}` : "";
|
|
11
|
+
const selectSizeClass = size ? `form-select-${size}` : "";
|
|
12
|
+
const chipSizeClass = size ? `chip-${size}` : "chip-md";
|
|
13
|
+
const hiddenInput = Input({
|
|
14
|
+
type: "hidden",
|
|
15
|
+
name,
|
|
16
|
+
value: selectedOption?.value ?? ""
|
|
17
|
+
});
|
|
18
|
+
const triggerIcon = selectedOption?.icon
|
|
19
|
+
? `<i class="mdi ${escapeHtml(selectedOption.icon)} ${escapeHtml(selectedOption.iconClass ?? "")} me-1.5 select-current-icon"></i>`
|
|
20
|
+
: "";
|
|
21
|
+
const triggerBtn = isFormSelect
|
|
22
|
+
? `<button type="button" class="form-select ${selectSizeClass} ${btnClassName} text-start d-flex align-items-center justify-content-between cursor-pointer" data-dropdown="" aria-haspopup="true" aria-expanded="false">
|
|
23
|
+
<div class="d-flex align-items-center min-w-0 flex-1 me-2 text-truncate">
|
|
24
|
+
${triggerIcon}
|
|
25
|
+
<span class="select-current-label text-truncate">${escapeHtml(selectedOption?.label ?? "")}</span>
|
|
26
|
+
</div>
|
|
27
|
+
</button>`
|
|
28
|
+
: Button({
|
|
29
|
+
type: "button",
|
|
30
|
+
variant: "secondary",
|
|
31
|
+
soft: true,
|
|
32
|
+
size: size === "md" ? undefined : size,
|
|
33
|
+
className: `${btnClassName || `composer-chip-btn ${chipSizeClass}`}`,
|
|
34
|
+
attributes: {
|
|
35
|
+
"data-dropdown": "",
|
|
36
|
+
"aria-haspopup": "true",
|
|
37
|
+
"aria-expanded": "false"
|
|
38
|
+
},
|
|
39
|
+
children: `
|
|
40
|
+
${triggerIcon}
|
|
41
|
+
<span class="select-current-label">${escapeHtml(selectedOption?.label ?? "")}</span>
|
|
42
|
+
<i class="mdi mdi-chevron-down ms-1 opacity-60"></i>
|
|
43
|
+
`
|
|
44
|
+
});
|
|
45
|
+
const menuItems = options
|
|
46
|
+
.map((opt) => DropdownItem({
|
|
47
|
+
active: opt.value === selectedOption?.value,
|
|
48
|
+
attributes: {
|
|
49
|
+
type: "button",
|
|
50
|
+
"data-dropdown-option": opt.value,
|
|
51
|
+
"data-icon": opt.icon ?? "",
|
|
52
|
+
"data-icon-class": opt.iconClass ?? ""
|
|
53
|
+
},
|
|
54
|
+
content: `
|
|
55
|
+
${opt.icon ? `<i class="mdi ${escapeHtml(opt.icon)} ${escapeHtml(opt.iconClass ?? "")} me-2"></i>` : ""}
|
|
56
|
+
<span>${escapeHtml(opt.label)}</span>
|
|
57
|
+
`
|
|
58
|
+
}))
|
|
59
|
+
.join("\n");
|
|
60
|
+
const menu = DropdownMenu({
|
|
61
|
+
className: `${menuSizeClass} ${isFormSelect ? "dropdown-select-menu" : ""}`.trim(),
|
|
62
|
+
attributes: {
|
|
63
|
+
"data-dropdown-select-menu": name
|
|
64
|
+
},
|
|
65
|
+
children: menuItems
|
|
66
|
+
});
|
|
67
|
+
return Dropdown({
|
|
68
|
+
className: classNames("aksara-select-dropdown", isFormSelect && "variant-form-select w-100", dropdownSizeClass, className),
|
|
69
|
+
attributes: {
|
|
70
|
+
"data-dropdown-select": name,
|
|
71
|
+
...attributes
|
|
72
|
+
},
|
|
73
|
+
children: `
|
|
74
|
+
${hiddenInput}
|
|
75
|
+
${triggerBtn}
|
|
76
|
+
${menu}
|
|
77
|
+
`
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export const dropdownSelect = DropdownSelect;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { classNames, toAttributes } from "../utils";
|
|
2
2
|
export function InputGroup(props = {}) {
|
|
3
3
|
const { children = "", size, className = "", attributes } = props;
|
|
4
|
-
const
|
|
4
|
+
const sizeClass = size ? `input-group-${size}` : "";
|
|
5
|
+
const classes = classNames("input-group", sizeClass, className);
|
|
5
6
|
const baseAttrs = toAttributes(attributes);
|
|
6
7
|
return `<div class="${classes}"${baseAttrs}>${children}</div>`.trim();
|
|
7
8
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ComponentSize } from "../utils";
|
|
1
2
|
export type InputType = "text" | "password" | "email" | "number" | "search" | "tel" | "url" | "date" | "datetime-local" | "time" | "month" | "week" | "color" | "file" | "hidden";
|
|
2
3
|
export interface InputProps {
|
|
3
4
|
type?: InputType;
|
|
@@ -8,7 +9,7 @@ export interface InputProps {
|
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
readOnly?: boolean;
|
|
10
11
|
required?: boolean;
|
|
11
|
-
size?:
|
|
12
|
+
size?: ComponentSize;
|
|
12
13
|
isInvalid?: boolean;
|
|
13
14
|
isValid?: boolean;
|
|
14
15
|
className?: string;
|
|
@@ -2,7 +2,8 @@ import { classNames, toAttributes } from "../utils";
|
|
|
2
2
|
export function Input(props = {}) {
|
|
3
3
|
const { type = "text", name, id, value, placeholder, disabled = false, readOnly = false, required = false, size, isInvalid = false, isValid = false, className = "", attributes } = props;
|
|
4
4
|
const controlClass = type === "color" ? "form-control form-control-color" : "form-control";
|
|
5
|
-
const
|
|
5
|
+
const sizeClass = size ? `form-control-${size}` : "";
|
|
6
|
+
const classes = classNames(controlClass, sizeClass, isInvalid && "is-invalid", isValid && "is-valid", className);
|
|
6
7
|
const baseAttrs = toAttributes({
|
|
7
8
|
type,
|
|
8
9
|
name,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ComponentSize } from "../utils";
|
|
1
2
|
export interface SelectOption {
|
|
2
3
|
label: string;
|
|
3
4
|
value: string | number;
|
|
@@ -15,7 +16,7 @@ export interface SelectProps {
|
|
|
15
16
|
placeholder?: string;
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
required?: boolean;
|
|
18
|
-
size?:
|
|
19
|
+
size?: ComponentSize;
|
|
19
20
|
isInvalid?: boolean;
|
|
20
21
|
isValid?: boolean;
|
|
21
22
|
className?: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { classNames, escapeHtml, toAttributes } from "../utils";
|
|
2
2
|
export function Select(props = {}) {
|
|
3
3
|
const { name, id, options = [], value, placeholder, disabled = false, required = false, size, isInvalid = false, isValid = false, className = "", attributes } = props;
|
|
4
|
-
const
|
|
4
|
+
const sizeClass = size ? `form-select-${size}` : "";
|
|
5
|
+
const classes = classNames("form-select", sizeClass, isInvalid && "is-invalid", isValid && "is-valid", className);
|
|
5
6
|
const baseAttrs = toAttributes({
|
|
6
7
|
name,
|
|
7
8
|
id,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ComponentSize } from "../utils";
|
|
1
2
|
export interface TextareaProps {
|
|
2
3
|
name?: string;
|
|
3
4
|
id?: string;
|
|
@@ -7,6 +8,7 @@ export interface TextareaProps {
|
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
readOnly?: boolean;
|
|
9
10
|
required?: boolean;
|
|
11
|
+
size?: ComponentSize;
|
|
10
12
|
isInvalid?: boolean;
|
|
11
13
|
isValid?: boolean;
|
|
12
14
|
className?: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { classNames, escapeHtml, toAttributes } from "../utils";
|
|
2
2
|
export function Textarea(props = {}) {
|
|
3
|
-
const { name, id, value = "", placeholder, rows = 3, disabled = false, readOnly = false, required = false, isInvalid = false, isValid = false, className = "", autoGrow = false, attributes } = props;
|
|
3
|
+
const { name, id, value = "", placeholder, rows = 3, disabled = false, readOnly = false, required = false, size, isInvalid = false, isValid = false, className = "", autoGrow = false, attributes } = props;
|
|
4
4
|
const isAutoGrow = autoGrow || rows === 1;
|
|
5
|
-
const
|
|
5
|
+
const sizeClass = size ? `form-control-${size}` : "";
|
|
6
|
+
const classes = classNames("form-control", sizeClass, isAutoGrow && "form-control-autogrow", isInvalid && "is-invalid", isValid && "is-valid", className);
|
|
6
7
|
const baseAttrs = toAttributes({
|
|
7
8
|
name,
|
|
8
9
|
id,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ComponentSize } from "../utils";
|
|
1
2
|
export interface PaginationItem {
|
|
2
3
|
label: string;
|
|
3
4
|
href?: string;
|
|
@@ -7,7 +8,7 @@ export interface PaginationItem {
|
|
|
7
8
|
}
|
|
8
9
|
export interface PaginationProps {
|
|
9
10
|
items: PaginationItem[];
|
|
10
|
-
size?:
|
|
11
|
+
size?: ComponentSize;
|
|
11
12
|
className?: string;
|
|
12
13
|
attributes?: Record<string, unknown>;
|
|
13
14
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { classNames, escapeHtml, toAttributes } from "../utils";
|
|
2
2
|
export function Pagination(props) {
|
|
3
3
|
const { items = [], size, className = "", attributes } = props;
|
|
4
|
-
const
|
|
4
|
+
const sizeClass = size ? `pagination-${size}` : "";
|
|
5
|
+
const classes = classNames("pagination", sizeClass, className);
|
|
5
6
|
const baseAttrs = toAttributes(attributes);
|
|
6
7
|
const renderedItems = items
|
|
7
8
|
.map((item) => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface UserPillProps {
|
|
2
|
+
avatar?: string;
|
|
3
|
+
initials?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
handle?: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
menuHtml?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
triggerClassName?: string;
|
|
10
|
+
attributes?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare function UserPill(props: UserPillProps): string;
|
|
13
|
+
export declare const userPill: typeof UserPill;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { classNames, escapeHtml, toAttributes } from "../utils";
|
|
2
|
+
import { Avatar } from "../data/avatar";
|
|
3
|
+
export function UserPill(props) {
|
|
4
|
+
const { avatar, initials, name, handle, subtitle, menuHtml = "", className = "", triggerClassName = "", attributes } = props;
|
|
5
|
+
const containerClasses = classNames("sidebar-user-pill-wrap position-relative mt-auto", className);
|
|
6
|
+
const triggerClasses = classNames("sidebar-user-pill w-100 text-start", triggerClassName);
|
|
7
|
+
const avatarHtml = Avatar({
|
|
8
|
+
src: avatar,
|
|
9
|
+
alt: name,
|
|
10
|
+
initials,
|
|
11
|
+
size: "md",
|
|
12
|
+
shape: "circle",
|
|
13
|
+
className: "sidebar-user-avatar"
|
|
14
|
+
});
|
|
15
|
+
const subText = subtitle || (handle ? `@${handle.replace(/^@/, "")}` : "");
|
|
16
|
+
const menuContainer = menuHtml ? `<div class="sidebar-user-menu d-none" data-user-menu>${menuHtml}</div>` : "";
|
|
17
|
+
const baseAttrs = toAttributes(attributes);
|
|
18
|
+
return `
|
|
19
|
+
<div class="${containerClasses}"${baseAttrs}>
|
|
20
|
+
${menuContainer}
|
|
21
|
+
<button type="button" class="${triggerClasses}" data-user-menu-trigger aria-haspopup="true" aria-expanded="false">
|
|
22
|
+
${avatarHtml}
|
|
23
|
+
<div class="sidebar-user-meta flex-1 min-w-0">
|
|
24
|
+
<div class="sidebar-user-name fw-bold text-truncate">${escapeHtml(name)}</div>
|
|
25
|
+
${subText ? `<div class="sidebar-user-handle text-muted text-truncate">${escapeHtml(subText)}</div>` : ""}
|
|
26
|
+
</div>
|
|
27
|
+
<i class="mdi mdi-dots-horizontal sidebar-user-dots" aria-hidden="true"></i>
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
`.trim();
|
|
31
|
+
}
|
|
32
|
+
export const userPill = UserPill;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type ComponentSize = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
|
|
1
2
|
export declare function escapeHtml(value: unknown): string;
|
|
2
3
|
export declare function classNames(...classes: (string | undefined | null | false | 0)[]): string;
|
|
3
4
|
export declare function toAttributes(attributes?: Record<string, unknown>): string;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|