@abydahana/aksara-ui 1.1.4 → 1.1.6

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.
@@ -1,6 +1,7 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export interface ButtonGroupProps {
2
3
  children?: string;
3
- size?: "sm" | "lg";
4
+ size?: ComponentSize;
4
5
  vertical?: boolean;
5
6
  ariaLabel?: string;
6
7
  className?: string;
@@ -1,7 +1,8 @@
1
1
  import { classNames, toAttributes } from "../utils";
2
2
  export function ButtonGroup(props = {}) {
3
3
  const { children = "", size, vertical = false, ariaLabel = "Button group", className = "", attributes } = props;
4
- const classes = classNames(vertical ? "btn-group-vertical" : "btn-group", size === "sm" && "btn-group-sm", size === "lg" && "btn-group-lg", className);
4
+ const sizeClass = size ? `btn-group-${size}` : "";
5
+ const classes = classNames(vertical ? "btn-group-vertical" : "btn-group", sizeClass, className);
5
6
  const baseAttrs = toAttributes({
6
7
  role: "group",
7
8
  "aria-label": ariaLabel,
@@ -1,3 +1,4 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export type ButtonVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light" | "link";
2
3
  export interface ButtonProps {
3
4
  label?: string;
@@ -7,7 +8,7 @@ export interface ButtonProps {
7
8
  outline?: boolean;
8
9
  soft?: boolean;
9
10
  ghost?: boolean;
10
- size?: "sm" | "lg";
11
+ size?: ComponentSize;
11
12
  pill?: boolean;
12
13
  disabled?: boolean;
13
14
  href?: string;
@@ -11,7 +11,8 @@ export function Button(props = {}) {
11
11
  else if (soft) {
12
12
  variantClass = `btn-soft-${variant}`;
13
13
  }
14
- const classes = classNames("btn", variantClass, size === "sm" && "btn-sm", size === "lg" && "btn-lg", pill && "rounded-pill", disabled && "disabled", className);
14
+ const sizeClass = size ? `btn-${size}` : "";
15
+ const classes = classNames("btn", variantClass, sizeClass, pill && "rounded-pill", disabled && "disabled", className);
15
16
  const isLink = Boolean(href);
16
17
  const Tag = isLink ? "a" : "button";
17
18
  const baseAttrs = toAttributes({
@@ -1,4 +1,6 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export interface CloseButtonProps {
3
+ size?: ComponentSize;
2
4
  white?: boolean;
3
5
  disabled?: boolean;
4
6
  ariaLabel?: string;
@@ -1,7 +1,8 @@
1
1
  import { classNames, toAttributes } from "../utils";
2
2
  export function CloseButton(props = {}) {
3
- const { white = false, disabled = false, ariaLabel = "Close", className = "", attributes } = props;
4
- const classes = classNames("btn-close", white && "btn-close-white", className);
3
+ const { size, white = false, disabled = false, ariaLabel = "Close", className = "", attributes } = props;
4
+ const sizeClass = size ? `btn-close-${size}` : "";
5
+ const classes = classNames("btn-close", sizeClass, white && "btn-close-white", className);
5
6
  const baseAttrs = toAttributes({
6
7
  type: "button",
7
8
  "aria-label": ariaLabel,
@@ -47,7 +47,7 @@ export function Avatar(props = {}) {
47
47
  else if (status === "away")
48
48
  statusVariant = "bg-warning";
49
49
  const statusKey = typeof status === "string" ? status : "online";
50
- statusHtml = `<span class="avatar-status position-absolute rounded-full ${statusVariant} border-2 border-body" data-status="${statusKey}" aria-hidden="true"></span>`;
50
+ statusHtml = `<span class="avatar-status position-absolute rounded-full ${statusVariant} border-2" data-status="${statusKey}" aria-hidden="true"></span>`;
51
51
  }
52
52
  return `
53
53
  <span class="${classes}"${baseAttrs}>
@@ -71,7 +71,7 @@ export function AvatarGroup(props = {}) {
71
71
  const renderedAvatars = displayed.map((item) => Avatar({ ...item, size: item.size ?? size })).join("\n");
72
72
  const extraPill = extraCount > 0
73
73
  ? `
74
- <span class="avatar avatar-${size} rounded-full bg-subtle text-subtle text-xs font-bold inline-flex items-center justify-center border-2 border-body">
74
+ <span class="avatar avatar-${size} rounded-full bg-subtle text-subtle text-xs font-bold inline-flex items-center justify-center border-2">
75
75
  +${extraCount}
76
76
  </span>
77
77
  `.trim()
@@ -2,7 +2,7 @@ import { classNames, escapeHtml, toAttributes } from "../utils";
2
2
  import { Avatar } from "./avatar";
3
3
  export function UserItem(props) {
4
4
  const { avatar, initials, avatarVariant, name, handle, subtitle, verified = false, status, href, action, className = "", attributes } = props;
5
- const containerClasses = classNames("user-item d-flex align-items-center justify-content-between p-3 border-bottom border-subtle", className);
5
+ const containerClasses = classNames("user-item d-flex align-items-center justify-content-between px-3 py-2 border-bottom border-subtle", className);
6
6
  const avatarHtml = Avatar({
7
7
  src: avatar,
8
8
  initials,
@@ -1,8 +1,10 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export type BadgeVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
2
3
  export interface BadgeProps {
3
4
  label?: string;
4
5
  children?: string;
5
6
  variant?: BadgeVariant;
7
+ size?: ComponentSize;
6
8
  soft?: boolean;
7
9
  pill?: boolean;
8
10
  dot?: boolean;
@@ -1,8 +1,9 @@
1
1
  import { classNames, escapeHtml, toAttributes } from "../utils";
2
2
  export function Badge(props = {}) {
3
- const { label, children, variant = "primary", soft = false, pill = false, dot = false, className = "", attributes } = props;
3
+ const { label, children, variant = "primary", size, soft = false, pill = false, dot = false, className = "", attributes } = props;
4
4
  const prefix = soft ? "badge-soft" : "badge";
5
- const classes = classNames("badge", `${prefix}-${variant}`, pill && "rounded-pill", dot && `badge-dot text-${variant}`, className);
5
+ const sizeClass = size ? `badge-${size}` : "";
6
+ const classes = classNames("badge", `${prefix}-${variant}`, sizeClass, pill && "rounded-pill", dot && `badge-dot text-${variant}`, className);
6
7
  const baseAttrs = toAttributes(attributes);
7
8
  const content = children !== undefined ? children : label !== undefined ? escapeHtml(label) : "";
8
9
  return `<span class="${classes}"${baseAttrs}>${content}</span>`.trim();
@@ -1,5 +1,6 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export interface SpinnerProps {
2
- size?: "sm" | "md";
3
+ size?: ComponentSize;
3
4
  variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
4
5
  label?: string;
5
6
  className?: string;
@@ -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 classes = classNames("spinner", size === "sm" && "spinner-sm", variant && `text-${variant}`, className);
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,
@@ -1,3 +1,4 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export interface DropdownSelectOption {
2
3
  value: string;
3
4
  label: string;
@@ -10,7 +11,7 @@ export interface DropdownSelectProps {
10
11
  defaultValue?: string;
11
12
  className?: string;
12
13
  btnClassName?: string;
13
- size?: "sm" | "md" | "lg";
14
+ size?: ComponentSize;
14
15
  variant?: "chip" | "form-select";
15
16
  attributes?: Record<string, unknown>;
16
17
  }
@@ -6,10 +6,10 @@ export function DropdownSelect(props) {
6
6
  const { name, options = [], defaultValue, className = "", btnClassName = "", size = props.variant === "form-select" ? "md" : "sm", variant = "chip", attributes } = props;
7
7
  const selectedOption = options.find((opt) => opt.value === defaultValue) ?? options[0];
8
8
  const isFormSelect = variant === "form-select";
9
- const dropdownSizeClass = size === "sm" ? "dropdown-sm" : size === "lg" ? "dropdown-lg" : "dropdown-md";
10
- const menuSizeClass = size === "sm" ? "dropdown-menu-sm" : size === "lg" ? "dropdown-menu-lg" : "";
11
- const selectSizeClass = size === "sm" ? "form-select-sm" : size === "lg" ? "form-select-lg" : "";
12
- const chipSizeClass = size === "sm" ? "chip-sm" : size === "lg" ? "chip-lg" : "chip-md";
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
13
  const hiddenInput = Input({
14
14
  type: "hidden",
15
15
  name,
@@ -1,6 +1,7 @@
1
+ import { type ComponentSize } from "../utils";
1
2
  export interface InputGroupProps {
2
3
  children?: string;
3
- size?: "sm" | "lg";
4
+ size?: ComponentSize;
4
5
  className?: string;
5
6
  attributes?: Record<string, unknown>;
6
7
  }
@@ -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 classes = classNames("input-group", size === "sm" && "input-group-sm", size === "lg" && "input-group-lg", className);
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?: "sm" | "lg";
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 classes = classNames(controlClass, size === "sm" && "form-control-sm", size === "lg" && "form-control-lg", isInvalid && "is-invalid", isValid && "is-valid", className);
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?: "sm" | "lg";
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 classes = classNames("form-select", size === "sm" && "form-select-sm", size === "lg" && "form-select-lg", isInvalid && "is-invalid", isValid && "is-valid", className);
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 classes = classNames("form-control", isAutoGrow && "form-control-autogrow", isInvalid && "is-invalid", isValid && "is-valid", className);
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?: "sm" | "lg";
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 classes = classNames("pagination", size === "sm" && "pagination-sm", size === "lg" && "pagination-lg", className);
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) => {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abydahana/aksara-ui",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },