@jbpark/ui-kit 10.3.0 → 10.4.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.
- package/README.ko.md +97 -76
- package/README.md +91 -70
- package/dist/AutoComplete.mjs +1 -1
- package/dist/Breadcrumb.mjs +1 -1
- package/dist/Cascader.mjs +2 -2
- package/dist/Checkbox.d.mts +10 -0
- package/dist/Checkbox.d.mts.map +1 -0
- package/dist/Checkbox.mjs +9 -0
- package/dist/Checkbox.mjs.map +1 -0
- package/dist/CodeEditor.d.mts +8 -2
- package/dist/CodeEditor.d.mts.map +1 -1
- package/dist/CodeEditor.mjs +9 -4
- package/dist/CodeEditor.mjs.map +1 -1
- package/dist/{components/molecules/collapse.d.mts → Collapse.d.mts} +1 -1
- package/dist/Collapse.d.mts.map +1 -0
- package/dist/{components/molecules/collapse.mjs → Collapse.mjs} +3 -3
- package/dist/Collapse.mjs.map +1 -0
- package/dist/{components/atoms/color-picker.d.mts → ColorPicker.d.mts} +1 -1
- package/dist/ColorPicker.d.mts.map +1 -0
- package/dist/{components/atoms/color-picker.mjs → ColorPicker.mjs} +3 -3
- package/dist/ColorPicker.mjs.map +1 -0
- package/dist/{components/templates/container.d.mts → Container.d.mts} +1 -1
- package/dist/Container.d.mts.map +1 -0
- package/dist/{components/templates/container.mjs → Container.mjs} +2 -2
- package/dist/Container.mjs.map +1 -0
- package/dist/{components/atoms/date-picker.d.mts → DatePicker.d.mts} +1 -1
- package/dist/DatePicker.d.mts.map +1 -0
- package/dist/{components/atoms/date-picker.mjs → DatePicker.mjs} +6 -6
- package/dist/DatePicker.mjs.map +1 -0
- package/dist/{components/organisms/drawer.d.mts → Drawer.d.mts} +1 -1
- package/dist/Drawer.d.mts.map +1 -0
- package/dist/{components/organisms/drawer.mjs → Drawer.mjs} +5 -5
- package/dist/Drawer.mjs.map +1 -0
- package/dist/{components/molecules/dropdown.d.mts → Dropdown.d.mts} +2 -2
- package/dist/Dropdown.d.mts.map +1 -0
- package/dist/{components/molecules/dropdown.mjs → Dropdown.mjs} +4 -4
- package/dist/Dropdown.mjs.map +1 -0
- package/dist/{components/templates/empty.d.mts → Empty.d.mts} +2 -2
- package/dist/Empty.d.mts.map +1 -0
- package/dist/{components/templates/empty.mjs → Empty.mjs} +3 -3
- package/dist/Empty.mjs.map +1 -0
- package/dist/FloatButton.d.mts +10 -0
- package/dist/FloatButton.d.mts.map +1 -0
- package/dist/FloatButton.mjs +9 -0
- package/dist/FloatButton.mjs.map +1 -0
- package/dist/Input.d.mts +16 -0
- package/dist/Input.d.mts.map +1 -0
- package/dist/Input.mjs +15 -0
- package/dist/Input.mjs.map +1 -0
- package/dist/{components/organisms/list/index.d.mts → List.d.mts} +3 -3
- package/dist/List.d.mts.map +1 -0
- package/dist/List.mjs +9 -0
- package/dist/List.mjs.map +1 -0
- package/dist/Marquees.d.mts +10 -0
- package/dist/Marquees.d.mts.map +1 -0
- package/dist/Marquees.mjs +9 -0
- package/dist/Marquees.mjs.map +1 -0
- package/dist/Mentions.d.mts.map +1 -1
- package/dist/Mentions.mjs +8 -7
- package/dist/Mentions.mjs.map +1 -1
- package/dist/{components/organisms/modal.d.mts → Modal.d.mts} +1 -1
- package/dist/Modal.d.mts.map +1 -0
- package/dist/{components/organisms/modal.mjs → Modal.mjs} +6 -6
- package/dist/Modal.mjs.map +1 -0
- package/dist/{components/templates/page-header.d.mts → PageHeader.d.mts} +1 -1
- package/dist/PageHeader.d.mts.map +1 -0
- package/dist/{components/templates/page-header.mjs → PageHeader.mjs} +4 -4
- package/dist/PageHeader.mjs.map +1 -0
- package/dist/Pagination.mjs +2 -2
- package/dist/Popconfirm.d.mts +1 -1
- package/dist/Popconfirm.mjs +1 -1
- package/dist/{components/atoms/popover.d.mts → Popover.d.mts} +1 -1
- package/dist/Popover.d.mts.map +1 -0
- package/dist/{components/atoms/popover.mjs → Popover.mjs} +4 -4
- package/dist/Popover.mjs.map +1 -0
- package/dist/{components/atoms/progress.d.mts → Progress.d.mts} +1 -1
- package/dist/Progress.d.mts.map +1 -0
- package/dist/{components/atoms/progress.mjs → Progress.mjs} +3 -3
- package/dist/Progress.mjs.map +1 -0
- package/dist/Radio.d.mts +10 -0
- package/dist/Radio.d.mts.map +1 -0
- package/dist/Radio.mjs +9 -0
- package/dist/Radio.mjs.map +1 -0
- package/dist/{components/templates/result.d.mts → Result.d.mts} +1 -1
- package/dist/Result.d.mts.map +1 -0
- package/dist/{components/templates/result.mjs → Result.mjs} +2 -2
- package/dist/Result.mjs.map +1 -0
- package/dist/RichTextEditor.d.mts +3 -0
- package/dist/RichTextEditor.mjs +1 -0
- package/dist/{components/atoms/select.d.mts → Select.d.mts} +5 -5
- package/dist/Select.d.mts.map +1 -0
- package/dist/{components/atoms/select.mjs → Select.mjs} +5 -5
- package/dist/Select.mjs.map +1 -0
- package/dist/Skeleton.d.mts +12 -0
- package/dist/Skeleton.d.mts.map +1 -0
- package/dist/Skeleton.mjs +11 -0
- package/dist/Skeleton.mjs.map +1 -0
- package/dist/Slider.d.mts +2 -0
- package/dist/{components/atoms/slider/index.mjs → Slider.mjs} +2 -2
- package/dist/Slider.mjs.map +1 -0
- package/dist/Space.d.mts +3 -2
- package/dist/Space.d.mts.map +1 -1
- package/dist/Space.mjs +13 -4
- package/dist/Space.mjs.map +1 -1
- package/dist/{components/atoms/spin.d.mts → Spin.d.mts} +1 -1
- package/dist/Spin.d.mts.map +1 -0
- package/dist/{components/atoms/spin.mjs → Spin.mjs} +3 -3
- package/dist/Spin.mjs.map +1 -0
- package/dist/Splitter.d.mts +10 -0
- package/dist/Splitter.d.mts.map +1 -0
- package/dist/Splitter.mjs +9 -0
- package/dist/Splitter.mjs.map +1 -0
- package/dist/Statistic.mjs +1 -1
- package/dist/Swiper.d.mts +10 -0
- package/dist/Swiper.d.mts.map +1 -0
- package/dist/Swiper.mjs +9 -0
- package/dist/Swiper.mjs.map +1 -0
- package/dist/{components/atoms/switch.d.mts → Switch.d.mts} +2 -2
- package/dist/Switch.d.mts.map +1 -0
- package/dist/{components/atoms/switch.mjs → Switch.mjs} +4 -4
- package/dist/Switch.mjs.map +1 -0
- package/dist/Table.mjs +2 -2
- package/dist/Table.mjs.map +1 -1
- package/dist/{components/molecules/tabs.d.mts → Tabs.d.mts} +3 -3
- package/dist/Tabs.d.mts.map +1 -0
- package/dist/{components/molecules/tabs.mjs → Tabs.mjs} +3 -3
- package/dist/Tabs.mjs.map +1 -0
- package/dist/TimePicker.mjs +1 -1
- package/dist/{components/organisms/toast.d.mts → Toast.d.mts} +12 -2
- package/dist/Toast.d.mts.map +1 -0
- package/dist/Toast.mjs +198 -0
- package/dist/Toast.mjs.map +1 -0
- package/dist/ToggleGroup.d.mts +28 -0
- package/dist/ToggleGroup.d.mts.map +1 -0
- package/dist/ToggleGroup.mjs +58 -0
- package/dist/ToggleGroup.mjs.map +1 -0
- package/dist/{components/atoms/tooltip.d.mts → Tooltip.d.mts} +1 -1
- package/dist/Tooltip.d.mts.map +1 -0
- package/dist/{components/atoms/tooltip.mjs → Tooltip.mjs} +2 -2
- package/dist/Tooltip.mjs.map +1 -0
- package/dist/Tour.d.mts.map +1 -1
- package/dist/Tour.mjs +47 -64
- package/dist/Tour.mjs.map +1 -1
- package/dist/Transfer.mjs +2 -2
- package/dist/Tree.mjs +1 -1
- package/dist/{components/molecules/upload.d.mts → Upload.d.mts} +1 -1
- package/dist/Upload.d.mts.map +1 -0
- package/dist/{components/molecules/upload.mjs → Upload.mjs} +7 -7
- package/dist/Upload.mjs.map +1 -0
- package/dist/components/atoms/index.d.mts +34 -27
- package/dist/components/atoms/input/input.d.mts +2 -1
- package/dist/components/atoms/input/input.d.mts.map +1 -1
- package/dist/components/atoms/input/input.mjs.map +1 -1
- package/dist/components/atoms/rich-text-editor/toolbar-presets.mjs +4 -4
- package/dist/components/atoms/select-multiple.mjs +1 -1
- package/dist/components/atoms/select-searchable.mjs +1 -1
- package/dist/components/molecules/index.d.mts +22 -21
- package/dist/components/organisms/form/control.mjs +1 -1
- package/dist/components/organisms/imperative-stack.mjs +16 -1
- package/dist/components/organisms/imperative-stack.mjs.map +1 -1
- package/dist/components/organisms/index.d.mts +15 -15
- package/dist/components/organisms/list/list.d.mts +1 -1
- package/dist/components/organisms/list/list.mjs +1 -1
- package/dist/components/organisms/swiper/swiper.d.mts +6 -0
- package/dist/components/organisms/swiper/swiper.d.mts.map +1 -1
- package/dist/components/organisms/swiper/swiper.mjs +1 -1
- package/dist/components/templates/index.d.mts +11 -12
- package/dist/components/templates/layout/sider.d.mts.map +1 -1
- package/dist/components/templates/layout/sider.mjs +4 -6
- package/dist/components/templates/layout/sider.mjs.map +1 -1
- package/dist/core/badge.d.mts +1 -1
- package/dist/core/button.d.mts +2 -2
- package/dist/index.d.mts +81 -74
- package/dist/index.mjs +31 -30
- package/dist/style.css +21 -0
- package/package.json +157 -2
- package/dist/components/atoms/checkbox/index.d.mts +0 -10
- package/dist/components/atoms/checkbox/index.d.mts.map +0 -1
- package/dist/components/atoms/checkbox/index.mjs +0 -9
- package/dist/components/atoms/checkbox/index.mjs.map +0 -1
- package/dist/components/atoms/color-picker.d.mts.map +0 -1
- package/dist/components/atoms/color-picker.mjs.map +0 -1
- package/dist/components/atoms/date-picker.d.mts.map +0 -1
- package/dist/components/atoms/date-picker.mjs.map +0 -1
- package/dist/components/atoms/float-button/index.d.mts +0 -10
- package/dist/components/atoms/float-button/index.d.mts.map +0 -1
- package/dist/components/atoms/float-button/index.mjs +0 -9
- package/dist/components/atoms/float-button/index.mjs.map +0 -1
- package/dist/components/atoms/input/index.d.mts +0 -16
- package/dist/components/atoms/input/index.d.mts.map +0 -1
- package/dist/components/atoms/input/index.mjs +0 -15
- package/dist/components/atoms/input/index.mjs.map +0 -1
- package/dist/components/atoms/popover.d.mts.map +0 -1
- package/dist/components/atoms/popover.mjs.map +0 -1
- package/dist/components/atoms/progress.d.mts.map +0 -1
- package/dist/components/atoms/progress.mjs.map +0 -1
- package/dist/components/atoms/radio/index.d.mts +0 -10
- package/dist/components/atoms/radio/index.d.mts.map +0 -1
- package/dist/components/atoms/radio/index.mjs +0 -9
- package/dist/components/atoms/radio/index.mjs.map +0 -1
- package/dist/components/atoms/rich-text-editor/index.d.mts +0 -3
- package/dist/components/atoms/select.d.mts.map +0 -1
- package/dist/components/atoms/select.mjs.map +0 -1
- package/dist/components/atoms/skeleton/index.d.mts +0 -12
- package/dist/components/atoms/skeleton/index.d.mts.map +0 -1
- package/dist/components/atoms/skeleton/index.mjs +0 -11
- package/dist/components/atoms/skeleton/index.mjs.map +0 -1
- package/dist/components/atoms/slider/index.mjs.map +0 -1
- package/dist/components/atoms/spin.d.mts.map +0 -1
- package/dist/components/atoms/spin.mjs.map +0 -1
- package/dist/components/atoms/switch.d.mts.map +0 -1
- package/dist/components/atoms/switch.mjs.map +0 -1
- package/dist/components/atoms/tooltip.d.mts.map +0 -1
- package/dist/components/atoms/tooltip.mjs.map +0 -1
- package/dist/components/molecules/collapse.d.mts.map +0 -1
- package/dist/components/molecules/collapse.mjs.map +0 -1
- package/dist/components/molecules/dropdown.d.mts.map +0 -1
- package/dist/components/molecules/dropdown.mjs.map +0 -1
- package/dist/components/molecules/marquees/index.d.mts +0 -10
- package/dist/components/molecules/marquees/index.d.mts.map +0 -1
- package/dist/components/molecules/marquees/index.mjs +0 -9
- package/dist/components/molecules/marquees/index.mjs.map +0 -1
- package/dist/components/molecules/splitter/index.d.mts +0 -10
- package/dist/components/molecules/splitter/index.d.mts.map +0 -1
- package/dist/components/molecules/splitter/index.mjs +0 -9
- package/dist/components/molecules/splitter/index.mjs.map +0 -1
- package/dist/components/molecules/tabs.d.mts.map +0 -1
- package/dist/components/molecules/tabs.mjs.map +0 -1
- package/dist/components/molecules/upload.d.mts.map +0 -1
- package/dist/components/molecules/upload.mjs.map +0 -1
- package/dist/components/organisms/drawer.d.mts.map +0 -1
- package/dist/components/organisms/drawer.mjs.map +0 -1
- package/dist/components/organisms/list/index.d.mts.map +0 -1
- package/dist/components/organisms/list/index.mjs +0 -9
- package/dist/components/organisms/list/index.mjs.map +0 -1
- package/dist/components/organisms/modal.d.mts.map +0 -1
- package/dist/components/organisms/modal.mjs.map +0 -1
- package/dist/components/organisms/swiper/index.d.mts +0 -10
- package/dist/components/organisms/swiper/index.d.mts.map +0 -1
- package/dist/components/organisms/swiper/index.mjs +0 -9
- package/dist/components/organisms/swiper/index.mjs.map +0 -1
- package/dist/components/organisms/toast.d.mts.map +0 -1
- package/dist/components/organisms/toast.mjs +0 -126
- package/dist/components/organisms/toast.mjs.map +0 -1
- package/dist/components/templates/container.d.mts.map +0 -1
- package/dist/components/templates/container.mjs.map +0 -1
- package/dist/components/templates/empty.d.mts.map +0 -1
- package/dist/components/templates/empty.mjs.map +0 -1
- package/dist/components/templates/page-header.d.mts.map +0 -1
- package/dist/components/templates/page-header.mjs.map +0 -1
- package/dist/components/templates/result.d.mts.map +0 -1
- package/dist/components/templates/result.mjs.map +0 -1
package/dist/Mentions.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mentions.mjs","names":["autocomplete"],"sources":["../src/components/atoms/mentions.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ComponentPropsWithRef,\n type ReactNode,\n type Ref,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useControllableState, useMergedRef } from '@jbpark/use-hooks';\n\nimport { useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport { autocomplete } from '../../core';\nimport Input from './input';\nimport { findToken, insertToken } from './mentions-token';\n\nexport interface Option {\n /** Unique, non-empty token text without whitespace or the prefix. */\n value: string;\n label?: string;\n prefix?: string;\n disabled?: boolean;\n}\n\nexport interface Props extends Omit<\n ComponentPropsWithRef<'textarea'>,\n 'children' | 'value' | 'defaultValue' | 'onChange' | 'onSelect'\n> {\n options: readonly Option[];\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n onSelect?: (option: Option, prefix: string) => void;\n onSearch?: (query: string, prefix: string) => void;\n prefixes?: readonly string[];\n filterOption?: false | ((query: string, option: Option) => boolean);\n loading?: boolean;\n loadingText?: ReactNode;\n emptyText?: ReactNode;\n container?: HTMLElement;\n classNames?: {\n root?: string;\n content?: string;\n list?: string;\n option?: string;\n empty?: string;\n };\n}\n\nconst DEFAULT_PREFIXES = ['@'];\n\nfunction TextareaBridge({\n primitiveRef,\n ref,\n ...props\n}: ComponentPropsWithRef<'textarea'> & {\n primitiveRef?: Ref<HTMLTextAreaElement>;\n}) {\n const mergedRef = useMergedRef(primitiveRef, ref);\n\n return <Input.TextArea {...props} ref={mergedRef} />;\n}\n\nconst Mentions = ({\n options,\n value,\n defaultValue = '',\n onChange,\n onSelect,\n onSearch,\n prefixes = DEFAULT_PREFIXES,\n filterOption,\n loading = false,\n loadingText = 'Loading suggestions…',\n emptyText = 'No suggestions',\n container,\n disabled,\n readOnly,\n name,\n form,\n className,\n classNames,\n dir,\n ref,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onCompositionStart,\n onCompositionEnd,\n ...props\n}: Props) => {\n const { direction } = useConfig();\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const mergedRef = useMergedRef(ref, textareaRef);\n const composingRef = useRef(false);\n const pendingCaret = useRef<{ value: string; caret: number } | null>(null);\n const [text, setText] = useControllableState<string>({\n value,\n defaultValue,\n onChange,\n });\n const [focused, setFocused] = useState(false);\n const [composing, setComposing] = useState(false);\n const [selection, setSelection] = useState({ text: '', start: 0, end: 0 });\n const [dismissed, setDismissed] = useState<readonly (string | null)[]>([]);\n const token =\n focused && !composing && !disabled && !readOnly && selection.text === text\n ? findToken(text, selection.start, selection.end, prefixes)\n : null;\n const signature = token\n ? JSON.stringify([text, selection.start, selection.end, token.prefix])\n : null;\n const open = token !== null && !dismissed.includes(signature);\n const query = token?.query;\n const prefix = token?.prefix;\n const searchRef = useRef(onSearch);\n\n useEffect(() => {\n searchRef.current = onSearch;\n }, [onSearch]);\n\n useEffect(() => {\n if (query !== undefined && prefix !== undefined) {\n searchRef.current?.(query, prefix);\n }\n }, [query, prefix]);\n\n useEffect(() => {\n const pending = pendingCaret.current;\n const textarea = textareaRef.current;\n\n if (pending && textarea && text === pending.value) {\n pendingCaret.current = null;\n\n if (textarea.ownerDocument.activeElement === textarea) {\n textarea.setSelectionRange(pending.caret, pending.caret);\n }\n }\n });\n\n const syncSelection = (textarea: HTMLTextAreaElement) => {\n setSelection(previous => {\n const next = {\n text: textarea.value,\n start: textarea.selectionStart,\n end: textarea.selectionEnd,\n };\n\n return previous.text === next.text &&\n previous.start === next.start &&\n previous.end === next.end\n ? previous\n : next;\n });\n };\n const filtered = options.filter(option => {\n if (\n !option.value ||\n /\\s/u.test(option.value) ||\n prefixes.some(\n prefix => prefix.length > 0 && option.value.startsWith(prefix),\n ) ||\n (option.prefix !== undefined && option.prefix !== prefix)\n ) {\n return false;\n }\n\n if (filterOption === false) {\n return true;\n }\n\n return filterOption\n ? filterOption(query ?? '', option)\n : [option.value, option.label ?? ''].some(label =>\n label.toLowerCase().includes((query ?? '').toLowerCase()),\n );\n });\n const select = (option: Option) => {\n const textarea = textareaRef.current;\n\n if (\n !open ||\n !textarea ||\n composingRef.current ||\n option.disabled ||\n disabled ||\n readOnly ||\n textarea.value !== text\n ) {\n return;\n }\n\n const currentToken = findToken(\n text,\n textarea.selectionStart,\n textarea.selectionEnd,\n prefixes,\n );\n\n if (\n !currentToken ||\n currentToken.start !== token?.start ||\n currentToken.query !== token.query ||\n (currentToken.prefix !== option.prefix && option.prefix !== undefined)\n ) {\n return;\n }\n\n const next = insertToken(text, currentToken, option.value);\n\n pendingCaret.current = next;\n setDismissed([\n signature,\n JSON.stringify([next.value, next.caret, next.caret, currentToken.prefix]),\n ]);\n setText(next.value);\n onSelect?.(option, currentToken.prefix);\n };\n const {\n Autocomplete: Root,\n AutocompleteInput,\n AutocompleteContent,\n AutocompleteList,\n AutocompleteItem,\n } = autocomplete;\n\n return (\n <div\n data-slot=\"mentions\"\n dir={dir ?? direction}\n className={cn(\n 'relative min-w-0',\n classNames?.root, //\n )}\n >\n <Root\n items={loading ? [] : filtered}\n filter={null}\n value={text}\n defaultValue={defaultValue}\n onValueChange={(next, details) => {\n if (\n details.reason === 'item-press' ||\n details.reason === 'escape-key'\n ) {\n details.cancel();\n\n return;\n }\n\n pendingCaret.current = null;\n setText(next);\n\n if (textareaRef.current) {\n syncSelection(textareaRef.current);\n }\n }}\n disabled={disabled}\n readOnly={readOnly}\n name={name}\n form={form}\n open={open}\n onOpenChange={next => {\n if (!next) {\n setDismissed([signature]);\n }\n }}\n itemToStringValue={option => option.value}\n >\n <AutocompleteInput\n render={inputProps => {\n // Base UI's input handlers use the shared text-control DOM contract.\n // Adapt their input-only types while preserving the textarea atom.\n const native =\n inputProps as unknown as ComponentPropsWithRef<'textarea'>;\n\n return (\n <TextareaBridge\n {...native}\n {...props}\n ref={mergedRef}\n primitiveRef={native.ref}\n dir={dir ?? direction}\n data-slot=\"mentions-input\"\n className={cn(\n native.className,\n className, //\n )}\n onFocus={event => {\n onFocus?.(event);\n native.onFocus?.(event);\n setFocused(true);\n setDismissed([]);\n syncSelection(event.currentTarget);\n }}\n onBlur={event => {\n onBlur?.(event);\n native.onBlur?.(event);\n setFocused(false);\n }}\n onSelect={event => syncSelection(event.currentTarget)}\n onClick={event => {\n onClick?.(event);\n native.onClick?.(event);\n syncSelection(event.currentTarget);\n }}\n onKeyDown={event => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n if (\n !open ||\n composingRef.current ||\n event.nativeEvent.isComposing ||\n event.keyCode === 229 ||\n event.key === 'Home' ||\n event.key === 'End'\n ) {\n return;\n }\n\n native.onKeyDown?.(event);\n }}\n onKeyUp={event => {\n onKeyUp?.(event);\n native.onKeyUp?.(event);\n syncSelection(event.currentTarget);\n }}\n onCompositionStart={event => {\n composingRef.current = true;\n setComposing(true);\n onCompositionStart?.(event);\n native.onCompositionStart?.(event);\n }}\n onCompositionEnd={event => {\n composingRef.current = false;\n setComposing(false);\n onCompositionEnd?.(event);\n native.onCompositionEnd?.(event);\n syncSelection(event.currentTarget);\n }}\n />\n );\n }}\n />\n <AutocompleteContent\n container={container}\n dir={dir ?? direction}\n className={classNames?.content}\n >\n {(loading || filtered.length === 0) && (\n <div\n role=\"status\"\n className={cn(\n 'text-muted-foreground px-3 py-2 text-sm',\n classNames?.empty, //\n )}\n >\n {loading ? loadingText : emptyText}\n </div>\n )}\n <AutocompleteList\n className={cn(\n 'max-h-60 overflow-y-auto p-1',\n classNames?.list, //\n )}\n >\n {(option: Option) => (\n <AutocompleteItem\n key={option.value}\n value={option}\n disabled={option.disabled}\n onMouseUp={event => event.preventBaseUIHandler()}\n onClick={event => {\n event.preventBaseUIHandler();\n select(option);\n }}\n className={cn(\n `data-highlighted:bg-accent\n data-highlighted:text-accent-foreground cursor-default\n rounded-sm px-2 py-1.5 text-sm [overflow-wrap:anywhere]\n outline-none data-disabled:opacity-50`,\n classNames?.option, //\n )}\n >\n {option.label ?? option.value}\n </AutocompleteItem>\n )}\n </AutocompleteList>\n </AutocompleteContent>\n </Root>\n </div>\n );\n};\n\nexport default Mentions;\n"],"mappings":";;;;;;;;;;AAqDA,MAAM,mBAAmB,CAAC,GAAG;AAE7B,SAAS,eAAe,EACtB,cACA,KACA,GAAG,SAGF;CACD,MAAM,YAAY,aAAa,cAAc,GAAG;CAEhD,OAAO,oBAAC,MAAM,UAAP;EAAgB,GAAI;EAAO,KAAK;CAAY,CAAA;AACrD;AAEA,MAAM,YAAY,EAChB,SACA,OACA,eAAe,IACf,UACA,UACA,UACA,WAAW,kBACX,cACA,UAAU,OACV,cAAc,wBACd,YAAY,kBACZ,WACA,UACA,UACA,MACA,MACA,WACA,YACA,KACA,KACA,SACA,QACA,SACA,WACA,SACA,oBACA,kBACA,GAAG,YACQ;CACX,MAAM,EAAE,cAAc,UAAU;CAChC,MAAM,cAAc,OAAmC,IAAI;CAC3D,MAAM,YAAY,aAAa,KAAK,WAAW;CAC/C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oB,UAAS;MAC3B,aAAa,UAAU;MACvB,aAAa,IAAI;MACjB,qBAAqB,KAAK;MAC1B,OAAO,qBAAqB,KAAK;KACnC;KACA,mBAAkB,UAAS;MACzB,aAAa,UAAU;MACvB,aAAa,KAAK;MAClB,mBAAmB,KAAK;MACxB,OAAO,mBAAmB,KAAK;MAC/B,cAAc,MAAM,aAAa;KACnC;IACD,CAAA;GAEL,EACD,CAAA,GACD,qBAAC,qBAAD;IACa;IACX,KAAK,OAAO;IACZ,WAAW,YAAY;IAHzB,UAAA,EAKI,WAAW,SAAS,WAAW,MAC/B,oBAAC,OAAD;KACE,MAAK;KACL,WAAW,GACT,2CACA,YAAY,KACd;KAEC,UAAA,UAAU,cAAc;IACtB,CAAA,GAEP,oBAAC,kBAAD;KACE,WAAW,GACT,gCACA,YAAY,IACd;KAEE,WAAA,WACA,oBAAC,kBAAD;MAEE,OAAO;MACP,UAAU,OAAO;MACjB,YAAW,UAAS,MAAM,qBAAqB;MAC/C,UAAS,UAAS;OAChB,MAAM,qBAAqB;OAC3B,OAAO,MAAM;MACf;MACA,WAAW,GACT;;;0DAIA,YAAY,MACd;MAEC,UAAA,OAAO,SAAS,OAAO;KACR,GAjBX,OAAO,KAiBI;IAEJ,CAAA,CACC;GACjB,CAAA,CAAA;;CACH,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"Mentions.mjs","names":["autocomplete"],"sources":["../src/components/atoms/mentions.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ComponentPropsWithRef,\n type ReactNode,\n type Ref,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n useControllableState,\n useLatest,\n useMergedRef,\n} from '@jbpark/use-hooks';\n\nimport { useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport { autocomplete } from '../../core';\nimport Input from './input';\nimport { findToken, insertToken } from './mentions-token';\n\nexport interface Option {\n /** Unique, non-empty token text without whitespace or the prefix. */\n value: string;\n label?: string;\n prefix?: string;\n disabled?: boolean;\n}\n\nexport interface Props extends Omit<\n ComponentPropsWithRef<'textarea'>,\n 'children' | 'value' | 'defaultValue' | 'onChange' | 'onSelect'\n> {\n options: readonly Option[];\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n onSelect?: (option: Option, prefix: string) => void;\n onSearch?: (query: string, prefix: string) => void;\n prefixes?: readonly string[];\n filterOption?: false | ((query: string, option: Option) => boolean);\n loading?: boolean;\n loadingText?: ReactNode;\n emptyText?: ReactNode;\n container?: HTMLElement;\n classNames?: {\n root?: string;\n content?: string;\n list?: string;\n option?: string;\n empty?: string;\n };\n}\n\nconst DEFAULT_PREFIXES = ['@'];\n\nfunction TextareaBridge({\n primitiveRef,\n ref,\n ...props\n}: ComponentPropsWithRef<'textarea'> & {\n primitiveRef?: Ref<HTMLTextAreaElement>;\n}) {\n const mergedRef = useMergedRef(primitiveRef, ref);\n\n return <Input.TextArea {...props} ref={mergedRef} />;\n}\n\nconst Mentions = ({\n options,\n value,\n defaultValue = '',\n onChange,\n onSelect,\n onSearch,\n prefixes = DEFAULT_PREFIXES,\n filterOption,\n loading = false,\n loadingText = 'Loading suggestions…',\n emptyText = 'No suggestions',\n container,\n disabled,\n readOnly,\n name,\n form,\n className,\n classNames,\n dir,\n ref,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onCompositionStart,\n onCompositionEnd,\n ...props\n}: Props) => {\n const { direction } = useConfig();\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const mergedRef = useMergedRef(ref, textareaRef);\n const composingRef = useRef(false);\n const pendingCaret = useRef<{ value: string; caret: number } | null>(null);\n const [text, setText] = useControllableState<string>({\n value,\n defaultValue,\n onChange,\n });\n const [focused, setFocused] = useState(false);\n const [composing, setComposing] = useState(false);\n const [selection, setSelection] = useState({ text: '', start: 0, end: 0 });\n const [dismissed, setDismissed] = useState<readonly (string | null)[]>([]);\n const token =\n focused && !composing && !disabled && !readOnly && selection.text === text\n ? findToken(text, selection.start, selection.end, prefixes)\n : null;\n const signature = token\n ? JSON.stringify([text, selection.start, selection.end, token.prefix])\n : null;\n const open = token !== null && !dismissed.includes(signature);\n const query = token?.query;\n const prefix = token?.prefix;\n const searchRef = useLatest(onSearch);\n\n useEffect(() => {\n if (query !== undefined && prefix !== undefined) {\n searchRef.current?.(query, prefix);\n }\n }, [query, prefix, searchRef]);\n\n useEffect(() => {\n const pending = pendingCaret.current;\n const textarea = textareaRef.current;\n\n if (pending && textarea && text === pending.value) {\n pendingCaret.current = null;\n\n if (textarea.ownerDocument.activeElement === textarea) {\n textarea.setSelectionRange(pending.caret, pending.caret);\n }\n }\n });\n\n const syncSelection = (textarea: HTMLTextAreaElement) => {\n setSelection(previous => {\n const next = {\n text: textarea.value,\n start: textarea.selectionStart,\n end: textarea.selectionEnd,\n };\n\n return previous.text === next.text &&\n previous.start === next.start &&\n previous.end === next.end\n ? previous\n : next;\n });\n };\n const filtered = options.filter(option => {\n if (\n !option.value ||\n /\\s/u.test(option.value) ||\n prefixes.some(\n prefix => prefix.length > 0 && option.value.startsWith(prefix),\n ) ||\n (option.prefix !== undefined && option.prefix !== prefix)\n ) {\n return false;\n }\n\n if (filterOption === false) {\n return true;\n }\n\n return filterOption\n ? filterOption(query ?? '', option)\n : [option.value, option.label ?? ''].some(label =>\n label.toLowerCase().includes((query ?? '').toLowerCase()),\n );\n });\n const select = (option: Option) => {\n const textarea = textareaRef.current;\n\n if (\n !open ||\n !textarea ||\n composingRef.current ||\n option.disabled ||\n disabled ||\n readOnly ||\n textarea.value !== text\n ) {\n return;\n }\n\n const currentToken = findToken(\n text,\n textarea.selectionStart,\n textarea.selectionEnd,\n prefixes,\n );\n\n if (\n !currentToken ||\n currentToken.start !== token?.start ||\n currentToken.query !== token.query ||\n (currentToken.prefix !== option.prefix && option.prefix !== undefined)\n ) {\n return;\n }\n\n const next = insertToken(text, currentToken, option.value);\n\n pendingCaret.current = next;\n setDismissed([\n signature,\n JSON.stringify([next.value, next.caret, next.caret, currentToken.prefix]),\n ]);\n setText(next.value);\n onSelect?.(option, currentToken.prefix);\n };\n const {\n Autocomplete: Root,\n AutocompleteInput,\n AutocompleteContent,\n AutocompleteList,\n AutocompleteItem,\n } = autocomplete;\n\n return (\n <div\n data-slot=\"mentions\"\n dir={dir ?? direction}\n className={cn(\n 'relative min-w-0',\n classNames?.root, //\n )}\n >\n <Root\n items={loading ? [] : filtered}\n filter={null}\n value={text}\n defaultValue={defaultValue}\n onValueChange={(next, details) => {\n if (\n details.reason === 'item-press' ||\n details.reason === 'escape-key'\n ) {\n details.cancel();\n\n return;\n }\n\n pendingCaret.current = null;\n setText(next);\n\n if (textareaRef.current) {\n syncSelection(textareaRef.current);\n }\n }}\n disabled={disabled}\n readOnly={readOnly}\n name={name}\n form={form}\n open={open}\n onOpenChange={next => {\n if (!next) {\n setDismissed([signature]);\n }\n }}\n itemToStringValue={option => option.value}\n >\n <AutocompleteInput\n render={inputProps => {\n // Base UI's input handlers use the shared text-control DOM contract.\n // Adapt their input-only types while preserving the textarea atom.\n const native =\n inputProps as unknown as ComponentPropsWithRef<'textarea'>;\n\n return (\n <TextareaBridge\n {...native}\n {...props}\n ref={mergedRef}\n primitiveRef={native.ref}\n dir={dir ?? direction}\n data-slot=\"mentions-input\"\n className={cn(\n native.className,\n className, //\n )}\n onFocus={event => {\n onFocus?.(event);\n native.onFocus?.(event);\n setFocused(true);\n setDismissed([]);\n syncSelection(event.currentTarget);\n }}\n onBlur={event => {\n onBlur?.(event);\n native.onBlur?.(event);\n setFocused(false);\n }}\n onSelect={event => syncSelection(event.currentTarget)}\n onClick={event => {\n onClick?.(event);\n native.onClick?.(event);\n syncSelection(event.currentTarget);\n }}\n onKeyDown={event => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n if (\n !open ||\n composingRef.current ||\n event.nativeEvent.isComposing ||\n event.keyCode === 229 ||\n event.key === 'Home' ||\n event.key === 'End'\n ) {\n return;\n }\n\n native.onKeyDown?.(event);\n }}\n onKeyUp={event => {\n onKeyUp?.(event);\n native.onKeyUp?.(event);\n syncSelection(event.currentTarget);\n }}\n onCompositionStart={event => {\n composingRef.current = true;\n setComposing(true);\n onCompositionStart?.(event);\n native.onCompositionStart?.(event);\n }}\n onCompositionEnd={event => {\n composingRef.current = false;\n setComposing(false);\n onCompositionEnd?.(event);\n native.onCompositionEnd?.(event);\n syncSelection(event.currentTarget);\n }}\n />\n );\n }}\n />\n <AutocompleteContent\n container={container}\n dir={dir ?? direction}\n className={classNames?.content}\n >\n {(loading || filtered.length === 0) && (\n <div\n role=\"status\"\n className={cn(\n 'text-muted-foreground px-3 py-2 text-sm',\n classNames?.empty, //\n )}\n >\n {loading ? loadingText : emptyText}\n </div>\n )}\n <AutocompleteList\n className={cn(\n 'max-h-60 overflow-y-auto p-1',\n classNames?.list, //\n )}\n >\n {(option: Option) => (\n <AutocompleteItem\n key={option.value}\n value={option}\n disabled={option.disabled}\n onMouseUp={event => event.preventBaseUIHandler()}\n onClick={event => {\n event.preventBaseUIHandler();\n select(option);\n }}\n className={cn(\n `data-highlighted:bg-accent\n data-highlighted:text-accent-foreground cursor-default\n rounded-sm px-2 py-1.5 text-sm [overflow-wrap:anywhere]\n outline-none data-disabled:opacity-50`,\n classNames?.option, //\n )}\n >\n {option.label ?? option.value}\n </AutocompleteItem>\n )}\n </AutocompleteList>\n </AutocompleteContent>\n </Root>\n </div>\n );\n};\n\nexport default Mentions;\n"],"mappings":";;;;;;;;;;AAyDA,MAAM,mBAAmB,CAAC,GAAG;AAE7B,SAAS,eAAe,EACtB,cACA,KACA,GAAG,SAGF;CACD,MAAM,YAAY,aAAa,cAAc,GAAG;CAEhD,OAAO,oBAAC,MAAM,UAAP;EAAgB,GAAI;EAAO,KAAK;CAAY,CAAA;AACrD;AAEA,MAAM,YAAY,EAChB,SACA,OACA,eAAe,IACf,UACA,UACA,UACA,WAAW,kBACX,cACA,UAAU,OACV,cAAc,wBACd,YAAY,kBACZ,WACA,UACA,UACA,MACA,MACA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,YAAY,KAAK;KAC1B;KACA,UAAS,UAAS;MAChB,UAAU,KAAK;MACf,OAAO,UAAU,KAAK;MACtB,cAAc,MAAM,aAAa;KACnC;KACA,qBAAoB,UAAS;MAC3B,aAAa,UAAU;MACvB,aAAa,IAAI;MACjB,qBAAqB,KAAK;MAC1B,OAAO,qBAAqB,KAAK;KACnC;KACA,mBAAkB,UAAS;MACzB,aAAa,UAAU;MACvB,aAAa,KAAK;MAClB,mBAAmB,KAAK;MACxB,OAAO,mBAAmB,KAAK;MAC/B,cAAc,MAAM,aAAa;KACnC;IACD,CAAA;GAEL,EACD,CAAA,GACD,qBAAC,qBAAD;IACa;IACX,KAAK,OAAO;IACZ,WAAW,YAAY;IAHzB,UAAA,EAKI,WAAW,SAAS,WAAW,MAC/B,oBAAC,OAAD;KACE,MAAK;KACL,WAAW,GACT,2CACA,YAAY,KACd;KAEC,UAAA,UAAU,cAAc;IACtB,CAAA,GAEP,oBAAC,kBAAD;KACE,WAAW,GACT,gCACA,YAAY,IACd;KAEE,WAAA,WACA,oBAAC,kBAAD;MAEE,OAAO;MACP,UAAU,OAAO;MACjB,YAAW,UAAS,MAAM,qBAAqB;MAC/C,UAAS,UAAS;OAChB,MAAM,qBAAqB;OAC3B,OAAO,MAAM;MACf;MACA,WAAW,GACT;;;0DAIA,YAAY,MACd;MAEC,UAAA,OAAO,SAAS,OAAO;KACR,GAjBX,OAAO,KAiBI;IAEJ,CAAA,CACC;GACjB,CAAA,CAAA;;CACH,CAAA;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.mts","names":[],"sources":["../src/components/organisms/modal.tsx"],"mappings":";;iBAiCiB;EACf;EACA;EACA;IAGM,YAAY,MAAM;IAClB;;EAEN,YAAY,MAAM;EAClB,QAAQ,MAAM;EACd,UAAU,MAAM;EAChB,SAAS,MAAM;EACf;EACA;IACE;IACA;IACA;IACA;;EAEF,QAAQ,MAAM;EACd;EACA;EACA,YAAY;EACZ,WAAW,MAAM;EACjB;EACA;;EAEA,wBAAwB;;KAGrB;UAEK,oBAAoB;EAC5B,SAAS;;;;;;EAMT;EACA;EACA,OAAO,MAAM;EACb,YAAY;;cAGR;KAmBH,MAAA,cAAA,UAAA,WAAA,WAAA,YAAA,OAAA,OAAA,SAAA,QAAA,WAAA,UAAA,QAAA,YAAA,MAAA,UAAA,yBAAA,SAAA,QAAK,MAAA,IAAA;;;;EA2Oa,KAAA,OAAA;EAEG,QAAA,OAAA;EAEF,MAAA,OAAA;EAEE,QAAA,OAAA;EAIA,QAAA,OAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "
|
|
3
|
-
import { DEFAULT_LOCALE, useConfig } from "
|
|
4
|
-
import Button from "
|
|
5
|
-
import { dialog_exports } from "
|
|
6
|
-
import { createImperativeStack, isBrowser } from "./imperative-stack.mjs";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import { DEFAULT_LOCALE, useConfig } from "./providers/config/context.mjs";
|
|
4
|
+
import Button from "./Button.mjs";
|
|
5
|
+
import { dialog_exports } from "./core/dialog.mjs";
|
|
6
|
+
import { createImperativeStack, isBrowser } from "./components/organisms/imperative-stack.mjs";
|
|
7
7
|
import { useRef, useState } from "react";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Check, CircleQuestionMark, Info, OctagonAlert, OctagonX } from "lucide-react";
|
|
@@ -159,4 +159,4 @@ Modal.confirm = (props) => modalStack.render({
|
|
|
159
159
|
//#endregion
|
|
160
160
|
export { Modal as default };
|
|
161
161
|
|
|
162
|
-
//# sourceMappingURL=
|
|
162
|
+
//# sourceMappingURL=Modal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.mjs","names":["dialog"],"sources":["../src/components/organisms/modal.tsx"],"sourcesContent":["'use client';\n\nimport React, { useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport {\n Check,\n CircleQuestionMark,\n Info,\n OctagonAlert,\n OctagonX,\n} from 'lucide-react';\n\nimport { DEFAULT_LOCALE, useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport { dialog } from '../../core';\nimport Button from '../atoms/button';\nimport {\n type ImperativeStack,\n createImperativeStack,\n isBrowser,\n} from './imperative-stack';\n\nconst {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} = dialog;\n\nexport interface Props {\n open?: boolean;\n maskClosable?: boolean;\n closable?:\n | boolean\n | {\n closeIcon?: React.ReactNode;\n disabled?: boolean;\n };\n closeIcon?: React.ReactNode;\n title?: React.ReactNode;\n content?: React.ReactNode;\n footer?: React.ReactNode;\n className?: string;\n classNames?: {\n mask?: string;\n header?: string;\n body?: string;\n footer?: string;\n };\n style?: React.CSSProperties;\n okText?: string;\n cancelText?: string;\n container?: HTMLElement;\n children?: React.ReactNode;\n onOk?: () => void;\n onCancel?: () => void;\n /** Called after the opening or closing animations finish. */\n onOpenChangeComplete?: (open: boolean) => void;\n}\n\ntype ModalStatus = 'info' | 'success' | 'error' | 'warning';\n\ninterface StaticProps extends Props {\n status?: ModalStatus;\n /**\n * Interaction mode set by `Modal.confirm()` to request the two-button\n * footer. `confirm` is a mode, not a status, so it rides its own axis rather\n * than `status` — call `Modal.confirm()` rather than setting this directly.\n */\n mode?: 'confirm';\n id?: string;\n icon?: React.ReactNode;\n container?: HTMLElement;\n}\n\nconst Modal = ({\n open = false,\n maskClosable,\n closable = false,\n closeIcon,\n className,\n classNames,\n style,\n title,\n content,\n footer,\n container,\n children,\n okText,\n cancelText,\n onOk,\n onCancel,\n onOpenChangeComplete,\n ...props\n}: Props) => {\n const { locale, defaultProps } = useConfig();\n const modalDefaults = defaultProps?.modal as\n Partial<Pick<Props, 'maskClosable'>> | undefined;\n // Explicit prop > `Config` default > built-in, matching Button/Tag.\n const resolvedMaskClosable =\n maskClosable ?? modalDefaults?.maskClosable ?? false;\n\n if (typeof window === 'undefined') {\n return null;\n }\n\n return (\n <Dialog\n open={open}\n onOpenChangeComplete={onOpenChangeComplete}\n onOpenChange={(open: boolean) => {\n if (!open) {\n onCancel?.();\n }\n }}\n // antd's `maskClosable` is a root-level dismissal concern in Base UI:\n // blocking the outside (mask) press keeps the dialog open on backdrop\n // click while Escape still closes it, matching the previous behaviour.\n disablePointerDismissal={!resolvedMaskClosable}\n {...props}\n >\n <DialogContent\n className={cn(\n 'rounded-lg p-4 max-sm:max-w-[80%]',\n 'border-none outline-none',\n className,\n )}\n classNames={{\n ...classNames,\n mask: cn('bg-black/60', classNames?.mask),\n }}\n style={style}\n closable={closable}\n closeIcon={closeIcon}\n container={container}\n >\n {/**\n * @todo [Dialog & AlertDialog] fix: can't get id correctly in shadow dom\n *\n * Filed while `core/dialog` was still Radix-based; the linked fix is\n * Radix's, and the repo no longer depends on it. Revalidate against\n * Base UI's Dialog before acting on this — the bug may already be gone.\n * @see https://github.com/radix-ui/primitives/pull/3384\n **/}\n <DialogHeader\n className={cn(\n classNames?.header,\n !title && 'hidden',\n //\n )}\n >\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription className=\"hidden\" />\n </DialogHeader>\n <div className={cn('break-all', classNames?.body)}>\n {children ?? content}\n </div>\n {footer !== null && (\n <DialogFooter\n className={cn('flex-row justify-end gap-x-2', classNames?.footer)}\n >\n {footer || (\n <>\n <Button variant=\"outlined\" onClick={onCancel}>\n {cancelText ?? locale.cancel ?? DEFAULT_LOCALE.cancel}\n </Button>\n <Button type=\"primary\" onClick={onOk}>\n {okText ?? locale.ok ?? DEFAULT_LOCALE.ok}\n </Button>\n </>\n )}\n </DialogFooter>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n\nconst STATIC_ICONS = {\n info: <Info className=\"text-blue-400\" />,\n success: <Check className=\"text-green-400\" />,\n error: <OctagonX className=\"text-red-400\" />,\n warning: <OctagonAlert className=\"text-yellow-400\" />,\n confirm: <CircleQuestionMark />,\n};\n\nconst StaticModal = ({\n id,\n status,\n mode,\n title,\n content,\n okText,\n cancelText,\n container,\n icon,\n onOk,\n onCancel,\n onOpenChangeComplete,\n ...props\n}: StaticProps & { id: string }): React.ReactPortal | null => {\n const { locale } = useConfig();\n const [open, setOpen] = useState(true);\n const closing = useRef(false);\n const resolvedOkText = okText ?? locale.ok ?? DEFAULT_LOCALE.ok;\n const resolvedCancelText =\n cancelText ?? locale.cancel ?? DEFAULT_LOCALE.cancel;\n // `confirm` is an interaction mode (two-button footer), not a status; the\n // semantic state comes from `status`.\n const isConfirm = mode === 'confirm';\n\n const closeModal = (callback?: () => void) => {\n if (closing.current) {\n return;\n }\n\n closing.current = true;\n setOpen(false);\n callback?.();\n };\n\n const footer = isConfirm ? (\n <div className=\"grid w-full grid-cols-5 gap-x-2\">\n <Button\n variant=\"outlined\"\n className=\"col-span-2\"\n onClick={() => closeModal(onCancel)}\n >\n {resolvedCancelText}\n </Button>\n <Button\n type=\"primary\"\n className=\"col-span-3\"\n onClick={() => closeModal(onOk)}\n >\n {resolvedOkText}\n </Button>\n </div>\n ) : (\n <Button\n type=\"primary\"\n className={cn(\n 'grow',\n //\n )}\n onClick={() => closeModal(onOk)}\n >\n {resolvedOkText}\n </Button>\n );\n\n if (!isBrowser) {\n return null;\n }\n\n return createPortal(\n <Modal\n open={open}\n footer={footer}\n className={cn(\n 'z-10000',\n 'box-content w-100',\n 'rounded-3xl p-4',\n 'gap-y-0',\n )}\n classNames={{\n mask: 'z-10000 bg-black/[.6]',\n body: cn(\n 'text-black-70 whitespace-pre-wrap text-center',\n content && 'mt-3',\n ),\n footer: 'mt-9',\n }}\n title={\n <p\n className={cn(\n 'text-center text-lg leading-normal whitespace-pre-wrap',\n 'flex items-center justify-center gap-x-2',\n //\n )}\n >\n {icon ||\n (isConfirm ? STATIC_ICONS.confirm : status && STATIC_ICONS[status])}\n {title}\n </p>\n }\n container={container}\n onCancel={() => closeModal(onCancel)}\n {...props}\n onOpenChangeComplete={open => {\n if (!open) {\n modalStack.destroy(id);\n }\n\n onOpenChangeComplete?.(open);\n }}\n >\n {content}\n </Modal>,\n modalStack.getRootElement(container)!,\n );\n};\n\n// No `role`/`aria-modal` here — this element is only a mount point for the\n// imperative stack, not the dialog itself. Base UI already renders its own\n// `role=\"dialog\"`/`aria-modal=\"true\"` on the actual `DialogContent` via\n// portal once a modal is open. Setting it here as well would (a) leave\n// `aria-modal=\"true\"` on the page permanently, even with zero modals open,\n// hiding the rest of the document from screen readers, and (b) duplicate\n// Base UI's own dialog role once one is open.\nconst modalStack: ImperativeStack<StaticProps> =\n createImperativeStack<StaticProps>({\n createRootElement: () => {\n const el = document.createElement('div');\n el.style.zIndex = '10000';\n el.style.position = 'absolute';\n return el;\n },\n StackItem: StaticModal,\n });\n\n/** Immediately removes a modal without waiting for its closing animation. */\nModal.destroy = modalStack.destroy;\n\n/** Immediately removes all modals, including those currently closing. */\nModal.destroyAll = () => {\n modalStack.destroy();\n};\n\nModal.info = (props: StaticProps) =>\n modalStack.render({ status: 'info', ...props });\nModal.success = (props: StaticProps) =>\n modalStack.render({ status: 'success', ...props });\nModal.error = (props: StaticProps) =>\n modalStack.render({ status: 'error', ...props });\nModal.warning = (props: StaticProps) =>\n modalStack.render({ status: 'warning', ...props });\n// `confirm` is a mode, not a status, so it rides its own `mode` axis rather\n// than `status`.\nModal.confirm = (props: StaticProps) =>\n modalStack.render({ mode: 'confirm', ...props });\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,EACJ,QACA,eACA,mBACA,cACA,cACA,gBACEA;AAgDJ,MAAM,SAAS,EACb,OAAO,OACP,cACA,WAAW,OACX,WACA,WACA,YACA,OACA,OACA,SACA,QACA,WACA,UACA,QACA,YACA,MACA,UACA,sBACA,GAAG,YACQ;CACX,MAAM,EAAE,QAAQ,iBAAiB,UAAU;CAC3C,MAAM,gBAAgB,cAAc;CAGpC,MAAM,uBACJ,gBAAgB,eAAe,gBAAgB;CAE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,MAAM,aACJ,sBAAmC;CACjC,yBAAyB;EACvB,MAAM,KAAK,SAAS,cAAc,KAAK;EACvC,GAAG,MAAM,SAAS;EAClB,GAAG,MAAM,WAAW;EACpB,OAAO;CACT;CACA,WAAW;AACb,CAAC;;AAGH,MAAM,UAAU,WAAW;;AAG3B,MAAM,mBAAmB;CACvB,WAAW,QAAQ;AACrB;AAEA,MAAM,QAAQ,UACZ,WAAW,OAAO;CAAE,QAAQ;CAAQ,GAAG;AAAM,CAAC;AAChD,MAAM,WAAW,UACf,WAAW,OAAO;CAAE,QAAQ;CAAW,GAAG;AAAM,CAAC;AACnD,MAAM,SAAS,UACb,WAAW,OAAO;CAAE,QAAQ;CAAS,GAAG;AAAM,CAAC;AACjD,MAAM,WAAW,UACf,WAAW,OAAO;CAAE,QAAQ;CAAW,GAAG;AAAM,CAAC;AAGnD,MAAM,WAAW,UACf,WAAW,OAAO;CAAE,MAAM;CAAW,GAAG;AAAM,CAAC"}
|
|
@@ -15,4 +15,4 @@ export interface Props extends Omit<React.ComponentProps<'div'>, 'title'> {
|
|
|
15
15
|
declare const PageHeader: ({ title, subTitle, extra, backIcon, onBack, className, classNames, children, ...props }: Props) => import("react").JSX.Element;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { PageHeader as default };
|
|
18
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=PageHeader.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageHeader.d.mts","names":[],"sources":["../src/components/templates/page-header.tsx"],"mappings":";iBASiB,cAAc,KAAK,MAAM;EACxC,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB;EACA;IACE;IACA;IACA;IACA;;;cAOE,eAAc,OAAA,UAAA,OAAA,UAAA,QAAA,WAAA,YAAA,aAAA,SAUjB,0BAAK,IAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "
|
|
3
|
-
import { DEFAULT_LOCALE, useConfig } from "
|
|
4
|
-
import Button from "
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import { DEFAULT_LOCALE, useConfig } from "./providers/config/context.mjs";
|
|
4
|
+
import Button from "./Button.mjs";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { ArrowLeft } from "lucide-react";
|
|
7
7
|
//#region src/components/templates/page-header.tsx
|
|
@@ -43,4 +43,4 @@ const PageHeader = ({ title, subTitle, extra, backIcon, onBack, className, class
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { PageHeader as default };
|
|
45
45
|
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=PageHeader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageHeader.mjs","names":[],"sources":["../src/components/templates/page-header.tsx"],"sourcesContent":["'use client';\n\nimport { ArrowLeft } from 'lucide-react';\n\nimport { DEFAULT_LOCALE, useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport Button from '../atoms/button';\n\nexport interface Props extends Omit<React.ComponentProps<'div'>, 'title'> {\n title?: React.ReactNode;\n subTitle?: React.ReactNode;\n extra?: React.ReactNode;\n backIcon?: React.ReactNode;\n onBack?: () => void;\n classNames?: {\n back?: string;\n title?: string;\n subTitle?: string;\n extra?: string;\n };\n}\n\n// Title + back button + extra action area — same shape as Drawer's header\n// (title/extra/closable), which this borrows the layout from wholesale;\n// PageHeader just swaps Drawer's close button for a back button.\nconst PageHeader = ({\n title,\n subTitle,\n extra,\n backIcon,\n onBack,\n className,\n classNames,\n children,\n ...props\n}: Props) => {\n const { locale } = useConfig();\n\n return (\n <div\n data-slot=\"page-header\"\n className={cn('flex flex-col gap-2', className)}\n {...props}\n >\n <div className=\"flex items-start gap-2\">\n {onBack && (\n <Button\n variant=\"text\"\n shape=\"circle\"\n size=\"small\"\n aria-label={locale.back ?? DEFAULT_LOCALE.back}\n icon={backIcon || <ArrowLeft />}\n onClick={onBack}\n className={cn(classNames?.back)}\n />\n )}\n <div className=\"flex flex-1 items-start justify-between gap-2\">\n <div className=\"flex flex-col gap-0.5\">\n {title && (\n <p className={cn('text-lg font-medium', classNames?.title)}>\n {title}\n </p>\n )}\n {subTitle && (\n <p\n className={cn(\n 'text-muted-foreground text-sm',\n classNames?.subTitle,\n )}\n >\n {subTitle}\n </p>\n )}\n </div>\n {extra != null && (\n <div className={cn('shrink-0', classNames?.extra)}>{extra}</div>\n )}\n </div>\n </div>\n {children}\n </div>\n );\n};\n\nexport default PageHeader;\n"],"mappings":";;;;;;;AA0BA,MAAM,cAAc,EAClB,OACA,UACA,OACA,UACA,QACA,WACA,YACA,UACA,GAAG,YACQ;CACX,MAAM,EAAE,WAAW,UAAU;CAE7B,OACE,qBAAC,OAAD;EACE,aAAU;EACV,WAAW,GAAG,uBAAuB,SAAS;EAC9C,GAAI;EAHN,UAAA,CAKE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,UACC,oBAAC,QAAD;IACE,SAAQ;IACR,OAAM;IACN,MAAK;IACL,cAAY,OAAO,QAAQ,eAAe;IAC1C,MAAM,YAAY,oBAAC,WAAD,CAAY,CAAA;IAC9B,SAAS;IACT,WAAW,GAAG,YAAY,IAAI;GAC/B,CAAA,GAEH,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,SACC,oBAAC,KAAD;MAAG,WAAW,GAAG,uBAAuB,YAAY,KAAK;MACtD,UAAA;KACA,CAAA,GAEJ,YACC,oBAAC,KAAD;MACE,WAAW,GACT,iCACA,YAAY,QACd;MAEC,UAAA;KACA,CAAA,CAEF;IACJ,CAAA,GAAA,SAAS,QACR,oBAAC,OAAD;KAAK,WAAW,GAAG,YAAY,YAAY,KAAK;KAAI,UAAA;IAAW,CAAA,CAE9D;GACF,CAAA,CAAA;EACJ,CAAA,GAAA,QACE;;AAET"}
|
package/dist/Pagination.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "./utils.mjs";
|
|
3
3
|
import { useConfig } from "./providers/config/context.mjs";
|
|
4
4
|
import Button from "./Button.mjs";
|
|
5
|
-
import Input from "./
|
|
6
|
-
import Select from "./
|
|
5
|
+
import Input from "./Input.mjs";
|
|
6
|
+
import Select from "./Select.mjs";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
|
package/dist/Popconfirm.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Props as Props$1 } from "./Button.mjs";
|
|
2
|
-
import { Props as Props$2 } from "./
|
|
2
|
+
import { Props as Props$2 } from "./Popover.mjs";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
//#region src/components/molecules/popconfirm.d.ts
|
|
5
5
|
type ActionProps = Omit<Props$1, 'children' | 'onClick' | 'loading' | 'disabled'>;
|
package/dist/Popconfirm.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { cn } from "./utils.mjs";
|
|
3
3
|
import Button from "./Button.mjs";
|
|
4
4
|
import Typography from "./Typography.mjs";
|
|
5
|
-
import Popover from "./
|
|
5
|
+
import Popover from "./Popover.mjs";
|
|
6
6
|
import * as React$1 from "react";
|
|
7
7
|
import { useControllableState } from "@jbpark/use-hooks";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -13,4 +13,4 @@ export interface Props extends Omit<React.ComponentPropsWithoutRef<'div'>, 'titl
|
|
|
13
13
|
declare const Popover: ({ title, nativeButton, placement, className, content, children, open: _open, defaultOpen, onOpenChange, ...props }: Props) => import("react").JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { Popover as default };
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=Popover.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.d.mts","names":[],"sources":["../src/components/atoms/popover.tsx"],"mappings":";KAmBK;iBAcY,cAAc,KAC7B,MAAM;EAGN,QAAQ,MAAM;;EAEd;EACA,YAAY;EACZ,SAAS,MAAM;EACf;EACA;EACA,gBAAgB;;cAqBZ,YAAW,OAAA,cAAA,WAAA,WAAA,SAAA,UAAA,MAAA,OAAA,aAAA,iBAAA,SAWd,0BAAK,IAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn, renderConditional } from "
|
|
3
|
-
import { popover_exports } from "
|
|
4
|
-
import Typography from "
|
|
2
|
+
import { cn, renderConditional } from "./utils.mjs";
|
|
3
|
+
import { popover_exports } from "./core/popover.mjs";
|
|
4
|
+
import Typography from "./Typography.mjs";
|
|
5
5
|
import { Children } from "react";
|
|
6
6
|
import { useControllableState } from "@jbpark/use-hooks";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -91,4 +91,4 @@ const Popover = ({ title, nativeButton, placement = "top", className, content, c
|
|
|
91
91
|
//#endregion
|
|
92
92
|
export { Popover as default };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=
|
|
94
|
+
//# sourceMappingURL=Popover.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.mjs","names":["popover"],"sources":["../src/components/atoms/popover.tsx"],"sourcesContent":["'use client';\n\nimport { Children, type ReactElement } from 'react';\n\nimport { useControllableState } from '@jbpark/use-hooks';\n\nimport { cn, renderConditional } from '@repo/ui/utils';\n\nimport { popover } from '../../core';\nimport Typography from './typography';\n\nconst {\n Popover: CorePopover,\n PopoverContent,\n PopoverTrigger,\n PopoverArrow,\n PopoverTitle,\n} = popover;\n\ntype Placement =\n | 'top'\n | 'left'\n | 'right'\n | 'bottom'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n\nexport interface Props extends Omit<\n React.ComponentPropsWithoutRef<'div'>,\n 'title' | 'content'\n> {\n title?: React.ReactNode;\n /** Set to false when a custom trigger component renders a non-button element. */\n nativeButton?: boolean;\n placement?: Placement;\n content: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\ntype Side = 'top' | 'bottom' | 'left' | 'right';\ntype Align = 'start' | 'center' | 'end';\n\nconst placementMap: Record<Placement, { side: Side; align: Align }> = {\n top: { side: 'top', align: 'center' },\n left: { side: 'left', align: 'center' },\n right: { side: 'right', align: 'center' },\n bottom: { side: 'bottom', align: 'center' },\n topLeft: { side: 'top', align: 'start' },\n topRight: { side: 'top', align: 'end' },\n bottomLeft: { side: 'bottom', align: 'start' },\n bottomRight: { side: 'bottom', align: 'end' },\n leftTop: { side: 'left', align: 'start' },\n leftBottom: { side: 'left', align: 'end' },\n rightTop: { side: 'right', align: 'start' },\n rightBottom: { side: 'right', align: 'end' },\n};\n\nconst Popover = ({\n title,\n nativeButton,\n placement = 'top',\n className,\n content,\n children,\n open: _open,\n defaultOpen,\n onOpenChange,\n ...props\n}: Props) => {\n const [open, setOpen] = useControllableState<boolean>({\n value: _open,\n defaultValue: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n const { side, align } = placementMap[placement];\n\n const trigger = Children.only(children) as ReactElement;\n\n return (\n <CorePopover open={open} onOpenChange={setOpen}>\n {/* Deliberately no `data-slot` here: Base UI merges the trigger's own\n props over the rendered element's, so a `data-slot` set here replaces\n the child's. A `Button` trigger would lose `data-slot=\"button\"` and\n with it every `--btn-*` token rule in globals.css. */}\n <PopoverTrigger\n render={trigger}\n nativeButton={\n nativeButton ??\n (typeof trigger.type !== 'string' || trigger.type === 'button')\n }\n />\n <PopoverContent\n {...props}\n align={align}\n side={side}\n sideOffset={16}\n className={cn('relative w-auto', className)}\n >\n {renderConditional(title, v => (\n <PopoverTitle render={<Typography.Title level={6} />}>\n {v}\n </PopoverTitle>\n ))}\n {content}\n <PopoverArrow />\n </PopoverContent>\n </CorePopover>\n );\n};\n\nexport default Popover;\n"],"mappings":";;;;;;;;AAWA,MAAM,EACJ,SAAS,aACT,gBACA,gBACA,cACA,iBACEA;AAiCJ,MAAM,eAAgE;CACpE,KAAK;EAAE,MAAM;EAAO,OAAO;CAAS;CACpC,MAAM;EAAE,MAAM;EAAQ,OAAO;CAAS;CACtC,OAAO;EAAE,MAAM;EAAS,OAAO;CAAS;CACxC,QAAQ;EAAE,MAAM;EAAU,OAAO;CAAS;CAC1C,SAAS;EAAE,MAAM;EAAO,OAAO;CAAQ;CACvC,UAAU;EAAE,MAAM;EAAO,OAAO;CAAM;CACtC,YAAY;EAAE,MAAM;EAAU,OAAO;CAAQ;CAC7C,aAAa;EAAE,MAAM;EAAU,OAAO;CAAM;CAC5C,SAAS;EAAE,MAAM;EAAQ,OAAO;CAAQ;CACxC,YAAY;EAAE,MAAM;EAAQ,OAAO;CAAM;CACzC,UAAU;EAAE,MAAM;EAAS,OAAO;CAAQ;CAC1C,aAAa;EAAE,MAAM;EAAS,OAAO;CAAM;AAC7C;AAEA,MAAM,WAAW,EACf,OACA,cACA,YAAY,OACZ,WACA,SACA,UACA,MAAM,OACN,aACA,cACA,GAAG,YACQ;CACX,MAAM,CAAC,MAAM,WAAW,qBAA8B;EACpD,OAAO;EACP,cAAc,eAAe;EAC7B,UAAU;CACZ,CAAC;CAED,MAAM,EAAE,MAAM,UAAU,aAAa;CAErC,MAAM,UAAU,SAAS,KAAK,QAAQ;CAEtC,OACE,qBAAC,aAAD;EAAmB;EAAM,cAAc;EAAvC,UAAA,CAKE,oBAAC,gBAAD;GACE,QAAQ;GACR,cACE,iBACC,OAAO,QAAQ,SAAS,YAAY,QAAQ,SAAS;EAEzD,CAAA,GACD,qBAAC,gBAAD;GACE,GAAI;GACG;GACD;GACN,YAAY;GACZ,WAAW,GAAG,mBAAmB,SAAS;GAL5C,UAAA;IAOG,kBAAkB,QAAO,MACxB,oBAAC,cAAD;KAAc,QAAQ,oBAAC,WAAW,OAAZ,EAAkB,OAAO,EAAI,CAAA;KAChD,UAAA;IACW,CAAA,CACf;IACA;IACD,oBAAC,cAAD,CAAe,CAAA;GACD;EACL,CAAA,CAAA;;AAEjB"}
|
|
@@ -12,4 +12,4 @@ export interface Props extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
12
12
|
declare const Progress: ({ value, className, orientation, direction, classNames, ...props }: Props) => import("react").JSX.Element;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { Progress as default };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=Progress.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.d.mts","names":[],"sources":["../src/components/atoms/progress.tsx"],"mappings":";iBAMiB,cAAc,MAAM;EACnC;EACA;;EAEA;EACA;IACE;IACA;;;cAIE,aAAY,OAAA,WAAA,aAAA,WAAA,eAAA,SAOf,0BAAK,IAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cn } from "
|
|
2
|
-
import { progress_exports } from "
|
|
1
|
+
import { cn } from "./utils.mjs";
|
|
2
|
+
import { progress_exports } from "./core/progress.mjs";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/atoms/progress.tsx
|
|
5
5
|
const { Progress: Core } = progress_exports;
|
|
@@ -20,4 +20,4 @@ const Progress = ({ value, className, orientation, direction = "horizontal", cla
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { Progress as default };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=Progress.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.mjs","names":["progress"],"sources":["../src/components/atoms/progress.tsx"],"sourcesContent":["import { cn } from '@repo/ui/utils';\n\nimport { progress } from '../../core';\n\nconst { Progress: Core } = progress;\n\nexport interface Props extends React.ComponentPropsWithoutRef<'div'> {\n value: number;\n orientation?: 'horizontal' | 'vertical';\n /** @deprecated Use `orientation`. */\n direction?: 'horizontal' | 'vertical';\n classNames?: {\n background?: string;\n bar?: string;\n };\n}\n\nconst Progress = ({\n value,\n className,\n orientation,\n direction = 'horizontal',\n classNames,\n ...props\n}: Props) => {\n const isHorizontal = (orientation ?? direction) === 'horizontal';\n const normalizedValue = Number.isFinite(value)\n ? Math.min(100, Math.max(0, value))\n : 0;\n\n return (\n <Core\n {...props}\n value={normalizedValue}\n className={cn(\n isHorizontal ? 'h-4 w-full' : 'flex h-full w-4 flex-col justify-end',\n className,\n classNames?.background,\n //\n )}\n barClassName={cn('flex-none', classNames?.bar)}\n barStyle={\n isHorizontal\n ? { width: `${normalizedValue}%` }\n : { width: '100%', height: `${normalizedValue}%` }\n }\n />\n );\n};\n\nexport default Progress;\n"],"mappings":";;;;AAIA,MAAM,EAAE,UAAU,SAASA;AAa3B,MAAM,YAAY,EAChB,OACA,WACA,aACA,YAAY,cACZ,YACA,GAAG,YACQ;CACX,MAAM,gBAAgB,eAAe,eAAe;CACpD,MAAM,kBAAkB,OAAO,SAAS,KAAK,IACzC,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,IAChC;CAEJ,OACE,oBAAC,MAAD;EACE,GAAI;EACJ,OAAO;EACP,WAAW,GACT,eAAe,eAAe,wCAC9B,WACA,YAAY,UAEd;EACA,cAAc,GAAG,aAAa,YAAY,GAAG;EAC7C,UACE,eACI,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAC/B;GAAE,OAAO;GAAQ,QAAQ,GAAG,gBAAgB;EAAG;CAEtD,CAAA;AAEL"}
|
package/dist/Radio.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import RadioGroup from "./components/atoms/radio/group.mjs";
|
|
2
|
+
import Radio$1, { Props } from "./components/atoms/radio/radio.mjs";
|
|
3
|
+
//#region src/components/atoms/radio/index.d.ts
|
|
4
|
+
type RadioComponent = typeof Radio$1 & {
|
|
5
|
+
Group: typeof RadioGroup;
|
|
6
|
+
};
|
|
7
|
+
declare const Radio: RadioComponent;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { type Props, Radio as default };
|
|
10
|
+
//# sourceMappingURL=Radio.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.d.mts","names":["RadioImpl","Group"],"sources":["../src/components/atoms/radio/index.ts"],"mappings":";;;KAGK,wBAAwBA;EAAc,cAAcC;;cAEnD,OAAqB"}
|
package/dist/Radio.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Radio$1 from "./components/atoms/radio/radio.mjs";
|
|
2
|
+
import RadioGroup from "./components/atoms/radio/group.mjs";
|
|
3
|
+
//#region src/components/atoms/radio/index.ts
|
|
4
|
+
const Radio = Radio$1;
|
|
5
|
+
Radio.Group = RadioGroup;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { Radio as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=Radio.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.mjs","names":["RadioImpl","Group"],"sources":["../src/components/atoms/radio/index.ts"],"sourcesContent":["import Group from './group';\nimport RadioImpl, { type Props } from './radio';\n\ntype RadioComponent = typeof RadioImpl & { Group: typeof Group };\n\nconst Radio = RadioImpl as RadioComponent;\n\nRadio.Group = Group;\n\nexport default Radio;\nexport type { Props };\n"],"mappings":";;;AAKA,MAAM,QAAQA;AAEd,MAAM,QAAQC"}
|
|
@@ -10,4 +10,4 @@ export interface Props extends Omit<React.ComponentProps<'div'>, 'title'> {
|
|
|
10
10
|
declare const Result: ({ status, icon, title, subTitle, extra, className, children, ...props }: Props) => import("react").JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Result as default };
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=Result.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Result.d.mts","names":[],"sources":["../src/components/templates/result.tsx"],"mappings":";KAYK;iBAeY,cAAc,KAAK,MAAM;EACxC,SAAS;EACT,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,QAAQ,MAAM;;cAMV,WAAU,QAAA,MAAA,OAAA,UAAA,OAAA,WAAA,aAAA,SASb,0BAAK,IAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn } from "
|
|
1
|
+
import { cn } from "./utils.mjs";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Check, FileQuestion, Info, OctagonAlert, OctagonX, ServerCrash, ShieldAlert } from "lucide-react";
|
|
4
4
|
//#region src/components/templates/result.tsx
|
|
@@ -43,4 +43,4 @@ const Result = ({ status = "info", icon, title, subTitle, extra, className, chil
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { Result as default };
|
|
45
45
|
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=Result.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Result.mjs","names":[],"sources":["../src/components/templates/result.tsx"],"sourcesContent":["import {\n Check,\n FileQuestion,\n Info,\n OctagonAlert,\n OctagonX,\n ServerCrash,\n ShieldAlert,\n} from 'lucide-react';\n\nimport { cn } from '@repo/ui/utils';\n\ntype Status = 'success' | 'error' | 'info' | 'warning' | '404' | '403' | '500';\n\n// Reuses Modal's exact STATIC_ICONS set (Check/OctagonX/Info/OctagonAlert,\n// same colors) for the 4 statuses they share, so a Result page matches the\n// tone of a Modal.success()/error()/etc a user may have just seen.\nconst STATUS_ICONS: Record<Status, React.ReactNode> = {\n success: <Check className=\"text-green-400\" />,\n error: <OctagonX className=\"text-red-400\" />,\n info: <Info className=\"text-blue-400\" />,\n warning: <OctagonAlert className=\"text-yellow-400\" />,\n '404': <FileQuestion className=\"text-muted-foreground\" />,\n '403': <ShieldAlert className=\"text-muted-foreground\" />,\n '500': <ServerCrash className=\"text-muted-foreground\" />,\n};\n\nexport interface Props extends Omit<React.ComponentProps<'div'>, 'title'> {\n status?: Status;\n icon?: React.ReactNode;\n title?: React.ReactNode;\n subTitle?: React.ReactNode;\n extra?: React.ReactNode;\n}\n\n// Full-page success/failure/404/403 state screen — Empty's larger,\n// more prominent sibling (Empty says \"nothing here yet\" inline within a\n// list/table; Result says \"here's what happened\" for an entire page/view).\nconst Result = ({\n status = 'info',\n icon,\n title,\n subTitle,\n extra,\n className,\n children,\n ...props\n}: Props) => {\n return (\n <div\n data-slot=\"result\"\n className={cn(\n 'flex flex-col items-center justify-center gap-2 py-16 text-center',\n className,\n //\n )}\n {...props}\n >\n <div className=\"mb-2 [&_svg]:size-16\">{icon ?? STATUS_ICONS[status]}</div>\n {title && <p className=\"text-xl font-medium\">{title}</p>}\n {subTitle && <p className=\"text-muted-foreground text-sm\">{subTitle}</p>}\n {extra && (\n <div className=\"mt-4 flex items-center justify-center gap-2\">\n {extra}\n </div>\n )}\n {children && <div className=\"mt-4 w-full\">{children}</div>}\n </div>\n );\n};\n\nexport default Result;\n"],"mappings":";;;;AAiBA,MAAM,eAAgD;CACpD,SAAS,oBAAC,OAAD,EAAO,WAAU,iBAAkB,CAAA;CAC5C,OAAO,oBAAC,UAAD,EAAU,WAAU,eAAgB,CAAA;CAC3C,MAAM,oBAAC,MAAD,EAAM,WAAU,gBAAiB,CAAA;CACvC,SAAS,oBAAC,cAAD,EAAc,WAAU,kBAAmB,CAAA;CACpD,OAAO,oBAAC,cAAD,EAAc,WAAU,wBAAyB,CAAA;CACxD,OAAO,oBAAC,aAAD,EAAa,WAAU,wBAAyB,CAAA;CACvD,OAAO,oBAAC,aAAD,EAAa,WAAU,wBAAyB,CAAA;AACzD;AAaA,MAAM,UAAU,EACd,SAAS,QACT,MACA,OACA,UACA,OACA,WACA,UACA,GAAG,YACQ;CACX,OACE,qBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,qEACA,SAEF;EACA,GAAI;EAPN,UAAA;GASE,oBAAC,OAAD;IAAK,WAAU;IAAwB,UAAA,QAAQ,aAAa;GAAa,CAAA;GACxE,SAAS,oBAAC,KAAD;IAAG,WAAU;IAAuB,UAAA;GAAS,CAAA;GACtD,YAAY,oBAAC,KAAD;IAAG,WAAU;IAAiC,UAAA;GAAY,CAAA;GACtE,SACC,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA;GAEN,YAAY,oBAAC,OAAD;IAAK,WAAU;IAAe;GAAc,CAAA;EACtD;;AAET"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ToolbarItem, ToolbarPreset } from "./components/atoms/rich-text-editor/types.mjs";
|
|
2
|
+
import RichTextEditor, { Props } from "./components/atoms/rich-text-editor/rich-text-editor.mjs";
|
|
3
|
+
export { type Props, type ToolbarItem, type ToolbarPreset, RichTextEditor as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./components/atoms/rich-text-editor/rich-text-editor.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Select as Select$1, select_d_exports } from "
|
|
2
|
-
import "
|
|
3
|
-
import { Props as Props$1 } from "./select-multiple.mjs";
|
|
4
|
-
import { Props as Props$2 } from "./select-searchable.mjs";
|
|
1
|
+
import { Select as Select$1, select_d_exports } from "./core/select.mjs";
|
|
2
|
+
import "./core/index.mjs";
|
|
3
|
+
import { Props as Props$1 } from "./components/atoms/select-multiple.mjs";
|
|
4
|
+
import { Props as Props$2 } from "./components/atoms/select-searchable.mjs";
|
|
5
5
|
import React from "react";
|
|
6
6
|
//#region src/components/atoms/select.d.ts
|
|
7
7
|
declare const Core: typeof Select$1;
|
|
@@ -26,4 +26,4 @@ export type Props = StaticProps | Props$2 | Props$1;
|
|
|
26
26
|
declare const Select: (props: Props) => React.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { Select as default };
|
|
29
|
-
//# sourceMappingURL=
|
|
29
|
+
//# sourceMappingURL=Select.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.mts","names":["select","select.Select","SearchableProps","MultipleProps"],"sources":["../src/components/atoms/select.tsx"],"mappings":";;;;;;cAWU,aAAIC;UASJ;EACR,OAAO,MAAM;EACb;EACA;;UAGQ;EACR,OAAO,MAAM;EACb,SAAS;;UAOD,oBAAoB,KAC5B,MAAM,sBAAsB;EAG5B;EACA;EACA;EACA,WAAW,SAAS;EACpB,YAAY;EACZ;;YAGU,QAAQ,cAAcC,UAAkBC;cA8D9C,SAAU,OAAO,UAAK,MAAA,IAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cn } from "
|
|
2
|
-
import { select_exports } from "
|
|
3
|
-
import MultipleSelect from "./select-multiple.mjs";
|
|
4
|
-
import SearchableSelect from "./select-searchable.mjs";
|
|
1
|
+
import { cn } from "./utils.mjs";
|
|
2
|
+
import { select_exports } from "./core/select.mjs";
|
|
3
|
+
import MultipleSelect from "./components/atoms/select-multiple.mjs";
|
|
4
|
+
import SearchableSelect from "./components/atoms/select-searchable.mjs";
|
|
5
5
|
import "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/atoms/select.tsx
|
|
@@ -40,4 +40,4 @@ const Select = (props) => {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
export { Select as default };
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=
|
|
43
|
+
//# sourceMappingURL=Select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.mjs","names":["select"],"sources":["../src/components/atoms/select.tsx"],"sourcesContent":["import React from 'react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport { select } from '../../core';\nimport MultipleSelect, { type Props as MultipleProps } from './select-multiple';\nimport SearchableSelect, {\n type Props as SearchableProps,\n} from './select-searchable';\n\nconst {\n Select: Core,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectTrigger,\n SelectValue,\n} = select;\n\ninterface Option {\n label: React.ReactNode;\n value: string;\n disabled?: boolean;\n}\n\ninterface OptionGroup {\n label: React.ReactNode;\n options: Option[];\n}\n\nconst isGroup = (option: Option | OptionGroup): option is OptionGroup => {\n return 'options' in option && Array.isArray(option.options);\n};\n\ninterface StaticProps extends Omit<\n React.ComponentProps<typeof Core>,\n 'onValueChange' | 'items'\n> {\n searchable?: false;\n placeholder?: string;\n className?: string;\n options?: (Option | OptionGroup)[];\n onChange?: (value: string) => void;\n 'aria-label'?: string;\n}\n\nexport type Props = StaticProps | SearchableProps | MultipleProps;\n\nconst StaticSelect = ({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Do not forward the public mode switch to Base UI.\n searchable: _searchable,\n className,\n placeholder,\n options,\n onChange,\n 'aria-label': ariaLabel,\n ...props\n}: StaticProps) => {\n const items = options?.flatMap(option =>\n isGroup(option) ? option.options : option,\n );\n\n return (\n <Core\n {...props}\n items={items}\n onValueChange={value => {\n if (value !== null) {\n onChange?.(value);\n }\n }}\n >\n <SelectTrigger\n aria-label={ariaLabel}\n className={cn('w-full max-w-48', className)}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options?.map((option, index) =>\n isGroup(option) ? (\n <SelectGroup key={index}>\n <SelectLabel>{option.label}</SelectLabel>\n {option.options.map(item => (\n <SelectItem\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n >\n {item.label}\n </SelectItem>\n ))}\n </SelectGroup>\n ) : (\n <SelectItem\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.label}\n </SelectItem>\n ),\n )}\n </SelectContent>\n </Core>\n );\n};\n\nconst Select = (props: Props) => {\n if (props.multiple) {\n return <MultipleSelect {...props} />;\n }\n\n if (props.searchable) {\n return <SearchableSelect {...props} />;\n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A;AACnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Skeleton$1, { Props } from "./components/atoms/skeleton/skeleton.mjs";
|
|
2
|
+
import Button from "./components/atoms/skeleton/button.mjs";
|
|
3
|
+
import Node from "./components/atoms/skeleton/node.mjs";
|
|
4
|
+
//#region src/components/atoms/skeleton/index.d.ts
|
|
5
|
+
type SkeletonComponent = typeof Skeleton$1 & {
|
|
6
|
+
Button: typeof Button;
|
|
7
|
+
Node: typeof Node;
|
|
8
|
+
};
|
|
9
|
+
declare const Skeleton: SkeletonComponent;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Button, Node, type Props, Skeleton as default };
|
|
12
|
+
//# sourceMappingURL=Skeleton.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.d.mts","names":["SkeletonImpl"],"sources":["../src/components/atoms/skeleton/index.ts"],"mappings":";;;;KAIK,2BAA2BA;EAC9B,eAAe;EACf,aAAa;;cAGT,UAA2B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Skeleton$1 from "./components/atoms/skeleton/skeleton.mjs";
|
|
2
|
+
import Button from "./components/atoms/skeleton/button.mjs";
|
|
3
|
+
import Node from "./components/atoms/skeleton/node.mjs";
|
|
4
|
+
//#region src/components/atoms/skeleton/index.ts
|
|
5
|
+
const Skeleton = Skeleton$1;
|
|
6
|
+
Skeleton.Button = Button;
|
|
7
|
+
Skeleton.Node = Node;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Button, Node, Skeleton as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=Skeleton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.mjs","names":["SkeletonImpl"],"sources":["../src/components/atoms/skeleton/index.ts"],"sourcesContent":["import Button from './button';\nimport Node from './node';\nimport SkeletonImpl, { type Props } from './skeleton';\n\ntype SkeletonComponent = typeof SkeletonImpl & {\n Button: typeof Button;\n Node: typeof Node;\n};\n\nconst Skeleton = SkeletonImpl as SkeletonComponent;\n\nSkeleton.Button = Button;\nSkeleton.Node = Node;\n\nexport { Button, Node };\nexport default Skeleton;\nexport type { Props };\n"],"mappings":";;;;AASA,MAAM,WAAWA;AAEjB,SAAS,SAAS;AAClB,SAAS,OAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Slider from "./slider.mjs";
|
|
1
|
+
import Slider from "./components/atoms/slider/slider.mjs";
|
|
2
2
|
//#region src/components/atoms/slider/index.ts
|
|
3
3
|
var slider_default = Slider;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { slider_default as default };
|
|
6
6
|
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=Slider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Slider.mjs","names":[],"sources":["../src/components/atoms/slider/index.ts"],"sourcesContent":["import Slider, { type Props, type SliderValue } from './slider';\n\nexport default Slider;\nexport type { Props, SliderValue };\n"],"mappings":";;AAEA,IAAA,iBAAe"}
|
package/dist/Space.d.mts
CHANGED
|
@@ -4,7 +4,8 @@ export interface Props extends React.ComponentPropsWithRef<'div'> {
|
|
|
4
4
|
loader?: React.ReactNode;
|
|
5
5
|
orientation?: 'horizontal' | 'vertical';
|
|
6
6
|
size?: 'small' | 'middle' | 'large' | number | number[];
|
|
7
|
-
align?: 'start' | 'end' | 'center' | 'baseline';
|
|
7
|
+
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
|
|
8
|
+
justify?: 'start' | 'end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
8
9
|
wrap?: boolean;
|
|
9
10
|
split?: React.ReactNode;
|
|
10
11
|
grid?: {
|
|
@@ -12,7 +13,7 @@ export interface Props extends React.ComponentPropsWithRef<'div'> {
|
|
|
12
13
|
cols?: number;
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
declare const Space: ({ loading, loader, children, size, orientation, align, wrap, split, className, grid, hidden, style, ...props }: Props) => import("react").JSX.Element;
|
|
16
|
+
declare const Space: ({ loading, loader, children, size, orientation, align, justify, wrap, split, className, grid, hidden, style, ...props }: Props) => import("react").JSX.Element;
|
|
16
17
|
//#endregion
|
|
17
18
|
export { Space as default };
|
|
18
19
|
//# sourceMappingURL=Space.d.mts.map
|
package/dist/Space.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Space.d.mts","names":[],"sources":["../src/components/molecules/space.tsx"],"mappings":";iBASiB,cAAc,MAAM;EACnC;EACA,SAAS,MAAM;EACf;EACA;EACA;EACA;EACA,QAAQ,MAAM;EACd;IACE;IACA;;;
|
|
1
|
+
{"version":3,"file":"Space.d.mts","names":[],"sources":["../src/components/molecules/space.tsx"],"mappings":";iBASiB,cAAc,MAAM;EACnC;EACA,SAAS,MAAM;EACf;EACA;EACA;EACA;EAOA;EACA,QAAQ,MAAM;EACd;IACE;IACA;;;cA2BE,UAAS,SAAA,QAAA,UAAA,MAAA,aAAA,OAAA,SAAA,MAAA,OAAA,WAAA,MAAA,QAAA,UAAA,SAeZ,0BAAK,IAAA"}
|
package/dist/Space.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "./utils.mjs";
|
|
3
3
|
import { useConfig } from "./providers/config/context.mjs";
|
|
4
|
-
import Skeleton from "./
|
|
4
|
+
import Skeleton from "./Skeleton.mjs";
|
|
5
5
|
import { Children } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/molecules/space.tsx
|
|
@@ -14,9 +14,18 @@ const aligns = {
|
|
|
14
14
|
start: "items-start text-start",
|
|
15
15
|
end: "items-end text-end",
|
|
16
16
|
center: "items-center text-center",
|
|
17
|
-
baseline: "items-baseline text-baseline"
|
|
17
|
+
baseline: "items-baseline text-baseline",
|
|
18
|
+
stretch: "items-stretch"
|
|
18
19
|
};
|
|
19
|
-
const
|
|
20
|
+
const justifies = {
|
|
21
|
+
start: "justify-start",
|
|
22
|
+
end: "justify-end",
|
|
23
|
+
center: "justify-center",
|
|
24
|
+
"space-between": "justify-between",
|
|
25
|
+
"space-around": "justify-around",
|
|
26
|
+
"space-evenly": "justify-evenly"
|
|
27
|
+
};
|
|
28
|
+
const Space = ({ loading, loader, children, size, orientation = "horizontal", align = "center", justify, wrap = false, split, className, grid, hidden, style, ...props }) => {
|
|
20
29
|
const { componentSize } = useConfig();
|
|
21
30
|
const resolvedSize = size ?? componentSize ?? "middle";
|
|
22
31
|
const [x, y] = typeof resolvedSize === "string" ? sizes[resolvedSize] || [0, 0] : Array.isArray(resolvedSize) ? resolvedSize : [resolvedSize, resolvedSize];
|
|
@@ -29,7 +38,7 @@ const Space = ({ loading, loader, children, size, orientation = "horizontal", al
|
|
|
29
38
|
children: loader || /* @__PURE__ */ jsx(Skeleton, {})
|
|
30
39
|
});
|
|
31
40
|
return /* @__PURE__ */ jsx("div", {
|
|
32
|
-
className: cn("flex flex-nowrap", orientation === "horizontal" ? "flex-row" : "flex-col", wrap && "flex-wrap", aligns[align], grid && "grid", hidden && "hidden", className),
|
|
41
|
+
className: cn("flex flex-nowrap", orientation === "horizontal" ? "flex-row" : "flex-col", wrap && "flex-wrap", aligns[align], justify && justifies[justify], grid && "grid", hidden && "hidden", className),
|
|
33
42
|
style: {
|
|
34
43
|
columnGap: x,
|
|
35
44
|
rowGap: y,
|
package/dist/Space.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Space.mjs","names":[],"sources":["../src/components/molecules/space.tsx"],"sourcesContent":["'use client';\n\nimport { Children } from 'react';\n\nimport { useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport Skeleton from '../atoms/skeleton';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n loading?: boolean;\n loader?: React.ReactNode;\n orientation?: 'horizontal' | 'vertical';\n size?: 'small' | 'middle' | 'large' | number | number[];\n align?: 'start' | 'end' | 'center' | 'baseline';\n wrap?: boolean;\n split?: React.ReactNode;\n grid?: {\n rows?: number;\n cols?: number;\n };\n}\n\nconst sizes: Record<string, number[]> = {\n small: [4, 4],\n middle: [8, 8],\n large: [16, 16],\n};\n\nconst aligns: Record<string, string> = {\n start: 'items-start text-start',\n end: 'items-end text-end',\n center: 'items-center text-center',\n baseline: 'items-baseline text-baseline',\n};\n\nconst Space = ({\n loading,\n loader,\n children,\n size,\n orientation = 'horizontal',\n align = 'center',\n wrap = false,\n split,\n className,\n grid,\n hidden,\n style,\n ...props\n}: Props) => {\n const { componentSize } = useConfig();\n // `size` overrides the global `componentSize` from `Config`, which in turn\n // falls back to `middle` — the same resolution order `Button` uses so a single\n // `<Config componentSize>` sizes both. Numeric/array gaps bypass the token.\n const resolvedSize = size ?? componentSize ?? 'middle';\n const [x, y] =\n typeof resolvedSize === 'string'\n ? sizes[resolvedSize] || [0, 0]\n : Array.isArray(resolvedSize)\n ? resolvedSize\n : [resolvedSize, resolvedSize];\n const count = Children.count(children);\n\n if (loading) {\n return (\n <div\n className={cn(hidden && 'hidden', className)}\n style={style}\n hidden={hidden}\n {...props}\n >\n {loader || <Skeleton />}\n </div>\n );\n }\n\n return (\n <div\n className={cn(\n 'flex flex-nowrap',\n orientation === 'horizontal' ? 'flex-row' : 'flex-col',\n wrap && 'flex-wrap',\n aligns[align],\n grid && 'grid',\n hidden && 'hidden',\n className,\n )}\n style={{\n columnGap: x,\n rowGap: y,\n gridTemplateRows: grid?.rows\n ? `repeat(${grid.rows}, minmax(0, 1fr))`\n : undefined,\n gridTemplateColumns: grid?.cols\n ? `repeat(${grid.cols}, minmax(0, 1fr))`\n : undefined,\n ...style,\n }}\n hidden={hidden}\n {...props}\n >\n {Children.map(children, (child, i) => (\n <>\n {child}\n {split && i < count - 1 && split}\n </>\n ))}\n </div>\n );\n};\n\nexport default Space;\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Space.mjs","names":[],"sources":["../src/components/molecules/space.tsx"],"sourcesContent":["'use client';\n\nimport { Children } from 'react';\n\nimport { useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport Skeleton from '../atoms/skeleton';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n loading?: boolean;\n loader?: React.ReactNode;\n orientation?: 'horizontal' | 'vertical';\n size?: 'small' | 'middle' | 'large' | number | number[];\n align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';\n justify?:\n | 'start'\n | 'end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\n wrap?: boolean;\n split?: React.ReactNode;\n grid?: {\n rows?: number;\n cols?: number;\n };\n}\n\nconst sizes: Record<string, number[]> = {\n small: [4, 4],\n middle: [8, 8],\n large: [16, 16],\n};\n\nconst aligns: Record<string, string> = {\n start: 'items-start text-start',\n end: 'items-end text-end',\n center: 'items-center text-center',\n baseline: 'items-baseline text-baseline',\n stretch: 'items-stretch',\n};\n\nconst justifies: Record<NonNullable<Props['justify']>, string> = {\n start: 'justify-start',\n end: 'justify-end',\n center: 'justify-center',\n 'space-between': 'justify-between',\n 'space-around': 'justify-around',\n 'space-evenly': 'justify-evenly',\n};\n\nconst Space = ({\n loading,\n loader,\n children,\n size,\n orientation = 'horizontal',\n align = 'center',\n justify,\n wrap = false,\n split,\n className,\n grid,\n hidden,\n style,\n ...props\n}: Props) => {\n const { componentSize } = useConfig();\n // `size` overrides the global `componentSize` from `Config`, which in turn\n // falls back to `middle` — the same resolution order `Button` uses so a single\n // `<Config componentSize>` sizes both. Numeric/array gaps bypass the token.\n const resolvedSize = size ?? componentSize ?? 'middle';\n const [x, y] =\n typeof resolvedSize === 'string'\n ? sizes[resolvedSize] || [0, 0]\n : Array.isArray(resolvedSize)\n ? resolvedSize\n : [resolvedSize, resolvedSize];\n const count = Children.count(children);\n\n if (loading) {\n return (\n <div\n className={cn(hidden && 'hidden', className)}\n style={style}\n hidden={hidden}\n {...props}\n >\n {loader || <Skeleton />}\n </div>\n );\n }\n\n return (\n <div\n className={cn(\n 'flex flex-nowrap',\n orientation === 'horizontal' ? 'flex-row' : 'flex-col',\n wrap && 'flex-wrap',\n aligns[align],\n justify && justifies[justify],\n grid && 'grid',\n hidden && 'hidden',\n className,\n )}\n style={{\n columnGap: x,\n rowGap: y,\n gridTemplateRows: grid?.rows\n ? `repeat(${grid.rows}, minmax(0, 1fr))`\n : undefined,\n gridTemplateColumns: grid?.cols\n ? `repeat(${grid.cols}, minmax(0, 1fr))`\n : undefined,\n ...style,\n }}\n hidden={hidden}\n {...props}\n >\n {Children.map(children, (child, i) => (\n <>\n {child}\n {split && i < count - 1 && split}\n </>\n ))}\n </div>\n );\n};\n\nexport default Space;\n"],"mappings":";;;;;;;AA8BA,MAAM,QAAkC;CACtC,OAAO,CAAC,GAAG,CAAC;CACZ,QAAQ,CAAC,GAAG,CAAC;CACb,OAAO,CAAC,IAAI,EAAE;AAChB;AAEA,MAAM,SAAiC;CACrC,OAAO;CACP,KAAK;CACL,QAAQ;CACR,UAAU;CACV,SAAS;AACX;AAEA,MAAM,YAA2D;CAC/D,OAAO;CACP,KAAK;CACL,QAAQ;CACR,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;AAClB;AAEA,MAAM,SAAS,EACb,SACA,QACA,UACA,MACA,cAAc,cACd,QAAQ,UACR,SACA,OAAO,OACP,OACA,WACA,MACA,QACA,OACA,GAAG,YACQ;CACX,MAAM,EAAE,kBAAkB,UAAU;CAIpC,MAAM,eAAe,QAAQ,iBAAiB;CAC9C,MAAM,CAAC,GAAG,KACR,OAAO,iBAAiB,WACpB,MAAM,iBAAiB,CAAC,GAAG,CAAC,IAC5B,MAAM,QAAQ,YAAY,IACxB,eACA,CAAC,cAAc,YAAY;CACnC,MAAM,QAAQ,SAAS,MAAM,QAAQ;CAErC,IAAI,SACF,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,UAAU,UAAU,SAAS;EACpC;EACC;EACR,GAAI;EAEH,UAAA,UAAU,oBAAC,UAAD,CAAW,CAAA;CACnB,CAAA;CAIT,OACE,oBAAC,OAAD;EACE,WAAW,GACT,oBACA,gBAAgB,eAAe,aAAa,YAC5C,QAAQ,aACR,OAAO,QACP,WAAW,UAAU,UACrB,QAAQ,QACR,UAAU,UACV,SACF;EACA,OAAO;GACL,WAAW;GACX,QAAQ;GACR,kBAAkB,MAAM,OACpB,UAAU,KAAK,KAAK,qBACpB,KAAA;GACJ,qBAAqB,MAAM,OACvB,UAAU,KAAK,KAAK,qBACpB,KAAA;GACJ,GAAG;EACL;EACQ;EACR,GAAI;EAEH,UAAA,SAAS,IAAI,WAAW,OAAO,MAC9B,qBAAA,YAAA,EAAA,UAAA,CACG,OACA,SAAS,IAAI,QAAQ,KAAK,KAC3B,EAAA,CAAA,CACH;CACE,CAAA;AAET"}
|
|
@@ -5,4 +5,4 @@ export interface Props extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
5
5
|
declare const Spin: ({ spinning, className, children, ...props }: Props) => string | number | bigint | true | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Spin as default };
|
|
8
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=Spin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spin.d.mts","names":[],"sources":["../src/components/atoms/spin.tsx"],"mappings":";iBAOiB,cAAc,MAAM;EACnC;;cAGI,SAAQ,UAAA,WAAA,aAAA,SAA6C,4CAAK,yBAAA,aAAA,6DAAA,8BAAA,+CAAA,8BAAA,yBAAA,iDAAA,IAAA"}
|