@abydahana/aksara-ui 0.1.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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +163 -0
  3. package/dist/aksara.css +33499 -0
  4. package/dist/aksara.d.ts +284 -0
  5. package/dist/aksara.esm.js +1604 -0
  6. package/dist/aksara.js +1608 -0
  7. package/dist/aksara.min.css +1 -0
  8. package/dist/aksara.min.js +1 -0
  9. package/dist/components/buttons/button-group.d.ts +10 -0
  10. package/dist/components/buttons/button-group.js +12 -0
  11. package/dist/components/buttons/button.d.ts +18 -0
  12. package/dist/components/buttons/button.js +28 -0
  13. package/dist/components/buttons/close-button.d.ts +9 -0
  14. package/dist/components/buttons/close-button.js +13 -0
  15. package/dist/components/buttons/index.d.ts +3 -0
  16. package/dist/components/buttons/index.js +3 -0
  17. package/dist/components/data/accordion.d.ts +17 -0
  18. package/dist/components/data/accordion.js +37 -0
  19. package/dist/components/data/avatar.d.ts +26 -0
  20. package/dist/components/data/avatar.js +64 -0
  21. package/dist/components/data/card.d.ts +39 -0
  22. package/dist/components/data/card.js +34 -0
  23. package/dist/components/data/carousel.d.ts +15 -0
  24. package/dist/components/data/carousel.js +47 -0
  25. package/dist/components/data/index.d.ts +7 -0
  26. package/dist/components/data/index.js +7 -0
  27. package/dist/components/data/list-group.d.ts +22 -0
  28. package/dist/components/data/list-group.js +30 -0
  29. package/dist/components/data/media-grid.d.ts +19 -0
  30. package/dist/components/data/media-grid.js +47 -0
  31. package/dist/components/data/table.d.ts +35 -0
  32. package/dist/components/data/table.js +30 -0
  33. package/dist/components/feedback/alert.d.ts +10 -0
  34. package/dist/components/feedback/alert.js +19 -0
  35. package/dist/components/feedback/badge.d.ts +13 -0
  36. package/dist/components/feedback/badge.js +10 -0
  37. package/dist/components/feedback/index.d.ts +6 -0
  38. package/dist/components/feedback/index.js +6 -0
  39. package/dist/components/feedback/placeholder.d.ts +9 -0
  40. package/dist/components/feedback/placeholder.js +11 -0
  41. package/dist/components/feedback/progress.d.ts +14 -0
  42. package/dist/components/feedback/progress.js +22 -0
  43. package/dist/components/feedback/spinner.d.ts +9 -0
  44. package/dist/components/feedback/spinner.js +12 -0
  45. package/dist/components/feedback/toast.d.ts +22 -0
  46. package/dist/components/feedback/toast.js +36 -0
  47. package/dist/components/form/checkbox.d.ts +17 -0
  48. package/dist/components/form/checkbox.js +29 -0
  49. package/dist/components/form/floating-label.d.ts +9 -0
  50. package/dist/components/form/floating-label.js +14 -0
  51. package/dist/components/form/form-control.d.ts +30 -0
  52. package/dist/components/form/form-control.js +28 -0
  53. package/dist/components/form/index.d.ts +11 -0
  54. package/dist/components/form/index.js +11 -0
  55. package/dist/components/form/input-group.d.ts +16 -0
  56. package/dist/components/form/input-group.js +14 -0
  57. package/dist/components/form/input.d.ts +18 -0
  58. package/dist/components/form/input.js +19 -0
  59. package/dist/components/form/layout.d.ts +20 -0
  60. package/dist/components/form/layout.js +15 -0
  61. package/dist/components/form/radio.d.ts +32 -0
  62. package/dist/components/form/radio.js +49 -0
  63. package/dist/components/form/range.d.ts +13 -0
  64. package/dist/components/form/range.js +18 -0
  65. package/dist/components/form/select.d.ts +25 -0
  66. package/dist/components/form/select.js +37 -0
  67. package/dist/components/form/switch.d.ts +16 -0
  68. package/dist/components/form/switch.js +30 -0
  69. package/dist/components/form/textarea.d.ts +17 -0
  70. package/dist/components/form/textarea.js +19 -0
  71. package/dist/components/index.d.ts +7 -0
  72. package/dist/components/index.js +7 -0
  73. package/dist/components/navigation/breadcrumb.d.ts +13 -0
  74. package/dist/components/navigation/breadcrumb.js +25 -0
  75. package/dist/components/navigation/index.d.ts +5 -0
  76. package/dist/components/navigation/index.js +5 -0
  77. package/dist/components/navigation/navbar.d.ts +20 -0
  78. package/dist/components/navigation/navbar.js +22 -0
  79. package/dist/components/navigation/pagination.d.ts +15 -0
  80. package/dist/components/navigation/pagination.js +31 -0
  81. package/dist/components/navigation/scrollspy.d.ts +23 -0
  82. package/dist/components/navigation/scrollspy.js +43 -0
  83. package/dist/components/navigation/tabs.d.ts +15 -0
  84. package/dist/components/navigation/tabs.js +56 -0
  85. package/dist/components/overlay/collapse.d.ts +20 -0
  86. package/dist/components/overlay/collapse.js +27 -0
  87. package/dist/components/overlay/dropdown.d.ts +33 -0
  88. package/dist/components/overlay/dropdown.js +41 -0
  89. package/dist/components/overlay/index.d.ts +7 -0
  90. package/dist/components/overlay/index.js +7 -0
  91. package/dist/components/overlay/media-modal.d.ts +15 -0
  92. package/dist/components/overlay/media-modal.js +83 -0
  93. package/dist/components/overlay/modal.d.ts +32 -0
  94. package/dist/components/overlay/modal.js +47 -0
  95. package/dist/components/overlay/offcanvas.d.ts +20 -0
  96. package/dist/components/overlay/offcanvas.js +33 -0
  97. package/dist/components/overlay/popover.d.ts +19 -0
  98. package/dist/components/overlay/popover.js +24 -0
  99. package/dist/components/overlay/tooltip.d.ts +17 -0
  100. package/dist/components/overlay/tooltip.js +21 -0
  101. package/dist/components/utils.d.ts +3 -0
  102. package/dist/components/utils.js +25 -0
  103. package/package.json +111 -0
@@ -0,0 +1,47 @@
1
+ import { classNames, escapeHtml, toAttributes } from "../utils";
2
+ export function MediaGrid(props) {
3
+ const { items = [], maxDisplay = 4, gap = 2, rounded = true, onItemClickAttribute, itemClickDataId, className = "", attributes } = props;
4
+ const count = items.length;
5
+ if (count === 0)
6
+ return "";
7
+ const displayed = items.slice(0, maxDisplay);
8
+ const extraCount = count - maxDisplay;
9
+ let gridVariant = "media-grid-1";
10
+ if (count === 2)
11
+ gridVariant = "media-grid-2";
12
+ else if (count === 3)
13
+ gridVariant = "media-grid-3";
14
+ else if (count >= 4)
15
+ gridVariant = "media-grid-4";
16
+ const containerClasses = classNames("media-grid", gridVariant, gap && `gap-${gap}`, rounded && "rounded-12", "overflow-hidden", className);
17
+ const baseAttrs = toAttributes({
18
+ ...(itemClickDataId ? { "data-media-id": itemClickDataId } : {}),
19
+ ...attributes
20
+ });
21
+ const cellsHtml = displayed
22
+ .map((item, idx) => {
23
+ const isLast = idx === maxDisplay - 1 && extraCount > 0;
24
+ const cellClasses = classNames("media-grid-item", `media-grid-item-${idx + 1}`, isLast && "has-overlay", "position-relative overflow-hidden cursor-pointer");
25
+ const itemAttrs = toAttributes({
26
+ ...(onItemClickAttribute && itemClickDataId ? { [onItemClickAttribute]: itemClickDataId } : {}),
27
+ "data-media-index": item.dataIndex ?? idx,
28
+ ...item.attributes
29
+ });
30
+ const overlayHtml = isLast
31
+ ? `
32
+ <div class="media-grid-overlay position-absolute inset-0 d-flex align-items-center justify-content-center">
33
+ <span class="media-grid-overlay-text font-bold text-white text-24">+${extraCount}</span>
34
+ </div>
35
+ `.trim()
36
+ : "";
37
+ return `
38
+ <div class="${cellClasses}"${itemAttrs}>
39
+ <img src="${escapeHtml(item.src)}" alt="${escapeHtml(item.alt || `Media item ${idx + 1}`)}" class="media-grid-img w-full h-full object-cover block" loading="lazy" />
40
+ ${overlayHtml}
41
+ </div>
42
+ `.trim();
43
+ })
44
+ .join("\n");
45
+ return `<div class="${containerClasses}"${baseAttrs}>${cellsHtml}</div>`.trim();
46
+ }
47
+ export const mediaGrid = MediaGrid;
@@ -0,0 +1,35 @@
1
+ export interface TableProps {
2
+ children?: string;
3
+ striped?: boolean;
4
+ bordered?: boolean;
5
+ borderless?: boolean;
6
+ hover?: boolean;
7
+ small?: boolean;
8
+ responsive?: boolean | "sm" | "md" | "lg" | "xl" | "xxl";
9
+ dark?: boolean;
10
+ className?: string;
11
+ attributes?: Record<string, unknown>;
12
+ }
13
+ export declare function Table(props?: TableProps): string;
14
+ export declare const table: typeof Table;
15
+ export interface TableHeadProps {
16
+ children?: string;
17
+ dark?: boolean;
18
+ className?: string;
19
+ }
20
+ export declare function TableHead(props?: TableHeadProps): string;
21
+ export declare const tableHead: typeof TableHead;
22
+ export interface TableBodyProps {
23
+ children?: string;
24
+ className?: string;
25
+ }
26
+ export declare function TableBody(props?: TableBodyProps): string;
27
+ export declare const tableBody: typeof TableBody;
28
+ export interface TableRowProps {
29
+ children?: string;
30
+ variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
31
+ active?: boolean;
32
+ className?: string;
33
+ }
34
+ export declare function TableRow(props?: TableRowProps): string;
35
+ export declare const tableRow: typeof TableRow;
@@ -0,0 +1,30 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function Table(props = {}) {
3
+ const { children = "", striped = false, bordered = false, borderless = false, hover = false, small = false, responsive = false, dark = false, className = "", attributes } = props;
4
+ const tableClasses = classNames("table", striped && "table-striped", bordered && "table-bordered", borderless && "table-borderless", hover && "table-hover", small && "table-compact table-sm", dark && "table-dark", className);
5
+ const baseAttrs = toAttributes(attributes);
6
+ const tableHtml = `<table class="${tableClasses}"${baseAttrs}>${children}</table>`.trim();
7
+ if (responsive) {
8
+ const responsiveClass = typeof responsive === "string" ? `table-responsive-${responsive}` : "table-responsive";
9
+ return `<div class="${responsiveClass}">${tableHtml}</div>`.trim();
10
+ }
11
+ return tableHtml;
12
+ }
13
+ export const table = Table;
14
+ export function TableHead(props = {}) {
15
+ const { children = "", dark = false, className = "" } = props;
16
+ const classes = classNames(dark && "table-dark", className);
17
+ return `<thead class="${classes}">${children}</thead>`.trim();
18
+ }
19
+ export const tableHead = TableHead;
20
+ export function TableBody(props = {}) {
21
+ const { children = "", className = "" } = props;
22
+ return `<tbody class="${classNames(className)}">${children}</tbody>`.trim();
23
+ }
24
+ export const tableBody = TableBody;
25
+ export function TableRow(props = {}) {
26
+ const { children = "", variant, active = false, className = "" } = props;
27
+ const classes = classNames(variant && `table-${variant}`, active && "table-active", className);
28
+ return `<tr class="${classes}">${children}</tr>`.trim();
29
+ }
30
+ export const tableRow = TableRow;
@@ -0,0 +1,10 @@
1
+ export type AlertVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
2
+ export interface AlertProps {
3
+ content: string;
4
+ variant?: AlertVariant;
5
+ dismissible?: boolean;
6
+ className?: string;
7
+ attributes?: Record<string, unknown>;
8
+ }
9
+ export declare function Alert(props: AlertProps): string;
10
+ export declare const alert: typeof Alert;
@@ -0,0 +1,19 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function Alert(props) {
3
+ const { content, variant = "primary", dismissible = false, className = "", attributes } = props;
4
+ const classes = classNames("alert", `alert-${variant}`, dismissible && "alert-dismissible", className);
5
+ const baseAttrs = toAttributes({
6
+ role: "alert",
7
+ ...attributes
8
+ });
9
+ const closeButton = dismissible
10
+ ? '<button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>'
11
+ : "";
12
+ return `
13
+ <div class="${classes}"${baseAttrs}>
14
+ ${content}
15
+ ${closeButton}
16
+ </div>
17
+ `.trim();
18
+ }
19
+ export const alert = Alert;
@@ -0,0 +1,13 @@
1
+ export type BadgeVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
2
+ export interface BadgeProps {
3
+ label?: string;
4
+ children?: string;
5
+ variant?: BadgeVariant;
6
+ soft?: boolean;
7
+ pill?: boolean;
8
+ dot?: boolean;
9
+ className?: string;
10
+ attributes?: Record<string, unknown>;
11
+ }
12
+ export declare function Badge(props?: BadgeProps): string;
13
+ export declare const badge: typeof Badge;
@@ -0,0 +1,10 @@
1
+ import { classNames, escapeHtml, toAttributes } from "../utils";
2
+ export function Badge(props = {}) {
3
+ const { label, children, variant = "primary", soft = false, pill = false, dot = false, className = "", attributes } = props;
4
+ const prefix = soft ? "badge-soft" : "badge";
5
+ const classes = classNames("badge", `${prefix}-${variant}`, pill && "rounded-pill", dot && `badge-dot text-${variant}`, className);
6
+ const baseAttrs = toAttributes(attributes);
7
+ const content = children !== undefined ? children : label !== undefined ? escapeHtml(label) : "";
8
+ return `<span class="${classes}"${baseAttrs}>${content}</span>`.trim();
9
+ }
10
+ export const badge = Badge;
@@ -0,0 +1,6 @@
1
+ export * from "./alert";
2
+ export * from "./badge";
3
+ export * from "./progress";
4
+ export * from "./spinner";
5
+ export * from "./toast";
6
+ export * from "./placeholder";
@@ -0,0 +1,6 @@
1
+ export * from "./alert";
2
+ export * from "./badge";
3
+ export * from "./progress";
4
+ export * from "./spinner";
5
+ export * from "./toast";
6
+ export * from "./placeholder";
@@ -0,0 +1,9 @@
1
+ export interface PlaceholderProps {
2
+ animation?: "glow" | "wave";
3
+ size?: "xs" | "sm" | "lg";
4
+ variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
5
+ className?: string;
6
+ attributes?: Record<string, unknown>;
7
+ }
8
+ export declare function Placeholder(props?: PlaceholderProps): string;
9
+ export declare const placeholder: typeof Placeholder;
@@ -0,0 +1,11 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function Placeholder(props = {}) {
3
+ const { animation, size, variant, className = "", attributes } = props;
4
+ const classes = classNames("placeholder", animation && `placeholder-${animation}`, size && `placeholder-${size}`, variant && `bg-${variant}`, className);
5
+ const baseAttrs = toAttributes({
6
+ "aria-hidden": "true",
7
+ ...attributes
8
+ });
9
+ return `<span class="${classes}"${baseAttrs}></span>`.trim();
10
+ }
11
+ export const placeholder = Placeholder;
@@ -0,0 +1,14 @@
1
+ export interface ProgressProps {
2
+ value: number;
3
+ min?: number;
4
+ max?: number;
5
+ label?: string;
6
+ variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark";
7
+ striped?: boolean;
8
+ animated?: boolean;
9
+ height?: string | number;
10
+ className?: string;
11
+ attributes?: Record<string, unknown>;
12
+ }
13
+ export declare function Progress(props: ProgressProps): string;
14
+ export declare const progress: typeof Progress;
@@ -0,0 +1,22 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function Progress(props) {
3
+ const { value, min = 0, max = 100, label, variant = "primary", striped = false, animated = false, height, className = "", attributes } = props;
4
+ const percentage = Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100));
5
+ const barClasses = classNames("progress-bar", variant && `bg-${variant}`, striped && "progress-striped", animated && "progress-animated");
6
+ const containerStyle = height ? ` style="height: ${typeof height === "number" ? `${height}px` : height};"` : "";
7
+ const baseAttrs = toAttributes({
8
+ role: "progressbar",
9
+ "aria-valuenow": value,
10
+ "aria-valuemin": min,
11
+ "aria-valuemax": max,
12
+ ...attributes
13
+ });
14
+ return `
15
+ <div class="${classNames("progress", className)}"${containerStyle}>
16
+ <div class="${barClasses}" style="width: ${percentage}%;"${baseAttrs}>
17
+ ${label ?? ""}
18
+ </div>
19
+ </div>
20
+ `.trim();
21
+ }
22
+ export const progress = Progress;
@@ -0,0 +1,9 @@
1
+ export interface SpinnerProps {
2
+ size?: "sm" | "md";
3
+ variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
4
+ label?: string;
5
+ className?: string;
6
+ attributes?: Record<string, unknown>;
7
+ }
8
+ export declare function Spinner(props?: SpinnerProps): string;
9
+ export declare const spinner: typeof Spinner;
@@ -0,0 +1,12 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function Spinner(props = {}) {
3
+ const { size, variant, label = "Loading...", className = "", attributes } = props;
4
+ const classes = classNames("spinner", size === "sm" && "spinner-sm", variant && `text-${variant}`, className);
5
+ const baseAttrs = toAttributes({
6
+ role: "status",
7
+ "aria-label": label,
8
+ ...attributes
9
+ });
10
+ return `<span class="${classes}"${baseAttrs}></span>`.trim();
11
+ }
12
+ export const spinner = Spinner;
@@ -0,0 +1,22 @@
1
+ export interface ToastProps {
2
+ id?: string;
3
+ title?: string;
4
+ time?: string;
5
+ body: string;
6
+ variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
7
+ delay?: number;
8
+ autohide?: boolean;
9
+ dismissible?: boolean;
10
+ className?: string;
11
+ attributes?: Record<string, unknown>;
12
+ }
13
+ export declare function Toast(props: ToastProps): string;
14
+ export declare const toast: typeof Toast;
15
+ export type ToastPlacement = "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end";
16
+ export interface ToastContainerProps {
17
+ children?: string;
18
+ placement?: ToastPlacement;
19
+ className?: string;
20
+ }
21
+ export declare function ToastContainer(props?: ToastContainerProps): string;
22
+ export declare const toastContainer: typeof ToastContainer;
@@ -0,0 +1,36 @@
1
+ import { classNames, escapeHtml, toAttributes } from "../utils";
2
+ export function Toast(props) {
3
+ const { id, title, time, body, variant, delay = 4000, autohide = true, dismissible = true, className = "", attributes } = props;
4
+ const classes = classNames("toast", variant && `toast-${variant}`, className);
5
+ const baseAttrs = toAttributes({
6
+ id,
7
+ role: "alert",
8
+ "aria-live": "assertive",
9
+ "aria-atomic": "true",
10
+ "data-toast-delay": delay,
11
+ "data-toast-autohide": autohide ? "true" : "false",
12
+ ...attributes
13
+ });
14
+ const headerHtml = title
15
+ ? `
16
+ <div class="toast-header">
17
+ <strong class="me-auto">${escapeHtml(title)}</strong>
18
+ ${time ? `<small class="text-muted ms-auto">${escapeHtml(time)}</small>` : ""}
19
+ ${dismissible ? `<button type="button" class="close" data-dismiss="${id ? `#${id}` : "toast"}" aria-label="Close"></button>` : ""}
20
+ </div>
21
+ `
22
+ : "";
23
+ return `
24
+ <div class="${classes}"${baseAttrs}>
25
+ ${headerHtml}
26
+ <div class="toast-body">${body}</div>
27
+ </div>
28
+ `.trim();
29
+ }
30
+ export const toast = Toast;
31
+ export function ToastContainer(props = {}) {
32
+ const { children = "", placement = "top-end", className = "" } = props;
33
+ const classes = classNames("toast-stack", `toast-${placement}`, className);
34
+ return `<div class="${classes}">${children}</div>`.trim();
35
+ }
36
+ export const toastContainer = ToastContainer;
@@ -0,0 +1,17 @@
1
+ export interface CheckboxProps {
2
+ label?: string;
3
+ name?: string;
4
+ id?: string;
5
+ value?: string | number;
6
+ checked?: boolean;
7
+ disabled?: boolean;
8
+ inline?: boolean;
9
+ isInvalid?: boolean;
10
+ isValid?: boolean;
11
+ className?: string;
12
+ inputClassName?: string;
13
+ labelClassName?: string;
14
+ attributes?: Record<string, unknown>;
15
+ }
16
+ export declare function Checkbox(props?: CheckboxProps): string;
17
+ export declare const checkbox: typeof Checkbox;
@@ -0,0 +1,29 @@
1
+ import { classNames, escapeHtml, toAttributes } from "../utils";
2
+ export function Checkbox(props = {}) {
3
+ const { label, name, id, value, checked = false, disabled = false, inline = false, isInvalid = false, isValid = false, className = "", inputClassName = "", labelClassName = "", attributes } = props;
4
+ const containerClasses = classNames("form-check", inline && "form-check-inline", className);
5
+ const inputClasses = classNames("form-check-input", isInvalid && "is-invalid", isValid && "is-valid", inputClassName);
6
+ const baseAttrs = toAttributes({
7
+ type: "checkbox",
8
+ name,
9
+ id,
10
+ value,
11
+ checked,
12
+ disabled,
13
+ ...attributes
14
+ });
15
+ const labelHtml = label
16
+ ? `
17
+ <label class="${classNames("form-check-label", labelClassName)}"${id ? ` for="${escapeHtml(id)}"` : ""}>
18
+ ${escapeHtml(label)}
19
+ </label>
20
+ `.trim()
21
+ : "";
22
+ return `
23
+ <div class="${containerClasses}">
24
+ <input class="${inputClasses}"${baseAttrs} />
25
+ ${labelHtml}
26
+ </div>
27
+ `.trim();
28
+ }
29
+ export const checkbox = Checkbox;
@@ -0,0 +1,9 @@
1
+ export interface FloatingLabelProps {
2
+ controlHtml: string;
3
+ label: string;
4
+ htmlFor?: string;
5
+ className?: string;
6
+ attributes?: Record<string, unknown>;
7
+ }
8
+ export declare function FloatingLabel(props: FloatingLabelProps): string;
9
+ export declare const floatingLabel: typeof FloatingLabel;
@@ -0,0 +1,14 @@
1
+ import { classNames, escapeHtml, toAttributes } from "../utils";
2
+ export function FloatingLabel(props) {
3
+ const { controlHtml, label, htmlFor, className = "", attributes } = props;
4
+ const classes = classNames("form-floating", className);
5
+ const baseAttrs = toAttributes(attributes);
6
+ const forAttr = htmlFor ? ` for="${escapeHtml(htmlFor)}"` : "";
7
+ return `
8
+ <div class="${classes}"${baseAttrs}>
9
+ ${controlHtml}
10
+ <label${forAttr}>${escapeHtml(label)}</label>
11
+ </div>
12
+ `.trim();
13
+ }
14
+ export const floatingLabel = FloatingLabel;
@@ -0,0 +1,30 @@
1
+ export interface FormLabelProps {
2
+ label: string;
3
+ htmlFor?: string;
4
+ required?: boolean;
5
+ className?: string;
6
+ attributes?: Record<string, unknown>;
7
+ }
8
+ export declare function FormLabel(props: FormLabelProps): string;
9
+ export declare const formLabel: typeof FormLabel;
10
+ export interface FormTextProps {
11
+ text: string;
12
+ id?: string;
13
+ className?: string;
14
+ }
15
+ export declare function FormText(props: FormTextProps): string;
16
+ export declare const formText: typeof FormText;
17
+ export interface FormFeedbackProps {
18
+ message: string;
19
+ type?: "invalid" | "valid";
20
+ tooltip?: boolean;
21
+ className?: string;
22
+ }
23
+ export declare function FormFeedback(props: FormFeedbackProps): string;
24
+ export declare const formFeedback: typeof FormFeedback;
25
+ export interface FormGroupProps {
26
+ children?: string;
27
+ className?: string;
28
+ }
29
+ export declare function FormGroup(props?: FormGroupProps): string;
30
+ export declare const formGroup: typeof FormGroup;
@@ -0,0 +1,28 @@
1
+ import { classNames, escapeHtml, toAttributes } from "../utils";
2
+ export function FormLabel(props) {
3
+ const { label, htmlFor, required = false, className = "", attributes } = props;
4
+ const baseAttrs = toAttributes({
5
+ for: htmlFor,
6
+ ...attributes
7
+ });
8
+ const reqIndicator = required ? '<span class="text-danger ms-1" aria-hidden="true">*</span>' : "";
9
+ return `<label class="${classNames("form-label", className)}"${baseAttrs}>${escapeHtml(label)}${reqIndicator}</label>`.trim();
10
+ }
11
+ export const formLabel = FormLabel;
12
+ export function FormText(props) {
13
+ const { text, id, className = "" } = props;
14
+ const idAttr = id ? ` id="${escapeHtml(id)}"` : "";
15
+ return `<div class="${classNames("form-text", className)}"${idAttr}>${escapeHtml(text)}</div>`.trim();
16
+ }
17
+ export const formText = FormText;
18
+ export function FormFeedback(props) {
19
+ const { message, type = "invalid", tooltip = false, className = "" } = props;
20
+ const feedbackClass = tooltip ? `${type}-tooltip` : `${type}-feedback`;
21
+ return `<div class="${classNames(feedbackClass, className)}">${escapeHtml(message)}</div>`.trim();
22
+ }
23
+ export const formFeedback = FormFeedback;
24
+ export function FormGroup(props = {}) {
25
+ const { children = "", className = "" } = props;
26
+ return `<div class="${classNames("form-group", className)}">${children}</div>`.trim();
27
+ }
28
+ export const formGroup = FormGroup;
@@ -0,0 +1,11 @@
1
+ export * from "./input";
2
+ export * from "./textarea";
3
+ export * from "./select";
4
+ export * from "./checkbox";
5
+ export * from "./radio";
6
+ export * from "./switch";
7
+ export * from "./range";
8
+ export * from "./input-group";
9
+ export * from "./form-control";
10
+ export * from "./floating-label";
11
+ export * from "./layout";
@@ -0,0 +1,11 @@
1
+ export * from "./input";
2
+ export * from "./textarea";
3
+ export * from "./select";
4
+ export * from "./checkbox";
5
+ export * from "./radio";
6
+ export * from "./switch";
7
+ export * from "./range";
8
+ export * from "./input-group";
9
+ export * from "./form-control";
10
+ export * from "./floating-label";
11
+ export * from "./layout";
@@ -0,0 +1,16 @@
1
+ export interface InputGroupProps {
2
+ children?: string;
3
+ size?: "sm" | "lg";
4
+ className?: string;
5
+ attributes?: Record<string, unknown>;
6
+ }
7
+ export declare function InputGroup(props?: InputGroupProps): string;
8
+ export declare const inputGroup: typeof InputGroup;
9
+ export interface InputGroupTextProps {
10
+ children?: string;
11
+ as?: "span" | "label";
12
+ htmlFor?: string;
13
+ className?: string;
14
+ }
15
+ export declare function InputGroupText(props?: InputGroupTextProps): string;
16
+ export declare const inputGroupText: typeof InputGroupText;
@@ -0,0 +1,14 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function InputGroup(props = {}) {
3
+ const { children = "", size, className = "", attributes } = props;
4
+ const classes = classNames("input-group", size === "sm" && "input-group-sm", size === "lg" && "input-group-lg", className);
5
+ const baseAttrs = toAttributes(attributes);
6
+ return `<div class="${classes}"${baseAttrs}>${children}</div>`.trim();
7
+ }
8
+ export const inputGroup = InputGroup;
9
+ export function InputGroupText(props = {}) {
10
+ const { children = "", as: Tag = "span", htmlFor, className = "" } = props;
11
+ const forAttr = htmlFor && Tag === "label" ? ` for="${htmlFor}"` : "";
12
+ return `<${Tag} class="${classNames("input-group-text", className)}"${forAttr}>${children}</${Tag}>`.trim();
13
+ }
14
+ export const inputGroupText = InputGroupText;
@@ -0,0 +1,18 @@
1
+ export type InputType = "text" | "password" | "email" | "number" | "search" | "tel" | "url" | "date" | "datetime-local" | "time" | "month" | "week" | "color" | "file" | "hidden";
2
+ export interface InputProps {
3
+ type?: InputType;
4
+ name?: string;
5
+ id?: string;
6
+ value?: string | number;
7
+ placeholder?: string;
8
+ disabled?: boolean;
9
+ readOnly?: boolean;
10
+ required?: boolean;
11
+ size?: "sm" | "lg";
12
+ isInvalid?: boolean;
13
+ isValid?: boolean;
14
+ className?: string;
15
+ attributes?: Record<string, unknown>;
16
+ }
17
+ export declare function Input(props?: InputProps): string;
18
+ export declare const input: typeof Input;
@@ -0,0 +1,19 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function Input(props = {}) {
3
+ const { type = "text", name, id, value, placeholder, disabled = false, readOnly = false, required = false, size, isInvalid = false, isValid = false, className = "", attributes } = props;
4
+ const controlClass = type === "color" ? "form-control form-control-color" : "form-control";
5
+ const classes = classNames(controlClass, size === "sm" && "form-control-sm", size === "lg" && "form-control-lg", isInvalid && "is-invalid", isValid && "is-valid", className);
6
+ const baseAttrs = toAttributes({
7
+ type,
8
+ name,
9
+ id,
10
+ value,
11
+ placeholder,
12
+ disabled,
13
+ readonly: readOnly,
14
+ required,
15
+ ...attributes
16
+ });
17
+ return `<input class="${classes}"${baseAttrs} />`.trim();
18
+ }
19
+ export const input = Input;
@@ -0,0 +1,20 @@
1
+ export interface FormRowProps {
2
+ children?: string;
3
+ gutter?: 1 | 2 | 3 | 4 | 5;
4
+ className?: string;
5
+ attributes?: Record<string, unknown>;
6
+ }
7
+ export declare function FormRow(props?: FormRowProps): string;
8
+ export declare const formRow: typeof FormRow;
9
+ export interface FormColProps {
10
+ children?: string;
11
+ size?: number | "auto";
12
+ sm?: number | "auto";
13
+ md?: number | "auto";
14
+ lg?: number | "auto";
15
+ xl?: number | "auto";
16
+ className?: string;
17
+ attributes?: Record<string, unknown>;
18
+ }
19
+ export declare function FormCol(props?: FormColProps): string;
20
+ export declare const formCol: typeof FormCol;
@@ -0,0 +1,15 @@
1
+ import { classNames, toAttributes } from "../utils";
2
+ export function FormRow(props = {}) {
3
+ const { children = "", gutter = 3, className = "", attributes } = props;
4
+ const classes = classNames("row", `g-${gutter}`, className);
5
+ const baseAttrs = toAttributes(attributes);
6
+ return `<div class="${classes}"${baseAttrs}>${children}</div>`.trim();
7
+ }
8
+ export const formRow = FormRow;
9
+ export function FormCol(props = {}) {
10
+ const { children = "", size, sm, md, lg, xl, className = "", attributes } = props;
11
+ const classes = classNames(size !== undefined ? (size === "auto" ? "col-auto" : `col-${size}`) : "col", sm !== undefined && (sm === "auto" ? "col-sm-auto" : `col-sm-${sm}`), md !== undefined && (md === "auto" ? "col-md-auto" : `col-md-${md}`), lg !== undefined && (lg === "auto" ? "col-lg-auto" : `col-lg-${lg}`), xl !== undefined && (xl === "auto" ? "col-xl-auto" : `col-xl-${xl}`), className);
12
+ const baseAttrs = toAttributes(attributes);
13
+ return `<div class="${classes}"${baseAttrs}>${children}</div>`.trim();
14
+ }
15
+ export const formCol = FormCol;
@@ -0,0 +1,32 @@
1
+ export interface RadioProps {
2
+ label?: string;
3
+ name: string;
4
+ id?: string;
5
+ value: string | number;
6
+ checked?: boolean;
7
+ disabled?: boolean;
8
+ inline?: boolean;
9
+ isInvalid?: boolean;
10
+ isValid?: boolean;
11
+ className?: string;
12
+ inputClassName?: string;
13
+ labelClassName?: string;
14
+ attributes?: Record<string, unknown>;
15
+ }
16
+ export declare function Radio(props: RadioProps): string;
17
+ export declare const radio: typeof Radio;
18
+ export interface RadioOption {
19
+ label: string;
20
+ value: string | number;
21
+ id?: string;
22
+ disabled?: boolean;
23
+ }
24
+ export interface RadioGroupProps {
25
+ name: string;
26
+ options: RadioOption[];
27
+ value?: string | number;
28
+ inline?: boolean;
29
+ className?: string;
30
+ }
31
+ export declare function RadioGroup(props: RadioGroupProps): string;
32
+ export declare const radioGroup: typeof RadioGroup;