@astralui/core 0.1.6 → 0.1.8
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/README.md +5 -1
- package/dist/index.cjs +77 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +78 -3
- package/dist/index.js.map +1 -1
- package/dist/styles.css +34 -0
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -274,4 +274,33 @@ interface StatusBadgeProps {
|
|
|
274
274
|
}
|
|
275
275
|
declare function StatusBadge({ status, label, color, filled }: StatusBadgeProps): react.JSX.Element;
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
interface SearchInputProps {
|
|
278
|
+
value: string;
|
|
279
|
+
onChange: (value: string) => void;
|
|
280
|
+
placeholder?: string;
|
|
281
|
+
/** runs when the clear button is pressed (defaults to onChange('')) */
|
|
282
|
+
onClear?: () => void;
|
|
283
|
+
autoFocus?: boolean;
|
|
284
|
+
disabled?: boolean;
|
|
285
|
+
className?: string;
|
|
286
|
+
style?: CSSProperties;
|
|
287
|
+
'aria-label'?: string;
|
|
288
|
+
}
|
|
289
|
+
declare function SearchInput({ value, onChange, placeholder, onClear, autoFocus, disabled, className, style, 'aria-label': ariaLabel, }: SearchInputProps): react.JSX.Element;
|
|
290
|
+
|
|
291
|
+
interface CollapsibleProps {
|
|
292
|
+
/** Header content - clicking it toggles the region. */
|
|
293
|
+
title: ReactNode;
|
|
294
|
+
children: ReactNode;
|
|
295
|
+
/** Uncontrolled initial state (ignored when `open` is provided). */
|
|
296
|
+
defaultOpen?: boolean;
|
|
297
|
+
/** Controlled open state. Pair with `onOpenChange`. */
|
|
298
|
+
open?: boolean;
|
|
299
|
+
onOpenChange?: (open: boolean) => void;
|
|
300
|
+
disabled?: boolean;
|
|
301
|
+
className?: string;
|
|
302
|
+
style?: CSSProperties;
|
|
303
|
+
}
|
|
304
|
+
declare function Collapsible({ title, children, defaultOpen, open: controlledOpen, onOpenChange, disabled, className, style, }: CollapsibleProps): react.JSX.Element;
|
|
305
|
+
|
|
306
|
+
export { AstralDrawer, AstralMenu, type AstralMenuItem, AstralModal, AstralPinInput, AstralSelect, type AstralSelectOption, type AstralThemeColors, AstralThemeProvider, AstralToaster, AuthCard, AuthShell, Avatar, type AvatarProps, Collapsible, type CollapsibleProps, type ColorScheme, ColorSchemeProvider, ConfirmModal, type ConfirmModalProps, DateInput, Delta, Donut, type DonutDatum, FunnelBars, type FunnelDatum, GridBackground, SearchInput, type SearchInputProps, SpaceBackground, Sparkline, Spinner, StackedBars, type StackedRow, type StackedSeries, StatusBadge, type StatusBadgeProps, type ToastOptions, buildOrgCss, chartColor, dateTimeToInputStr, dateToInputStr, generateColors, notifications, useColorScheme, useThemePreview };
|
package/dist/index.d.ts
CHANGED
|
@@ -274,4 +274,33 @@ interface StatusBadgeProps {
|
|
|
274
274
|
}
|
|
275
275
|
declare function StatusBadge({ status, label, color, filled }: StatusBadgeProps): react.JSX.Element;
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
interface SearchInputProps {
|
|
278
|
+
value: string;
|
|
279
|
+
onChange: (value: string) => void;
|
|
280
|
+
placeholder?: string;
|
|
281
|
+
/** runs when the clear button is pressed (defaults to onChange('')) */
|
|
282
|
+
onClear?: () => void;
|
|
283
|
+
autoFocus?: boolean;
|
|
284
|
+
disabled?: boolean;
|
|
285
|
+
className?: string;
|
|
286
|
+
style?: CSSProperties;
|
|
287
|
+
'aria-label'?: string;
|
|
288
|
+
}
|
|
289
|
+
declare function SearchInput({ value, onChange, placeholder, onClear, autoFocus, disabled, className, style, 'aria-label': ariaLabel, }: SearchInputProps): react.JSX.Element;
|
|
290
|
+
|
|
291
|
+
interface CollapsibleProps {
|
|
292
|
+
/** Header content - clicking it toggles the region. */
|
|
293
|
+
title: ReactNode;
|
|
294
|
+
children: ReactNode;
|
|
295
|
+
/** Uncontrolled initial state (ignored when `open` is provided). */
|
|
296
|
+
defaultOpen?: boolean;
|
|
297
|
+
/** Controlled open state. Pair with `onOpenChange`. */
|
|
298
|
+
open?: boolean;
|
|
299
|
+
onOpenChange?: (open: boolean) => void;
|
|
300
|
+
disabled?: boolean;
|
|
301
|
+
className?: string;
|
|
302
|
+
style?: CSSProperties;
|
|
303
|
+
}
|
|
304
|
+
declare function Collapsible({ title, children, defaultOpen, open: controlledOpen, onOpenChange, disabled, className, style, }: CollapsibleProps): react.JSX.Element;
|
|
305
|
+
|
|
306
|
+
export { AstralDrawer, AstralMenu, type AstralMenuItem, AstralModal, AstralPinInput, AstralSelect, type AstralSelectOption, type AstralThemeColors, AstralThemeProvider, AstralToaster, AuthCard, AuthShell, Avatar, type AvatarProps, Collapsible, type CollapsibleProps, type ColorScheme, ColorSchemeProvider, ConfirmModal, type ConfirmModalProps, DateInput, Delta, Donut, type DonutDatum, FunnelBars, type FunnelDatum, GridBackground, SearchInput, type SearchInputProps, SpaceBackground, Sparkline, Spinner, StackedBars, type StackedRow, type StackedSeries, StatusBadge, type StatusBadgeProps, type ToastOptions, buildOrgCss, chartColor, dateTimeToInputStr, dateToInputStr, generateColors, notifications, useColorScheme, useThemePreview };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createContext, useState, useEffect, useCallback, useContext, useMemo, useRef, useSyncExternalStore } from 'react';
|
|
1
|
+
import { createContext, useState, useEffect, useCallback, useContext, useMemo, useRef, useSyncExternalStore, useLayoutEffect } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import chroma from 'chroma-js';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
|
-
import { IconX, IconChevronDown, IconInfoCircle, IconAlertTriangle, IconExclamationCircle, IconCheck } from '@tabler/icons-react';
|
|
5
|
+
import { IconX, IconChevronDown, IconSearch, IconInfoCircle, IconAlertTriangle, IconExclamationCircle, IconCheck } from '@tabler/icons-react';
|
|
6
6
|
|
|
7
7
|
// src/theme/ColorSchemeProvider.tsx
|
|
8
8
|
var ColorSchemeContext = createContext({
|
|
@@ -913,7 +913,82 @@ function StatusBadge({ status, label, color, filled }) {
|
|
|
913
913
|
}
|
|
914
914
|
);
|
|
915
915
|
}
|
|
916
|
+
function SearchInput({
|
|
917
|
+
value,
|
|
918
|
+
onChange,
|
|
919
|
+
placeholder,
|
|
920
|
+
onClear,
|
|
921
|
+
autoFocus,
|
|
922
|
+
disabled,
|
|
923
|
+
className,
|
|
924
|
+
style,
|
|
925
|
+
"aria-label": ariaLabel
|
|
926
|
+
}) {
|
|
927
|
+
return /* @__PURE__ */ jsxs("div", { className: `au-search${className ? " " + className : ""}`, style, children: [
|
|
928
|
+
/* @__PURE__ */ jsx(IconSearch, { size: 15 }),
|
|
929
|
+
/* @__PURE__ */ jsx(
|
|
930
|
+
"input",
|
|
931
|
+
{
|
|
932
|
+
value,
|
|
933
|
+
onChange: (e) => onChange(e.currentTarget.value),
|
|
934
|
+
placeholder,
|
|
935
|
+
"aria-label": ariaLabel ?? placeholder ?? "Search",
|
|
936
|
+
autoFocus,
|
|
937
|
+
disabled
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
value && !disabled && /* @__PURE__ */ jsx(
|
|
941
|
+
"button",
|
|
942
|
+
{
|
|
943
|
+
type: "button",
|
|
944
|
+
className: "clr",
|
|
945
|
+
onClick: () => onClear ? onClear() : onChange(""),
|
|
946
|
+
"aria-label": "Clear search",
|
|
947
|
+
children: /* @__PURE__ */ jsx(IconX, { size: 13 })
|
|
948
|
+
}
|
|
949
|
+
)
|
|
950
|
+
] });
|
|
951
|
+
}
|
|
952
|
+
function Collapsible({
|
|
953
|
+
title,
|
|
954
|
+
children,
|
|
955
|
+
defaultOpen = false,
|
|
956
|
+
open: controlledOpen,
|
|
957
|
+
onOpenChange,
|
|
958
|
+
disabled,
|
|
959
|
+
className,
|
|
960
|
+
style
|
|
961
|
+
}) {
|
|
962
|
+
const isControlled = controlledOpen !== void 0;
|
|
963
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
964
|
+
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
965
|
+
const innerRef = useRef(null);
|
|
966
|
+
const [maxH, setMaxH] = useState(0);
|
|
967
|
+
useLayoutEffect(() => {
|
|
968
|
+
const el = innerRef.current;
|
|
969
|
+
if (!el) return;
|
|
970
|
+
const sync = () => setMaxH(open ? el.scrollHeight : 0);
|
|
971
|
+
sync();
|
|
972
|
+
if (!open) return;
|
|
973
|
+
const ro = new ResizeObserver(sync);
|
|
974
|
+
ro.observe(el);
|
|
975
|
+
return () => ro.disconnect();
|
|
976
|
+
}, [open, children]);
|
|
977
|
+
const toggle = useCallback(() => {
|
|
978
|
+
if (disabled) return;
|
|
979
|
+
const next = !open;
|
|
980
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
981
|
+
onOpenChange?.(next);
|
|
982
|
+
}, [disabled, open, isControlled, onOpenChange]);
|
|
983
|
+
return /* @__PURE__ */ jsxs("div", { className: `au-collapse${open ? " au-collapse--open" : ""}${className ? " " + className : ""}`, style, children: [
|
|
984
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "au-collapse-head", "aria-expanded": open, disabled, onClick: toggle, children: [
|
|
985
|
+
/* @__PURE__ */ jsx("span", { className: "au-collapse-title", children: title }),
|
|
986
|
+
/* @__PURE__ */ jsx(IconChevronDown, { size: 16, className: "au-collapse-chev", "aria-hidden": true })
|
|
987
|
+
] }),
|
|
988
|
+
/* @__PURE__ */ jsx("div", { className: "au-collapse-region", style: { maxHeight: open ? maxH : 0 }, children: /* @__PURE__ */ jsx("div", { className: "au-collapse-inner", ref: innerRef, children }) })
|
|
989
|
+
] });
|
|
990
|
+
}
|
|
916
991
|
|
|
917
|
-
export { AstralDrawer, AstralMenu, AstralModal, AstralPinInput, AstralSelect, AstralThemeProvider, AstralToaster, AuthCard, AuthShell, Avatar, ColorSchemeProvider, ConfirmModal, DateInput, Delta, Donut, FunnelBars, GridBackground, SpaceBackground, Sparkline, Spinner2 as Spinner, StackedBars, StatusBadge, buildOrgCss, chartColor, dateTimeToInputStr, dateToInputStr, generateColors, notifications, useColorScheme, useThemePreview };
|
|
992
|
+
export { AstralDrawer, AstralMenu, AstralModal, AstralPinInput, AstralSelect, AstralThemeProvider, AstralToaster, AuthCard, AuthShell, Avatar, Collapsible, ColorSchemeProvider, ConfirmModal, DateInput, Delta, Donut, FunnelBars, GridBackground, SearchInput, SpaceBackground, Sparkline, Spinner2 as Spinner, StackedBars, StatusBadge, buildOrgCss, chartColor, dateTimeToInputStr, dateToInputStr, generateColors, notifications, useColorScheme, useThemePreview };
|
|
918
993
|
//# sourceMappingURL=index.js.map
|
|
919
994
|
//# sourceMappingURL=index.js.map
|