@clubmed/trident-ui 2.0.0-beta.4 → 2.0.0-beta.40
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/chunks/Carousel.context.js +1548 -0
- package/chunks/Carousel.context.js.map +1 -0
- package/chunks/ChatMessage.js +14395 -0
- package/chunks/ChatMessage.js.map +1 -0
- package/chunks/DateField.js +177 -63
- package/chunks/DateField.js.map +1 -1
- package/chunks/Tooltip.js +4461 -0
- package/chunks/Tooltip.js.map +1 -0
- package/chunks/chunk.js +11 -4
- package/chunks/client.js +18953 -0
- package/chunks/client.js.map +1 -0
- package/examples/button-demo.js +2 -2
- package/examples/button-demo.js.map +1 -1
- package/examples/chat-input-demo.d.ts +1 -0
- package/examples/chat-input-demo.js +21 -0
- package/examples/chat-input-demo.js.map +1 -0
- package/examples/chat-message-demo.d.ts +1 -0
- package/examples/chat-message-demo.js +20 -0
- package/examples/chat-message-demo.js.map +1 -0
- package/examples/chat-typing-indicator-demo.d.ts +1 -0
- package/examples/chat-typing-indicator-demo.js +14 -0
- package/examples/chat-typing-indicator-demo.js.map +1 -0
- package/examples/chat-window-demo.d.ts +1 -0
- package/examples/chat-window-demo.js +45 -0
- package/examples/chat-window-demo.js.map +1 -0
- package/examples/checkbox-demo.js +16 -20
- package/examples/checkbox-demo.js.map +1 -1
- package/examples/checkbox-select-demo.d.ts +1 -0
- package/examples/checkbox-select-demo.js +101 -0
- package/examples/checkbox-select-demo.js.map +1 -0
- package/examples/checkboxes-demo.js +6 -6
- package/examples/checkboxes-demo.js.map +1 -1
- package/examples/checkboxes-with-form-control-demo.js +4 -4
- package/examples/choice-expander-demo.js +4 -67
- package/examples/choice-expander-demo.js.map +1 -1
- package/examples/dropdown-demo.js +9 -1
- package/examples/dropdown-demo.js.map +1 -1
- package/examples/elastic-height-demo.js +2 -1
- package/examples/elastic-height-demo.js.map +1 -1
- package/examples/frame-demo.d.ts +1 -0
- package/examples/frame-demo.js +36 -0
- package/examples/frame-demo.js.map +1 -0
- package/examples/frame-horizontal-demo.d.ts +1 -0
- package/examples/frame-horizontal-demo.js +44 -0
- package/examples/frame-horizontal-demo.js.map +1 -0
- package/examples/frame-no-image-demo.d.ts +1 -0
- package/examples/frame-no-image-demo.js +47 -0
- package/examples/frame-no-image-demo.js.map +1 -0
- package/examples/frame-vertical-demo.d.ts +1 -0
- package/examples/frame-vertical-demo.js +44 -0
- package/examples/frame-vertical-demo.js.map +1 -0
- package/examples/frame-with-tag-demo.d.ts +1 -0
- package/examples/frame-with-tag-demo.js +48 -0
- package/examples/frame-with-tag-demo.js.map +1 -0
- package/examples/scrollbar-demo.d.ts +1 -0
- package/examples/scrollbar-demo.js +40 -0
- package/examples/scrollbar-demo.js.map +1 -0
- package/examples/slider-frame-demo.d.ts +1 -0
- package/examples/slider-frame-demo.js +38 -0
- package/examples/slider-frame-demo.js.map +1 -0
- package/examples/slider-frame-with-button-demo.d.ts +1 -0
- package/examples/slider-frame-with-button-demo.js +46 -0
- package/examples/slider-frame-with-button-demo.js.map +1 -0
- package/examples/slider-frame-with-tag-demo.d.ts +1 -0
- package/examples/slider-frame-with-tag-demo.js +50 -0
- package/examples/slider-frame-with-tag-demo.js.map +1 -0
- package/examples/switch-demo.js +1 -1
- package/examples/switch-demo.js.map +1 -1
- package/examples/tooltip-demo.d.ts +1 -0
- package/examples/tooltip-demo.js +103 -0
- package/examples/tooltip-demo.js.map +1 -0
- package/package.json +10 -3
- package/styles/animate.css +19 -19
- package/styles/components.css +82 -0
- package/styles/theme.css +23 -18
- package/styles/ui/button.css +19 -25
- package/styles/ui/chat-button.css +68 -1
- package/styles/ui/controls.css +9 -63
- package/styles/ui/range.css +1 -1
- package/styles/variants.css +0 -2
- package/ui/AdvancedToast.js +11 -11
- package/ui/AdvancedToast.js.map +1 -1
- package/ui/BasicToast.js +1 -1
- package/ui/BasicToast.js.map +1 -1
- package/ui/Breadcrumb.d.ts +2 -2
- package/ui/Breadcrumb.js +31 -35
- package/ui/Breadcrumb.js.map +1 -1
- package/ui/ChatButton.js +1 -1
- package/ui/ChatButton.js.map +1 -1
- package/ui/ChatInput.d.ts +10 -0
- package/ui/ChatInput.js +149 -0
- package/ui/ChatInput.js.map +1 -0
- package/ui/ChatMessage.d.ts +6 -0
- package/ui/ChatMessage.js +2 -0
- package/ui/ChatTypingIndicator.d.ts +2 -0
- package/ui/ChatTypingIndicator.js +30 -0
- package/ui/ChatTypingIndicator.js.map +1 -0
- package/ui/ChatWindow.d.ts +21 -0
- package/ui/ChatWindow.js +108 -0
- package/ui/ChatWindow.js.map +1 -0
- package/ui/ChoiceExpander.js +1 -1
- package/ui/ChoiceExpander.js.map +1 -1
- package/ui/Dropdown.d.ts +20 -3
- package/ui/Dropdown.js +57 -23
- package/ui/Dropdown.js.map +1 -1
- package/ui/ElasticHeight.d.ts +0 -1
- package/ui/ElasticHeight.js +14 -23
- package/ui/ElasticHeight.js.map +1 -1
- package/ui/Loader.d.ts +5 -4
- package/ui/Loader.js +11 -10
- package/ui/Loader.js.map +1 -1
- package/ui/Popin.js +2 -2
- package/ui/Popin.js.map +1 -1
- package/ui/Scrollbar.d.ts +14 -0
- package/ui/Scrollbar.js +68 -0
- package/ui/Scrollbar.js.map +1 -0
- package/ui/SidebarLayout.d.ts +3 -1
- package/ui/SidebarLayout.js +32 -24
- package/ui/SidebarLayout.js.map +1 -1
- package/ui/Tooltip.d.ts +8 -0
- package/ui/Tooltip.js +2 -0
- package/ui/arrows/Arrows.d.ts +1 -0
- package/ui/arrows/Arrows.js +19 -17
- package/ui/arrows/Arrows.js.map +1 -1
- package/ui/buttons/Button.type.d.ts +1 -1
- package/ui/buttons/Button.type.js.map +1 -1
- package/ui/carousel/Carousel.context.d.ts +27 -0
- package/ui/carousel/Carousel.context.js +2 -0
- package/ui/carousel/Carousel.d.ts +3 -0
- package/ui/carousel/Carousel.js +12 -0
- package/ui/carousel/Carousel.js.map +1 -0
- package/ui/carousel/CarouselBody.d.ts +6 -0
- package/ui/carousel/CarouselBody.js +21 -0
- package/ui/carousel/CarouselBody.js.map +1 -0
- package/ui/carousel/CarouselItem.d.ts +6 -0
- package/ui/carousel/CarouselItem.js +21 -0
- package/ui/carousel/CarouselItem.js.map +1 -0
- package/ui/carousel/CarouselNext.d.ts +8 -0
- package/ui/carousel/CarouselNext.js +23 -0
- package/ui/carousel/CarouselNext.js.map +1 -0
- package/ui/carousel/CarouselPrevious.d.ts +8 -0
- package/ui/carousel/CarouselPrevious.js +23 -0
- package/ui/carousel/CarouselPrevious.js.map +1 -0
- package/ui/contexts/TridentUIConfig.js +1 -1
- package/ui/forms/CheckboxSelect.d.ts +31 -0
- package/ui/forms/CheckboxSelect.js +119 -0
- package/ui/forms/CheckboxSelect.js.map +1 -0
- package/ui/forms/Filter.d.ts +8 -4
- package/ui/forms/Filter.js +23 -45
- package/ui/forms/Filter.js.map +1 -1
- package/ui/forms/FormControl.js +6 -6
- package/ui/forms/NumberField.d.ts +10 -10
- package/ui/forms/NumberField.js +8 -8
- package/ui/forms/PhoneField.d.ts +5 -10
- package/ui/forms/PhoneField.js +29 -211
- package/ui/forms/PhoneField.js.map +1 -1
- package/ui/forms/PhoneFieldFullInput.d.ts +16 -0
- package/ui/forms/PhoneFieldFullInput.js +116 -0
- package/ui/forms/PhoneFieldFullInput.js.map +1 -0
- package/ui/forms/PhoneFieldSplitInput.d.ts +19 -0
- package/ui/forms/PhoneFieldSplitInput.js +159 -0
- package/ui/forms/PhoneFieldSplitInput.js.map +1 -0
- package/ui/forms/Select.js +4 -4
- package/ui/forms/Switch.d.ts +3 -3
- package/ui/forms/Switch.js +51 -34
- package/ui/forms/Switch.js.map +1 -1
- package/ui/forms/TextField.js +4 -4
- package/ui/forms/TextField.js.map +1 -1
- package/ui/forms/checkboxes/Checkbox.d.ts +10 -12
- package/ui/forms/checkboxes/Checkbox.js +38 -55
- package/ui/forms/checkboxes/Checkbox.js.map +1 -1
- package/ui/forms/checkboxes/Checkboxes.js +2 -2
- package/ui/forms/checkboxes/Checkboxes.js.map +1 -1
- package/ui/forms/password/Password.js +4 -4
- package/ui/frame/Frame.d.ts +8 -0
- package/ui/frame/Frame.js +16 -0
- package/ui/frame/Frame.js.map +1 -0
- package/ui/frame/FrameLabelsWrapper.d.ts +5 -0
- package/ui/frame/FrameLabelsWrapper.js +12 -0
- package/ui/frame/FrameLabelsWrapper.js.map +1 -0
- package/ui/frame/FrameTitle.d.ts +7 -0
- package/ui/frame/FrameTitle.js +25 -0
- package/ui/frame/FrameTitle.js.map +1 -0
- package/ui/frame/FrameWrapper.d.ts +6 -0
- package/ui/frame/FrameWrapper.js +14 -0
- package/ui/frame/FrameWrapper.js.map +1 -0
- package/ui/frame/SliderFrame.d.ts +14 -0
- package/ui/frame/SliderFrame.js +50 -0
- package/ui/frame/SliderFrame.js.map +1 -0
- package/ui/helpers/colors/colors.d.ts +4 -0
- package/ui/helpers/colors/colors.js +6 -1
- package/ui/helpers/colors/colors.js.map +1 -1
- package/ui/helpers/phone/defaultPrefixes.js +28 -28
- package/ui/helpers/phone/defaultPrefixes.js.map +1 -1
- package/ui/helpers/phone/formatters.d.ts +11 -0
- package/ui/helpers/phone/formatters.js +32 -1
- package/ui/helpers/phone/formatters.js.map +1 -1
- package/ui/helpers/phone/index.d.ts +1 -1
- package/ui/helpers/phone/index.js +3 -3
- package/ui/hooks/useValue.js +1 -1
- package/ui/hooks/useValue.js.map +1 -1
- package/ui/tabs/Tabs.js +1 -1
- package/ui/tabs/Tabs.js.map +1 -1
- package/ui/Breadcrumb.themes.d.ts +0 -8
- package/ui/Breadcrumb.themes.js +0 -16
- package/ui/Breadcrumb.themes.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhoneFieldSplitInput.js","names":[],"sources":["../../../lib/ui/forms/PhoneFieldSplitInput.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Icon, type IconicTypes } from '@clubmed/trident-icons';\nimport {\n type ChangeEvent,\n type InputHTMLAttributes,\n type KeyboardEvent,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\nimport {\n calculateCursorPosition,\n DEFAULT_PHONE_PREFIXES,\n extractDigits,\n formatPhoneDigits,\n formatWithPattern,\n getLiteralPrefixInfo,\n type PhonePrefix,\n stripLiteralPrefix,\n} from '../helpers/phone';\nimport { useInternalStatus } from '../hooks/useInternalStatus';\nimport type { FormControlProps } from './FormControl';\nimport type { PhoneValue } from './PhoneField';\n\ntype PhoneFieldChangeHandler = (name: string, value: PhoneValue) => void;\n\nexport interface PhoneFieldSplitProps {\n prefixes?: PhonePrefix[];\n defaultPrefix?: string;\n}\n\nconst usePhoneField = (args: {\n externalValue?: PhoneValue;\n name: string;\n pattern: string;\n defaultPrefix: string;\n onChange?: PhoneFieldChangeHandler;\n}) => {\n const { externalValue, name, pattern, defaultPrefix, onChange } = args;\n const numberInputRef = useRef<HTMLInputElement>(null);\n const cursorPositionRef = useRef<number | null>(null);\n const [prefix, setPrefix] = useState(defaultPrefix);\n const [number, setNumber] = useState('');\n\n const emitChange = useCallback(\n (nextPrefix: string, nextNumber: string) => {\n if (nextPrefix === prefix && nextNumber === number) {\n return;\n }\n\n const full = `${nextPrefix} ${nextNumber}`.trim();\n\n onChange?.(name, {\n full,\n prefix: nextPrefix,\n number: nextNumber,\n raw: extractDigits(full),\n });\n },\n [name, number, onChange, prefix],\n );\n\n useEffect(() => {\n if (cursorPositionRef.current !== null && numberInputRef.current) {\n numberInputRef.current.setSelectionRange(\n cursorPositionRef.current,\n cursorPositionRef.current,\n );\n cursorPositionRef.current = null;\n }\n }, [number]);\n\n useEffect(() => {\n if (externalValue && typeof externalValue === 'object' && 'full' in externalValue) {\n setPrefix(externalValue.prefix || defaultPrefix);\n setNumber(externalValue.number || '');\n }\n }, [externalValue, defaultPrefix]);\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key !== 'Backspace' && e.key !== 'Delete') {\n return;\n }\n\n const cursorPosition = e.currentTarget.selectionStart || 0;\n const selectionEnd = e.currentTarget.selectionEnd || 0;\n\n if (cursorPosition !== selectionEnd) {\n return;\n }\n\n const { literalPrefixDigits } = getLiteralPrefixInfo(pattern);\n\n const targetChar =\n e.key === 'Backspace' ? number[cursorPosition - 1] : number[cursorPosition];\n\n if (!targetChar || /\\d/.test(targetChar)) {\n return;\n }\n\n e.preventDefault();\n\n const allDigits = stripLiteralPrefix(extractDigits(number), literalPrefixDigits);\n const digitsBeforeCursor = stripLiteralPrefix(\n extractDigits(number.substring(0, cursorPosition)),\n literalPrefixDigits,\n ).length;\n\n let newDigits: string;\n let targetCursorDigits: number;\n\n if (e.key === 'Backspace') {\n if (digitsBeforeCursor === 0) {\n return;\n }\n\n newDigits =\n allDigits.slice(0, digitsBeforeCursor - 1) + allDigits.slice(digitsBeforeCursor);\n targetCursorDigits = digitsBeforeCursor - 1;\n } else {\n if (digitsBeforeCursor >= allDigits.length) {\n return;\n }\n\n newDigits =\n allDigits.slice(0, digitsBeforeCursor) + allDigits.slice(digitsBeforeCursor + 1);\n targetCursorDigits = digitsBeforeCursor;\n }\n\n const formatted = formatWithPattern(newDigits, pattern);\n cursorPositionRef.current = calculateCursorPosition(\n targetCursorDigits,\n formatted,\n literalPrefixDigits,\n );\n\n setNumber(formatted);\n\n emitChange(prefix, formatted);\n },\n [emitChange, pattern, number, prefix],\n );\n\n const onInputChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n const formattedValue = formatPhoneDigits(\n e.target.value,\n pattern,\n e.target.selectionStart || 0,\n );\n if (!formattedValue) return;\n\n cursorPositionRef.current = formattedValue.nextCursor;\n setNumber(formattedValue.formatted);\n\n emitChange(prefix, formattedValue.formatted);\n },\n [emitChange, pattern, prefix],\n );\n\n const onPrefixChange = useCallback(\n (newPrefix: string) => {\n setPrefix(newPrefix);\n\n emitChange(newPrefix, number);\n },\n [emitChange, number],\n );\n\n return { numberInputRef, prefix, number, onKeyDown, onInputChange, onPrefixChange };\n};\n\nexport interface PhoneFieldSplitInputProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'pattern'> {\n value?: PhoneValue;\n pattern?: string;\n prefixes?: PhoneFieldSplitProps['prefixes'];\n defaultPrefix?: PhoneFieldSplitProps['defaultPrefix'];\n iconType?: IconicTypes;\n validationStatus?: FormControlProps<PhoneValue>['validationStatus'];\n onChange?: (name: string, value: PhoneValue) => void;\n}\n\nexport const PhoneFieldSplitInput = ({\n id,\n name,\n value: externalValue,\n pattern = '## ## ## ## ##',\n prefixes = DEFAULT_PHONE_PREFIXES,\n defaultPrefix = prefixes[0]?.code || '+1',\n placeholder = '',\n iconType,\n disabled = false,\n required = false,\n validationStatus = 'default',\n onChange,\n ...rest\n}: PhoneFieldSplitInputProps) => {\n const internalId = useId();\n const resolvedId = id ?? internalId;\n const resolvedName = name ?? resolvedId;\n\n const internalStatus = useInternalStatus({ isDisabled: disabled, validationStatus });\n const { numberInputRef, prefix, number, onKeyDown, onInputChange, onPrefixChange } =\n usePhoneField({\n externalValue,\n name: resolvedName,\n pattern,\n defaultPrefix,\n onChange,\n });\n\n return (\n <div className=\"flex gap-8\">\n <div\n className={clsx('relative rounded-pill z-0 w-[130px] flex-shrink-0', {\n 'bg-white': internalStatus !== 'disabled',\n 'bg-pearl border-middleGrey': internalStatus === 'disabled',\n })}\n >\n <select\n disabled={disabled}\n value={prefix}\n onChange={(e) => onPrefixChange(e.target.value)}\n className={clsx(\n 'text-b3 rounded-pill w-full border overflow-hidden px-20 py-12 font-semibold outline-none appearance-none bg-transparent',\n {\n 'border-middleGrey focus:border-black active:border-black':\n internalStatus === 'default',\n 'text-black': internalStatus !== 'disabled',\n 'bg-pearl border-middleGrey': internalStatus === 'disabled',\n 'border-red': internalStatus === 'error',\n 'border-green': internalStatus === 'success',\n 'pe-[40px]': true,\n },\n )}\n id={`${resolvedId}-prefix`}\n aria-label={`${resolvedName}-prefix`}\n >\n {(prefixes as PhonePrefix[]).map((p) => (\n <option key={p.code} value={p.code}>\n {p.label ?? p.code}\n </option>\n ))}\n </select>\n\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-end px-20 py-12 -z-1\">\n <Icon name=\"ArrowDefaultDown\" type=\"svg\" width=\"24px\" color=\"black\" />\n </div>\n </div>\n\n <div className=\"relative flex-1\">\n <input\n {...(rest as Record<string, unknown>)}\n ref={numberInputRef}\n type=\"tel\"\n disabled={disabled}\n required={required}\n value={number}\n onChange={onInputChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n className={clsx(\n 'text-b3 rounded-pill w-full border overflow-hidden px-20 py-12 font-normal outline-none',\n {\n 'border-middleGrey focus:border-black active:border-black':\n internalStatus === 'default',\n 'pe-[52px]': internalStatus === 'error' || internalStatus === 'success',\n 'bg-white text-black': internalStatus !== 'disabled',\n 'bg-pearl border-middleGrey': internalStatus === 'disabled',\n 'border-red': internalStatus === 'error',\n 'border-green': internalStatus === 'success',\n },\n )}\n aria-label={`${resolvedName}-number`}\n />\n\n <div\n className={clsx(\n 'pointer-events-none absolute inset-0 flex items-center justify-end px-20 py-12',\n {\n 'text-grey': internalStatus === 'disabled',\n 'text-red': internalStatus === 'error',\n 'text-green': internalStatus === 'success',\n },\n )}\n >\n <span className=\"flex gap-x-8\">\n {internalStatus === 'error' && (\n <Icon name=\"CrossDefault\" width=\"24px\" type={iconType} />\n )}\n {internalStatus === 'success' && (\n <Icon name=\"CheckDefault\" width=\"24px\" type={iconType} />\n )}\n </span>\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":"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"}
|
package/ui/forms/Select.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "./FormControl.js";
|
|
4
|
+
import { useValue as r } from "../hooks/useValue.js";
|
|
5
5
|
import { useId as i } from "react";
|
|
6
6
|
import { Icon as a } from "@clubmed/trident-icons";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
//#region lib/ui/forms/Select.tsx
|
|
9
9
|
var c = (c) => {
|
|
10
|
-
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", iconType: g, errorMessage: _, disabled: v = !1, required: y = !1, hideRequiredStar: b, className: x, dataTestId: S = u, onChange: C, children: w, ...T } = c, { value: E, setValue: D } =
|
|
10
|
+
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", iconType: g, errorMessage: _, disabled: v = !1, required: y = !1, hideRequiredStar: b, className: x, dataTestId: S = u, onChange: C, children: w, ...T } = c, { value: E, setValue: D } = r({
|
|
11
11
|
name: d,
|
|
12
12
|
initialValue: p,
|
|
13
13
|
onChange: C
|
|
@@ -15,7 +15,7 @@ var c = (c) => {
|
|
|
15
15
|
isDisabled: v,
|
|
16
16
|
validationStatus: h
|
|
17
17
|
});
|
|
18
|
-
return /* @__PURE__ */ o(
|
|
18
|
+
return /* @__PURE__ */ o(n, {
|
|
19
19
|
id: u,
|
|
20
20
|
className: x,
|
|
21
21
|
label: f,
|
package/ui/forms/Switch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import { Colors } from '../types/Colors';
|
|
3
|
-
export interface SwitchProps extends ComponentPropsWithoutRef<'
|
|
3
|
+
export interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'type' | 'defaultChecked'> {
|
|
4
4
|
checked: boolean;
|
|
5
5
|
color?: Colors;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare function Switch({ id, name, checked, className, color, onChange, disabled, tabIndex, children, role, ...attrs }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
package/ui/forms/Switch.js
CHANGED
|
@@ -1,42 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { t as e } from "../../chunks/clsx.js";
|
|
3
3
|
import { getBgColor as t } from "../helpers/colors/colors.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useId as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
6
|
//#region lib/ui/forms/Switch.tsx
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...c,
|
|
12
|
-
"aria-checked": i,
|
|
13
|
-
className: e(a, "rounded-pill inline-flex min-w-56 items-center p-4 align-middle transition-colors", { "bg-middleGrey": !i }, { [t(o)]: i }),
|
|
14
|
-
"data-name": "Switch",
|
|
15
|
-
onClick: l,
|
|
16
|
-
role: "switch",
|
|
17
|
-
type: "button",
|
|
18
|
-
children: /* @__PURE__ */ r("svg", {
|
|
19
|
-
className: "size-24",
|
|
20
|
-
viewBox: "0 0 24 24",
|
|
21
|
-
children: [
|
|
22
|
-
/* @__PURE__ */ n("circle", {
|
|
23
|
-
className: "fill-white",
|
|
24
|
-
cx: 12,
|
|
25
|
-
cy: 12,
|
|
26
|
-
r: 12
|
|
27
|
-
}),
|
|
28
|
-
/* @__PURE__ */ n("circle", {
|
|
29
|
-
className: "fill-middleGrey",
|
|
30
|
-
cx: 12,
|
|
31
|
-
cy: 12,
|
|
32
|
-
r: 4
|
|
33
|
-
}),
|
|
34
|
-
/* @__PURE__ */ n("path", { d: "M18.73 6c.35 0 .68.14.9.37.5.5.5 1.35 0 1.85l-8.54 8.75q-.37.38-.9.38t-.9-.38l-4.91-5.02a1.33 1.33 0 0 1 0-1.85 1.26 1.26 0 0 1 1.8 0l4.01 4.09 7.64-7.82c.23-.24.56-.37.9-.37" })
|
|
35
|
-
]
|
|
36
|
-
})
|
|
7
|
+
function a({ id: a, name: o, checked: s, className: c, color: l = "saffron", onChange: u, disabled: d = !1, tabIndex: f = 0, children: p, role: m = "switch", ...h }) {
|
|
8
|
+
let g = n(), _ = a ?? g, v = o ?? _, y = p != null, b = e("inline-flex items-center relative", {
|
|
9
|
+
"gap-4": y,
|
|
10
|
+
"cursor-pointer": !d,
|
|
11
|
+
"cursor-not-allowed": d
|
|
37
12
|
});
|
|
38
|
-
|
|
13
|
+
return /* @__PURE__ */ i(y ? "label" : "span", {
|
|
14
|
+
htmlFor: _,
|
|
15
|
+
className: b,
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ r("input", {
|
|
18
|
+
...h,
|
|
19
|
+
id: _,
|
|
20
|
+
name: v,
|
|
21
|
+
checked: s,
|
|
22
|
+
"data-name": "Switch",
|
|
23
|
+
disabled: d,
|
|
24
|
+
role: m,
|
|
25
|
+
tabIndex: f,
|
|
26
|
+
type: "checkbox",
|
|
27
|
+
className: "absolute opacity-0 left-0 w-full top-0 m-0 p-0 z-1 h-full",
|
|
28
|
+
onChange: u
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ r("span", {
|
|
31
|
+
className: e(c, "rounded-pill inline-flex min-w-56 items-center p-4 align-middle transition-colors", { "bg-middleGrey": !s }, { [t(l)]: s }),
|
|
32
|
+
children: /* @__PURE__ */ r("svg", {
|
|
33
|
+
className: "size-24",
|
|
34
|
+
viewBox: "0 0 24 24",
|
|
35
|
+
children: /* @__PURE__ */ i("g", { children: [
|
|
36
|
+
/* @__PURE__ */ r("circle", {
|
|
37
|
+
cx: 12,
|
|
38
|
+
cy: 12,
|
|
39
|
+
r: 12,
|
|
40
|
+
fill: "var(--color-white)"
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ r("circle", {
|
|
43
|
+
cx: 12,
|
|
44
|
+
cy: 12,
|
|
45
|
+
r: 4,
|
|
46
|
+
fill: "var(--color-middleGrey)"
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ r("path", { d: "M18.73 6c.35 0 .68.14.9.37.5.5.5 1.35 0 1.85l-8.54 8.75q-.37.38-.9.38t-.9-.38l-4.91-5.02a1.33 1.33 0 0 1 0-1.85 1.26 1.26 0 0 1 1.8 0l4.01 4.09 7.64-7.82c.23-.24.56-.37.9-.37" })
|
|
49
|
+
] })
|
|
50
|
+
})
|
|
51
|
+
}),
|
|
52
|
+
p
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
39
56
|
//#endregion
|
|
40
|
-
export {
|
|
57
|
+
export { a as Switch };
|
|
41
58
|
|
|
42
59
|
//# sourceMappingURL=Switch.js.map
|
package/ui/forms/Switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","names":[],"sources":["../../../lib/ui/forms/Switch.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type
|
|
1
|
+
{"version":3,"file":"Switch.js","names":[],"sources":["../../../lib/ui/forms/Switch.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { type ComponentPropsWithoutRef, useId } from 'react';\n\nimport { getBgColor } from '../helpers/colors/colors';\nimport type { Colors } from '../types/Colors';\n\nexport interface SwitchProps\n extends Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'type' | 'defaultChecked'> {\n checked: boolean;\n color?: Colors;\n}\n\nexport function Switch({\n id,\n name,\n checked,\n className,\n color = 'saffron',\n onChange,\n disabled = false,\n tabIndex = 0,\n children,\n role = 'switch',\n ...attrs\n}: SwitchProps) {\n const internalId = useId();\n const inputId = id ?? internalId;\n const inputName = name ?? inputId;\n const hasChildren = children !== undefined && children !== null;\n const rootClassName = clsx('inline-flex items-center relative', {\n 'gap-4': hasChildren,\n 'cursor-pointer': !disabled,\n 'cursor-not-allowed': disabled,\n });\n const Node = hasChildren ? 'label' : 'span';\n\n return (\n <Node htmlFor={inputId} className={rootClassName}>\n <input\n {...attrs}\n id={inputId}\n name={inputName}\n checked={checked}\n data-name=\"Switch\"\n disabled={disabled}\n role={role}\n tabIndex={tabIndex}\n type=\"checkbox\"\n className=\"absolute opacity-0 left-0 w-full top-0 m-0 p-0 z-1 h-full\"\n onChange={onChange}\n />\n\n <span\n className={clsx(\n className,\n 'rounded-pill inline-flex min-w-56 items-center p-4 align-middle transition-colors',\n { 'bg-middleGrey': !checked },\n { [getBgColor(color)]: checked },\n )}\n >\n <svg className=\"size-24\" viewBox=\"0 0 24 24\">\n <g>\n <circle cx={12} cy={12} r={12} fill=\"var(--color-white)\" />\n <circle cx={12} cy={12} r={4} fill=\"var(--color-middleGrey)\" />\n <path d=\"M18.73 6c.35 0 .68.14.9.37.5.5.5 1.35 0 1.85l-8.54 8.75q-.37.38-.9.38t-.9-.38l-4.91-5.02a1.33 1.33 0 0 1 0-1.85 1.26 1.26 0 0 1 1.8 0l4.01 4.09 7.64-7.82c.23-.24.56-.37.9-.37\" />\n </g>\n </svg>\n </span>\n {children}\n </Node>\n );\n}\n"],"mappings":";;;;;;AAcA,SAAgB,EAAO,EACrB,OACA,SACA,YACA,cACA,WAAQ,WACR,aACA,cAAW,IACX,cAAW,GACX,aACA,UAAO,UACP,GAAG,KACW;CACd,IAAM,IAAa,GAAO,EACpB,IAAU,KAAM,GAChB,IAAY,KAAQ,GACpB,IAAc,KAAuC,MACrD,IAAgB,EAAK,qCAAqC;EAC9D,SAAS;EACT,kBAAkB,CAAC;EACnB,sBAAsB;EACvB,CAAC;AAGF,QACE,kBAHW,IAAc,UAAU,QAGnC;EAAM,SAAS;EAAS,WAAW;YAAnC;GACE,kBAAC,SAAD;IACE,GAAI;IACJ,IAAI;IACJ,MAAM;IACG;IACT,aAAU;IACA;IACJ;IACI;IACV,MAAK;IACL,WAAU;IACA;IACV,CAAA;GAEF,kBAAC,QAAD;IACE,WAAW,EACT,GACA,qFACA,EAAE,iBAAiB,CAAC,GAAS,EAC7B,GAAG,EAAW,EAAM,GAAG,GAAS,CACjC;cAED,kBAAC,OAAD;KAAK,WAAU;KAAU,SAAQ;eAC/B,kBAAC,KAAD,EAAA,UAAA;MACE,kBAAC,UAAD;OAAQ,IAAI;OAAI,IAAI;OAAI,GAAG;OAAI,MAAK;OAAuB,CAAA;MAC3D,kBAAC,UAAD;OAAQ,IAAI;OAAI,IAAI;OAAI,GAAG;OAAG,MAAK;OAA4B,CAAA;MAC/D,kBAAC,QAAD,EAAM,GAAE,kLAAmL,CAAA;MACzL,EAAA,CAAA;KACA,CAAA;IACD,CAAA;GACN"}
|
package/ui/forms/TextField.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "./FormControl.js";
|
|
4
|
+
import { useValue as r } from "../hooks/useValue.js";
|
|
5
5
|
import { useId as i } from "react";
|
|
6
6
|
import { Icon as a } from "@clubmed/trident-icons";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
//#region lib/ui/forms/TextField.tsx
|
|
9
9
|
var c = (c) => {
|
|
10
|
-
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", icon: g, iconType: _, errorMessage: v, disabled: y = !1, required: b = !1, hideRequiredStar: x, className: S, dataTestId: C = "TextField", hasDropdown: w = !
|
|
10
|
+
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", icon: g, iconType: _, errorMessage: v, disabled: y = !1, required: b = !1, hideRequiredStar: x, className: S, dataTestId: C = "TextField", hasDropdown: w = !1, clear: T = "", iconFirst: E = !0, onChange: D, formatter: O, ...k } = c, { value: A, setValue: j } = r({
|
|
11
11
|
name: d,
|
|
12
12
|
initialValue: p,
|
|
13
13
|
onChange: D,
|
|
@@ -16,7 +16,7 @@ var c = (c) => {
|
|
|
16
16
|
isDisabled: y,
|
|
17
17
|
validationStatus: h
|
|
18
18
|
}), N = !y && A !== "" && A != null && !!T;
|
|
19
|
-
return /* @__PURE__ */ o(
|
|
19
|
+
return /* @__PURE__ */ o(n, {
|
|
20
20
|
id: u,
|
|
21
21
|
label: f,
|
|
22
22
|
className: S,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":[],"sources":["../../../lib/ui/forms/TextField.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useValue, type UseValueProps } from '../hooks/useValue';\nimport { useInternalStatus } from '../hooks/useInternalStatus';\nimport { FormControl, type FormControlProps } from './FormControl';\nimport { Icon, type IconicNames, type IconicTypes } from '@clubmed/trident-icons';\nimport { useId } from 'react';\n\nexport interface TextFieldProps<Value> extends FormControlProps<Value> {\n description?: string;\n icon?: IconicNames;\n iconType?: IconicTypes;\n errorMessage?: string;\n dataTestId?: string;\n formatter?: UseValueProps<Value>['formatter'];\n hasDropdown?: boolean;\n clear?: string;\n iconFirst?: boolean;\n}\n\nexport const TextField = <Value = string,>(props: TextFieldProps<Value>) => {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n label,\n value: initialValue,\n description,\n validationStatus = 'default',\n icon,\n iconType,\n errorMessage,\n disabled = false,\n required = false,\n hideRequiredStar,\n className,\n dataTestId = 'TextField',\n hasDropdown =
|
|
1
|
+
{"version":3,"file":"TextField.js","names":[],"sources":["../../../lib/ui/forms/TextField.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useValue, type UseValueProps } from '../hooks/useValue';\nimport { useInternalStatus } from '../hooks/useInternalStatus';\nimport { FormControl, type FormControlProps } from './FormControl';\nimport { Icon, type IconicNames, type IconicTypes } from '@clubmed/trident-icons';\nimport { useId } from 'react';\n\nexport interface TextFieldProps<Value> extends FormControlProps<Value> {\n description?: string;\n icon?: IconicNames;\n iconType?: IconicTypes;\n errorMessage?: string;\n dataTestId?: string;\n formatter?: UseValueProps<Value>['formatter'];\n hasDropdown?: boolean;\n clear?: string;\n iconFirst?: boolean;\n}\n\nexport const TextField = <Value = string,>(props: TextFieldProps<Value>) => {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n label,\n value: initialValue,\n description,\n validationStatus = 'default',\n icon,\n iconType,\n errorMessage,\n disabled = false,\n required = false,\n hideRequiredStar,\n className,\n dataTestId = 'TextField',\n hasDropdown = false,\n clear = '',\n iconFirst = true,\n onChange,\n formatter,\n ...rest\n } = props;\n\n const { value, setValue } = useValue<Value>({ name, initialValue, onChange, formatter });\n const internalStatus = useInternalStatus({\n isDisabled: disabled,\n validationStatus,\n });\n\n const shouldDisplayClearButton =\n !disabled && value !== '' && value !== null && value !== undefined && !!clear;\n\n return (\n <FormControl\n id={id}\n label={label}\n className={className}\n description={description}\n dataName=\"TextField\"\n dataTestId={dataTestId}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n validationStatus={validationStatus}\n errorMessage={errorMessage}\n >\n <div className=\"relative\">\n <input\n {...rest}\n id={id}\n name={name}\n disabled={disabled}\n required={required}\n value={value as any}\n onChange={(e) => setValue(e.target.value as Value)}\n style={\n {\n '--nbIconsStart': Number(!!icon && iconFirst),\n '--nbIconsEnd':\n Number(!!icon && !iconFirst) +\n Number(shouldDisplayClearButton || hasDropdown) +\n Number(internalStatus === 'error' || internalStatus === 'success'),\n } as React.CSSProperties\n }\n className={clsx(\n 'text-b3 rounded-pill w-full border overflow-hidden px-20 py-12 font-normal outline-none ps-[calc(20px+var(--nbIconsStart)*32px)] pe-[calc(20px+var(--nbIconsEnd)*32px)]',\n {\n 'border-middleGrey focus:border-black active:border-black':\n internalStatus === 'default',\n 'bg-white text-black': internalStatus !== 'disabled',\n 'bg-pearl border-middleGrey': internalStatus === 'disabled',\n 'border-red': internalStatus === 'error',\n 'border-green': internalStatus === 'success',\n },\n )}\n aria-label={name}\n />\n\n <div\n className={clsx(\n 'pointer-events-none absolute inset-0 flex items-center justify-between px-20 py-12',\n {\n 'text-grey': internalStatus === 'disabled',\n 'text-red': internalStatus === 'error',\n 'text-green': internalStatus === 'success',\n },\n )}\n >\n {icon && iconFirst && <Icon name={icon} width=\"24px\" />}\n\n <span className=\"ms-auto flex gap-x-8\">\n {internalStatus === 'error' && (\n <Icon name=\"CrossDefault\" width=\"24px\" type={iconType} />\n )}\n\n {internalStatus === 'success' && (\n <Icon name=\"CheckDefault\" width=\"24px\" type={iconType} />\n )}\n {(hasDropdown || shouldDisplayClearButton) &&\n (shouldDisplayClearButton ? (\n <button\n className=\"pointer-events-auto\"\n onClick={() => setValue('' as Value)}\n aria-label={clear}\n type=\"reset\"\n >\n <Icon name=\"CrossDefault\" className=\"text-black\" width=\"24px\" />\n </button>\n ) : (\n <Icon name=\"ArrowDefaultDown\" className=\"text-black\" width=\"24px\" />\n ))}\n {!iconFirst && icon && <Icon name={icon} width=\"24px\" />}\n </span>\n </div>\n </div>\n </FormControl>\n );\n};\n"],"mappings":";;;;;;;;AAmBA,IAAa,KAA8B,MAAiC;CAC1E,IAAM,IAAa,GAAO,EAEpB,EACJ,QAAK,GACL,UAAO,GACP,UACA,OAAO,GACP,gBACA,sBAAmB,WACnB,SACA,aACA,iBACA,cAAW,IACX,cAAW,IACX,qBACA,cACA,gBAAa,aACb,iBAAc,IACd,WAAQ,IACR,eAAY,IACZ,aACA,cACA,GAAG,MACD,GAEE,EAAE,UAAO,gBAAa,EAAgB;EAAE;EAAM;EAAc;EAAU;EAAW,CAAC,EAClF,IAAiB,EAAkB;EACvC,YAAY;EACZ;EACD,CAAC,EAEI,IACJ,CAAC,KAAY,MAAU,MAAM,KAAU,QAA+B,CAAC,CAAC;AAE1E,QACE,kBAAC,GAAD;EACM;EACG;EACI;EACE;EACb,UAAS;EACG;EACF;EACA;EACQ;EACA;EACJ;YAEd,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,SAAD;IACE,GAAI;IACA;IACE;IACI;IACA;IACH;IACP,WAAW,MAAM,EAAS,EAAE,OAAO,MAAe;IAClD,OACE;KACE,kBAAkB,OAAO,CAAC,CAAC,KAAQ,EAAU;KAC7C,gBACE,OAAO,CAAC,CAAC,KAAQ,CAAC,EAAU,GAC5B,OAAO,KAA4B,EAAY,GAC/C,OAAO,MAAmB,WAAW,MAAmB,UAAU;KACrE;IAEH,WAAW,EACT,2KACA;KACE,4DACE,MAAmB;KACrB,uBAAuB,MAAmB;KAC1C,8BAA8B,MAAmB;KACjD,cAAc,MAAmB;KACjC,gBAAgB,MAAmB;KACpC,CACF;IACD,cAAY;IACZ,CAAA,EAEF,kBAAC,OAAD;IACE,WAAW,EACT,sFACA;KACE,aAAa,MAAmB;KAChC,YAAY,MAAmB;KAC/B,cAAc,MAAmB;KAClC,CACF;cARH,CAUG,KAAQ,KAAa,kBAAC,GAAD;KAAM,MAAM;KAAM,OAAM;KAAS,CAAA,EAEvD,kBAAC,QAAD;KAAM,WAAU;eAAhB;MACG,MAAmB,WAClB,kBAAC,GAAD;OAAM,MAAK;OAAe,OAAM;OAAO,MAAM;OAAY,CAAA;MAG1D,MAAmB,aAClB,kBAAC,GAAD;OAAM,MAAK;OAAe,OAAM;OAAO,MAAM;OAAY,CAAA;OAEzD,KAAe,OACd,IACC,kBAAC,UAAD;OACE,WAAU;OACV,eAAe,EAAS,GAAY;OACpC,cAAY;OACZ,MAAK;iBAEL,kBAAC,GAAD;QAAM,MAAK;QAAe,WAAU;QAAa,OAAM;QAAS,CAAA;OACzD,CAAA,GAET,kBAAC,GAAD;OAAM,MAAK;OAAmB,WAAU;OAAa,OAAM;OAAS,CAAA;MAEvE,CAAC,KAAa,KAAQ,kBAAC,GAAD;OAAM,MAAM;OAAM,OAAM;OAAS,CAAA;MACnD;OACH;MACF;;EACM,CAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
validationStatus?: FormControlProps['validationStatus'];
|
|
12
|
-
errorMessage?: FormControlProps['errorMessage'];
|
|
1
|
+
import { ComponentPropsWithoutRef, Ref } from 'react';
|
|
2
|
+
import { Colors } from '../../types/Colors';
|
|
3
|
+
import { ValidationStatus } from '../../hooks/useInternalStatus';
|
|
4
|
+
export interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size'> {
|
|
5
|
+
color?: Colors;
|
|
6
|
+
size?: string;
|
|
7
|
+
validationStatus?: ValidationStatus;
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
['data-testid']?: string;
|
|
10
|
+
ref?: Ref<HTMLInputElement>;
|
|
13
11
|
}
|
|
14
12
|
export declare function Checkbox(props: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,63 +1,46 @@
|
|
|
1
1
|
import { t as e } from "../../../chunks/clsx.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { getBorderColor as t, getTextColor as n } from "../../helpers/colors/colors.js";
|
|
3
|
+
import { FormControlError as r } from "../FormControlError.js";
|
|
4
|
+
import { useInternalStatus as i } from "../../hooks/useInternalStatus.js";
|
|
5
|
+
import { useId as a } from "react";
|
|
6
|
+
import { Icon as o } from "@clubmed/trident-icons";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
8
|
//#region lib/ui/forms/checkboxes/Checkbox.tsx
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
isDisabled:
|
|
10
|
-
validationStatus:
|
|
11
|
-
}),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
disabled: d
|
|
31
|
-
}), /* @__PURE__ */ i("span", {
|
|
32
|
-
style: {
|
|
33
|
-
height: f,
|
|
34
|
-
width: f
|
|
35
|
-
},
|
|
36
|
-
className: e({
|
|
37
|
-
"!border-red": y === "error",
|
|
38
|
-
"bg-pearl": y === "disabled"
|
|
39
|
-
}),
|
|
40
|
-
"data-testid": `check-container-${c}`,
|
|
41
|
-
children: /* @__PURE__ */ i(r, {
|
|
42
|
-
name: "CheckDefault",
|
|
43
|
-
type: "svg",
|
|
44
|
-
width: `${f}px`,
|
|
45
|
-
color: "black",
|
|
46
|
-
className: "absolute"
|
|
47
|
-
})
|
|
48
|
-
})]
|
|
49
|
-
}), g]
|
|
50
|
-
}), b && /* @__PURE__ */ a("span", {
|
|
51
|
-
className: "text-red text-b4 flex items-start space-x-4 ps-20",
|
|
52
|
-
role: "alert",
|
|
53
|
-
children: [/* @__PURE__ */ i(r, {
|
|
54
|
-
name: "Error",
|
|
55
|
-
width: "20px"
|
|
56
|
-
}), h]
|
|
9
|
+
function l(l) {
|
|
10
|
+
let u = a(), { id: d = u, name: f = d, className: p, color: m = "black", size: h = "size-24", disabled: g = !1, tabIndex: _ = 0, validationStatus: v = "default", errorMessage: y, children: b, ref: x, "data-testid": S, ...C } = l, w = i({
|
|
11
|
+
isDisabled: g,
|
|
12
|
+
validationStatus: v
|
|
13
|
+
}), T = w === "disabled", E = w === "error" && y, D = e({
|
|
14
|
+
"!border-red !text-red": w === "error",
|
|
15
|
+
"bg-pearl": T
|
|
16
|
+
}), O = /* @__PURE__ */ c("span", {
|
|
17
|
+
className: e("rounded-8 inline-flex shrink-0 items-center justify-center self-start border transition-colors hover:!border-current/60 focus-visible:!border-current/60", t(m), n(m), h, D, p),
|
|
18
|
+
"data-name": "Checkbox",
|
|
19
|
+
children: [/* @__PURE__ */ s("input", {
|
|
20
|
+
...C,
|
|
21
|
+
disabled: g,
|
|
22
|
+
id: d,
|
|
23
|
+
name: f,
|
|
24
|
+
className: "peer sr-only",
|
|
25
|
+
ref: x,
|
|
26
|
+
tabIndex: _,
|
|
27
|
+
type: "checkbox"
|
|
28
|
+
}), /* @__PURE__ */ s(o, {
|
|
29
|
+
className: "scale-1/2 transition-[transform,opacity] peer-checked:scale-auto opacity-0 peer-checked:opacity-100",
|
|
30
|
+
name: "CheckDefault",
|
|
31
|
+
width: "100%"
|
|
57
32
|
})]
|
|
58
33
|
});
|
|
34
|
+
return !b && !y ? O : /* @__PURE__ */ c("div", {
|
|
35
|
+
className: e("flex flex-col space-y-2", p),
|
|
36
|
+
"data-testid": S || `checkbox-container-${d}`,
|
|
37
|
+
children: [/* @__PURE__ */ c("label", {
|
|
38
|
+
className: e("relative flex items-center gap-8", { "text-grey": g }),
|
|
39
|
+
children: [O, b]
|
|
40
|
+
}), E && /* @__PURE__ */ s(r, { children: y })]
|
|
41
|
+
});
|
|
59
42
|
}
|
|
60
43
|
//#endregion
|
|
61
|
-
export {
|
|
44
|
+
export { l as Checkbox };
|
|
62
45
|
|
|
63
46
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../../../lib/ui/forms/checkboxes/Checkbox.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useId } from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../../../lib/ui/forms/checkboxes/Checkbox.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useId, type ComponentPropsWithoutRef, type Ref } from 'react';\nimport { Icon } from '@clubmed/trident-icons';\nimport type { Colors } from '../../types/Colors';\nimport { getBorderColor, getTextColor } from '../../helpers/colors/colors';\nimport { FormControlError } from '@/ui/forms/FormControlError';\nimport { useInternalStatus, type ValidationStatus } from '@/ui/hooks/useInternalStatus';\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size'> {\n color?: Colors;\n size?: string;\n validationStatus?: ValidationStatus;\n errorMessage?: string;\n ['data-testid']?: string;\n ref?: Ref<HTMLInputElement>;\n}\n\nexport function Checkbox(props: CheckboxProps) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n className,\n color = 'black',\n size = 'size-24',\n disabled = false,\n tabIndex = 0,\n validationStatus = 'default',\n errorMessage,\n children,\n ref,\n 'data-testid': dataTestId,\n ...rest\n } = props;\n\n const internalStatus = useInternalStatus({\n isDisabled: disabled,\n validationStatus,\n });\n const isDisabled = internalStatus === 'disabled';\n\n const shouldDisplayErrorMessage = internalStatus === 'error' && errorMessage;\n\n // Apply validation styling to checkbox via className\n const checkboxClassName = clsx({\n '!border-red !text-red': internalStatus === 'error',\n 'bg-pearl': isDisabled,\n });\n\n const checkbox = (\n <span\n className={clsx(\n 'rounded-8 inline-flex shrink-0 items-center justify-center self-start border transition-colors hover:!border-current/60 focus-visible:!border-current/60',\n getBorderColor(color),\n getTextColor(color),\n size,\n checkboxClassName,\n className,\n )}\n data-name=\"Checkbox\"\n >\n <input\n {...rest}\n disabled={disabled}\n id={id}\n name={name}\n className=\"peer sr-only\"\n ref={ref}\n tabIndex={tabIndex}\n type=\"checkbox\"\n />\n <Icon\n className=\"scale-1/2 transition-[transform,opacity] peer-checked:scale-auto opacity-0 peer-checked:opacity-100\"\n name=\"CheckDefault\"\n width=\"100%\"\n />\n </span>\n );\n\n if (!children && !errorMessage) {\n return checkbox;\n }\n\n return (\n <div\n className={clsx('flex flex-col space-y-2', className)}\n data-testid={dataTestId || `checkbox-container-${id}`}\n >\n <label\n className={clsx('relative flex items-center gap-8', {\n 'text-grey': disabled,\n })}\n >\n {checkbox}\n {children}\n </label>\n {shouldDisplayErrorMessage && <FormControlError>{errorMessage}</FormControlError>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAiBA,SAAgB,EAAS,GAAsB;CAC7C,IAAM,IAAa,GAAO,EAEpB,EACJ,QAAK,GACL,UAAO,GACP,cACA,WAAQ,SACR,UAAO,WACP,cAAW,IACX,cAAW,GACX,sBAAmB,WACnB,iBACA,aACA,QACA,eAAe,GACf,GAAG,MACD,GAEE,IAAiB,EAAkB;EACvC,YAAY;EACZ;EACD,CAAC,EACI,IAAa,MAAmB,YAEhC,IAA4B,MAAmB,WAAW,GAG1D,IAAoB,EAAK;EAC7B,yBAAyB,MAAmB;EAC5C,YAAY;EACb,CAAC,EAEI,IACJ,kBAAC,QAAD;EACE,WAAW,EACT,4JACA,EAAe,EAAM,EACrB,EAAa,EAAM,EACnB,GACA,GACA,EACD;EACD,aAAU;YATZ,CAWE,kBAAC,SAAD;GACE,GAAI;GACM;GACN;GACE;GACN,WAAU;GACL;GACK;GACV,MAAK;GACL,CAAA,EACF,kBAAC,GAAD;GACE,WAAU;GACV,MAAK;GACL,OAAM;GACN,CAAA,CACG;;AAOT,QAJI,CAAC,KAAY,CAAC,IACT,IAIP,kBAAC,OAAD;EACE,WAAW,EAAK,2BAA2B,EAAU;EACrD,eAAa,KAAc,sBAAsB;YAFnD,CAIE,kBAAC,SAAD;GACE,WAAW,EAAK,oCAAoC,EAClD,aAAa,GACd,CAAC;aAHJ,CAKG,GACA,EACK;MACP,KAA6B,kBAAC,GAAD,EAAA,UAAmB,GAAgC,CAAA,CAC7E"}
|
|
@@ -29,8 +29,8 @@ function s(s) {
|
|
|
29
29
|
tabIndex: _ + n + 1,
|
|
30
30
|
className: e(t.props.className || "mt-8 first:mt-0"),
|
|
31
31
|
checked: y.includes(i),
|
|
32
|
-
onChange(e
|
|
33
|
-
b(
|
|
32
|
+
onChange(e) {
|
|
33
|
+
e.target.checked ? b(y.concat(i)) : b(y.filter((e) => e !== i));
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkboxes.js","names":[],"sources":["../../../../lib/ui/forms/checkboxes/Checkboxes.tsx"],"sourcesContent":["import { Children, cloneElement, type HTMLAttributes, isValidElement, useId } from 'react';\nimport type { FormControlProps } from '../FormControl';\nimport { useValue } from '../../hooks/useValue';\nimport type { CheckboxProps } from './Checkbox';\nimport clsx from 'clsx';\n\nexport interface CheckboxesProps<Value = string>\n extends Pick<\n FormControlProps<Value[]>,\n | 'id'\n | 'name'\n | 'value'\n | 'onChange'\n | 'disabled'\n | 'readOnly'\n | 'tabIndex'\n | 'description'\n | 'validationStatus'\n | 'errorMessage'\n >,\n Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {}\n\nexport function Checkboxes<Value = string>(props: CheckboxesProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n children,\n value: initialValue,\n defaultValue,\n onChange,\n disabled,\n readOnly,\n tabIndex = 0,\n ...rest\n } = props;\n\n const { value, setValue } = useValue<Value[]>({\n name,\n initialValue,\n formatter(value) {\n return value !== undefined ? ([].concat(value as never) as Value[]) : value;\n },\n defaultValue: (defaultValue as Value[]) || ([] as Value[]),\n onChange,\n });\n\n return (\n <div {...rest} className={rest.className} role=\"listbox\">\n {Children.map(children, (child, index) => {\n if (isValidElement(child)) {\n const propValue = (child.props as CheckboxProps).value as Value;\n\n return cloneElement(child, {\n ...(child.props as any),\n name,\n id: `${id}-${index}`,\n disabled,\n readOnly,\n tabIndex: tabIndex + index + 1,\n className: clsx((child.props as any).className || 'mt-8 first:mt-0'),\n checked: value.includes(propValue),\n onChange(
|
|
1
|
+
{"version":3,"file":"Checkboxes.js","names":[],"sources":["../../../../lib/ui/forms/checkboxes/Checkboxes.tsx"],"sourcesContent":["import { Children, cloneElement, type HTMLAttributes, isValidElement, useId } from 'react';\nimport type { FormControlProps } from '../FormControl';\nimport { useValue } from '../../hooks/useValue';\nimport type { CheckboxProps } from './Checkbox';\nimport clsx from 'clsx';\n\nexport interface CheckboxesProps<Value = string>\n extends Pick<\n FormControlProps<Value[]>,\n | 'id'\n | 'name'\n | 'value'\n | 'onChange'\n | 'disabled'\n | 'readOnly'\n | 'tabIndex'\n | 'description'\n | 'validationStatus'\n | 'errorMessage'\n >,\n Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {}\n\nexport function Checkboxes<Value = string>(props: CheckboxesProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n children,\n value: initialValue,\n defaultValue,\n onChange,\n disabled,\n readOnly,\n tabIndex = 0,\n ...rest\n } = props;\n\n const { value, setValue } = useValue<Value[]>({\n name,\n initialValue,\n formatter(value) {\n return value !== undefined ? ([].concat(value as never) as Value[]) : value;\n },\n defaultValue: (defaultValue as Value[]) || ([] as Value[]),\n onChange,\n });\n\n return (\n <div {...rest} className={rest.className} role=\"listbox\">\n {Children.map(children, (child, index) => {\n if (isValidElement(child)) {\n const propValue: Value = (child.props as CheckboxProps).value as Value;\n\n return cloneElement(child, {\n ...(child.props as any),\n name,\n id: `${id}-${index}`,\n disabled,\n readOnly,\n tabIndex: tabIndex + index + 1,\n className: clsx((child.props as any).className || 'mt-8 first:mt-0'),\n checked: value.includes(propValue),\n onChange(e: React.ChangeEvent<HTMLInputElement>) {\n if (e.target.checked) {\n setValue(value.concat(propValue));\n } else {\n setValue(value.filter((v) => v !== propValue));\n }\n },\n } as CheckboxProps);\n }\n\n return child;\n })}\n </div>\n );\n}\n"],"mappings":";;;;;AAsBA,SAAgB,EAA2B,GAA+B;CACxE,IAAM,IAAa,GAAO,EAEpB,EACJ,QAAK,GACL,UAAO,GACP,aACA,OAAO,GACP,iBACA,aACA,aACA,aACA,cAAW,GACX,GAAG,MACD,GAEE,EAAE,UAAO,gBAAa,EAAkB;EAC5C;EACA;EACA,UAAU,GAAO;AACf,UAAO,MAAU,KAAA,IAAqD,IAAxC,EAAE,CAAC,OAAO,EAAe;;EAEzD,cAAe,KAA6B,EAAE;EAC9C;EACD,CAAC;AAEF,QACE,kBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,EAAK;EAAW,MAAK;YAC5C,EAAS,IAAI,IAAW,GAAO,MAAU;AACxC,OAAI,EAAe,EAAM,EAAE;IACzB,IAAM,IAAoB,EAAM,MAAwB;AAExD,WAAO,EAAa,GAAO;KACzB,GAAI,EAAM;KACV;KACA,IAAI,GAAG,EAAG,GAAG;KACb;KACA;KACA,UAAU,IAAW,IAAQ;KAC7B,WAAW,EAAM,EAAM,MAAc,aAAa,kBAAkB;KACpE,SAAS,EAAM,SAAS,EAAU;KAClC,SAAS,GAAwC;AAC/C,MAAI,EAAE,OAAO,UACX,EAAS,EAAM,OAAO,EAAU,CAAC,GAEjC,EAAS,EAAM,QAAQ,MAAM,MAAM,EAAU,CAAC;;KAGnD,CAAkB;;AAGrB,UAAO;IACP;EACE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "../../../chunks/clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../../hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "../FormControl.js";
|
|
4
|
+
import { useValue as r } from "../../hooks/useValue.js";
|
|
5
5
|
import { ValidationMessage as i } from "./ValidationMessage.js";
|
|
6
6
|
import { useEffect as a, useId as o, useState as s } from "react";
|
|
7
7
|
import { Icon as c } from "@clubmed/trident-icons";
|
|
@@ -11,7 +11,7 @@ function d(d) {
|
|
|
11
11
|
let f = o(), { id: p = f, name: m = p, label: h, value: g, disabled: _ = !1, required: v = !1, hideRequiredStar: y, validationStatus: b = "default", errorMessage: x, validationMessages: S = [], withoutFieldValidation: C = !1, className: w, onChange: T, dataTestId: E = "Password", ...D } = d, O = t({
|
|
12
12
|
isDisabled: _,
|
|
13
13
|
validationStatus: b
|
|
14
|
-
}), { value: k, setValue: A } =
|
|
14
|
+
}), { value: k, setValue: A } = r({
|
|
15
15
|
name: m,
|
|
16
16
|
initialValue: g,
|
|
17
17
|
onChange: T
|
|
@@ -20,7 +20,7 @@ function d(d) {
|
|
|
20
20
|
M(_ ? "password" : j);
|
|
21
21
|
}, [j, _]);
|
|
22
22
|
let N = () => M(j === "password" ? "text" : "password");
|
|
23
|
-
return /* @__PURE__ */ u(
|
|
23
|
+
return /* @__PURE__ */ u(n, {
|
|
24
24
|
className: w,
|
|
25
25
|
id: p,
|
|
26
26
|
label: h,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ImageProps } from '../Image';
|
|
3
|
+
import { FrameWrapperProps } from './FrameWrapper';
|
|
4
|
+
export interface FrameProps extends FrameWrapperProps {
|
|
5
|
+
image: ImageProps | null;
|
|
6
|
+
sizes?: ImageProps['sizes'];
|
|
7
|
+
}
|
|
8
|
+
export declare const Frame: FunctionComponent<FrameProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Image as e } from "../Image.js";
|
|
2
|
+
import { FrameWrapper as t } from "./FrameWrapper.js";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region lib/ui/frame/Frame.tsx
|
|
5
|
+
var i = ({ children: i, image: a, sizes: o, ...s }) => /* @__PURE__ */ r(t, {
|
|
6
|
+
...s,
|
|
7
|
+
children: [a && /* @__PURE__ */ n(e, {
|
|
8
|
+
...a,
|
|
9
|
+
className: "h-full w-full object-cover",
|
|
10
|
+
sizes: o ?? a.sizes
|
|
11
|
+
}), i]
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as Frame };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=Frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frame.js","names":[],"sources":["../../../lib/ui/frame/Frame.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { Image, type ImageProps } from '../Image';\n\nimport { FrameWrapper, type FrameWrapperProps } from './FrameWrapper';\n\nexport interface FrameProps extends FrameWrapperProps {\n image: ImageProps | null;\n sizes?: ImageProps['sizes'];\n}\n\nexport const Frame: FunctionComponent<FrameProps> = ({ children, image, sizes, ...props }) => {\n return (\n <FrameWrapper {...props}>\n {image && (\n <Image {...image} className=\"h-full w-full object-cover\" sizes={sizes ?? image.sizes} />\n )}\n {children}\n </FrameWrapper>\n );\n};\n"],"mappings":";;;;AAWA,IAAa,KAAwC,EAAE,aAAU,UAAO,UAAO,GAAG,QAE9E,kBAAC,GAAD;CAAc,GAAI;WAAlB,CACG,KACC,kBAAC,GAAD;EAAO,GAAI;EAAO,WAAU;EAA6B,OAAO,KAAS,EAAM;EAAS,CAAA,EAEzF,EACY"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as e } from "../../chunks/clsx.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
//#region lib/ui/frame/FrameLabelsWrapper.tsx
|
|
4
|
+
var n = ({ children: n, className: r, hasImage: i = !1, ...a }) => /* @__PURE__ */ t("div", {
|
|
5
|
+
...a,
|
|
6
|
+
className: e("rounded-16 pointer-events-none absolute inset-0 flex flex-col overflow-auto", { "bg-linear-to-b from-transparent via-transparent via-40% to-black/70": i }, r),
|
|
7
|
+
children: n
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as FrameLabelsWrapper };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=FrameLabelsWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameLabelsWrapper.js","names":[],"sources":["../../../lib/ui/frame/FrameLabelsWrapper.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport type { ComponentPropsWithoutRef, FunctionComponent } from 'react';\n\nexport interface FrameLabelsWrapperProps extends ComponentPropsWithoutRef<'div'> {\n hasImage: boolean;\n}\n\nexport const FrameLabelsWrapper: FunctionComponent<FrameLabelsWrapperProps> = ({\n children,\n className,\n hasImage = false,\n ...attrs\n}) => {\n return (\n <div\n {...attrs}\n className={clsx(\n 'rounded-16 pointer-events-none absolute inset-0 flex flex-col overflow-auto',\n {\n 'bg-linear-to-b from-transparent via-transparent via-40% to-black/70': hasImage,\n },\n className,\n )}\n >\n {children}\n </div>\n );\n};\n"],"mappings":";;;AAOA,IAAa,KAAkE,EAC7E,aACA,cACA,cAAW,IACX,GAAG,QAGD,kBAAC,OAAD;CACE,GAAI;CACJ,WAAW,EACT,+EACA,EACE,uEAAuE,GACxE,EACD,EACD;CAEA;CACG,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FunctionComponent, HTMLAttributes } from 'react';
|
|
2
|
+
export interface FrameTitleProps extends HTMLAttributes<HTMLDivElement | HTMLAnchorElement> {
|
|
3
|
+
coverLink?: boolean;
|
|
4
|
+
hasImage?: boolean;
|
|
5
|
+
href?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const FrameTitle: FunctionComponent<FrameTitleProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { t as e } from "../../chunks/clsx.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
//#region lib/ui/frame/FrameTitle.tsx
|
|
4
|
+
var n = ({ children: n, className: r, coverLink: i = !1, hasImage: a = !1, href: o, onClick: s, ...c }) => {
|
|
5
|
+
let l = !!o, u = l ? "a" : "div", d = l ? {
|
|
6
|
+
href: o,
|
|
7
|
+
onClick: s
|
|
8
|
+
} : null;
|
|
9
|
+
return /* @__PURE__ */ t(u, {
|
|
10
|
+
className: e("pointer-events-auto flex w-full gap-x-8 px-12 pb-12 sm:px-24 sm:pb-24", {
|
|
11
|
+
"justify-center text-center": !n,
|
|
12
|
+
"h-full items-end": i,
|
|
13
|
+
"mt-auto h-auto": !i,
|
|
14
|
+
"text-white": a,
|
|
15
|
+
"text-black": !a
|
|
16
|
+
}, r),
|
|
17
|
+
...d,
|
|
18
|
+
...c,
|
|
19
|
+
children: n
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { n as FrameTitle };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=FrameTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameTitle.js","names":[],"sources":["../../../lib/ui/frame/FrameTitle.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport type { FunctionComponent, HTMLAttributes } from 'react';\n\nexport interface FrameTitleProps extends HTMLAttributes<HTMLDivElement | HTMLAnchorElement> {\n coverLink?: boolean;\n hasImage?: boolean;\n href?: string;\n}\n\nexport const FrameTitle: FunctionComponent<FrameTitleProps> = ({\n children,\n className,\n coverLink = false,\n hasImage = false,\n href,\n onClick,\n ...attrs\n}) => {\n const hasLink = !!href;\n\n const TagName = hasLink ? 'a' : 'div';\n const tagProps = hasLink ? { href, onClick } : null;\n\n return (\n <TagName\n className={clsx(\n 'pointer-events-auto flex w-full gap-x-8 px-12 pb-12 sm:px-24 sm:pb-24',\n {\n 'justify-center text-center': !children,\n 'h-full items-end': coverLink,\n 'mt-auto h-auto': !coverLink,\n 'text-white': hasImage,\n 'text-black': !hasImage,\n },\n className,\n )}\n {...tagProps}\n {...attrs}\n >\n {children}\n </TagName>\n );\n};\n"],"mappings":";;;AASA,IAAa,KAAkD,EAC7D,aACA,cACA,eAAY,IACZ,cAAW,IACX,SACA,YACA,GAAG,QACC;CACJ,IAAM,IAAU,CAAC,CAAC,GAEZ,IAAU,IAAU,MAAM,OAC1B,IAAW,IAAU;EAAE;EAAM;EAAS,GAAG;AAE/C,QACE,kBAAC,GAAD;EACE,WAAW,EACT,yEACA;GACE,8BAA8B,CAAC;GAC/B,oBAAoB;GACpB,kBAAkB,CAAC;GACnB,cAAc;GACd,cAAc,CAAC;GAChB,EACD,EACD;EACD,GAAI;EACJ,GAAI;EAEH;EACO,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, FunctionComponent } from 'react';
|
|
2
|
+
export interface FrameWrapperProps extends ComponentPropsWithoutRef<'article'> {
|
|
3
|
+
as?: 'article' | 'div' | 'span';
|
|
4
|
+
format?: 'horizontal' | 'vertical' | 'square' | 'custom';
|
|
5
|
+
}
|
|
6
|
+
export declare const FrameWrapper: FunctionComponent<FrameWrapperProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as e } from "../../chunks/clsx.js";
|
|
2
|
+
import { CARD_ASPECT_RATIOS as t } from "../cards/CardAspectRatios.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region lib/ui/frame/FrameWrapper.tsx
|
|
5
|
+
var r = ({ as: r = "article", children: i, className: a, format: o = "horizontal", ...s }) => /* @__PURE__ */ n(r, {
|
|
6
|
+
className: e(t[o], "group rounded-16 relative isolate overflow-hidden", a),
|
|
7
|
+
"data-name": "Frame",
|
|
8
|
+
...s,
|
|
9
|
+
children: i
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as FrameWrapper };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=FrameWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameWrapper.js","names":[],"sources":["../../../lib/ui/frame/FrameWrapper.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport type { ComponentPropsWithoutRef, FunctionComponent } from 'react';\n\nimport { CARD_ASPECT_RATIOS } from '../cards/CardAspectRatios';\n\nexport interface FrameWrapperProps extends ComponentPropsWithoutRef<'article'> {\n as?: 'article' | 'div' | 'span';\n format?: 'horizontal' | 'vertical' | 'square' | 'custom';\n}\n\nexport const FrameWrapper: FunctionComponent<FrameWrapperProps> = ({\n as: TagName = 'article',\n children,\n className,\n format = 'horizontal',\n ...attrs\n}) => {\n return (\n <TagName\n className={clsx(\n CARD_ASPECT_RATIOS[format],\n 'group rounded-16 relative isolate overflow-hidden',\n className,\n )}\n data-name=\"Frame\"\n {...attrs}\n >\n {children}\n </TagName>\n );\n};\n"],"mappings":";;;;AAUA,IAAa,KAAsD,EACjE,IAAI,IAAU,WACd,aACA,cACA,YAAS,cACT,GAAG,QAGD,kBAAC,GAAD;CACE,WAAW,EACT,EAAmB,IACnB,qDACA,EACD;CACD,aAAU;CACV,GAAI;CAEH;CACO,CAAA"}
|