@cryptlex/web-components 6.6.6-alpha50 → 6.6.6-alpha53
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/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/{table-actions.js → data-table-actions.js} +1 -1
- package/dist/components/data-table-actions.js.map +1 -0
- package/dist/components/data-table-filter.d.ts +1 -1
- package/dist/components/data-table-filter.js +1 -1
- package/dist/components/data-table.d.ts +11 -25
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/duration-field.js +1 -1
- package/dist/components/duration-field.js.map +1 -1
- package/dist/components/id-search.d.ts +4 -4
- package/dist/components/id-search.js +1 -1
- package/dist/components/id-search.js.map +1 -1
- package/dist/components/multi-select.js +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/numberfield.js +1 -1
- package/dist/components/numberfield.js.map +1 -1
- package/dist/components/select-options.d.ts +1 -0
- package/dist/components/select-options.js +1 -1
- package/dist/components/select-options.js.map +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/textfield.js +1 -1
- package/dist/components/textfield.js.map +1 -1
- package/dist/components/toast.d.ts +4 -8
- package/dist/components/toast.js +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/utilities/form-context.d.ts +3 -1
- package/dist/utilities/form-context.js +1 -1
- package/dist/utilities/form-context.js.map +1 -1
- package/dist/utilities/resources.d.ts +9 -7
- package/dist/utilities/resources.js +1 -1
- package/dist/utilities/resources.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/table-actions.js.map +0 -1
- /package/dist/components/{table-actions.d.ts → data-table-actions.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-search.js","sources":["../../lib/components/id-search.tsx"],"sourcesContent":["'use client';\nimport { useQuery } from '@tanstack/react-query';\nimport { useId, useState } from 'react';\nimport { Select as AriaSelect, Autocomplete } from 'react-aria-components';\n\nimport { useCtxClient } from '../utilities/ctx-client';\nimport { Loader } from '../components/loader';\nimport { Menu, MenuItem } from '../components/menu';\nimport { PopoverTrigger } from '../components/popover';\nimport { SearchField } from '../components/searchfield';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport type { CtxResourceName } from '../utilities/resources';\nimport { RESOURCE_ENDPOINT_MAP } from '../utilities/resources';\nimport { FormField, type FormFieldProps } from './form';\nimport { SelectPopover, SelectTrigger } from './select';\n\n/**\n * Minimal resource shape used by the ID search inputs.\n * Only `id` and `name` are required.\n *\n * @example\n * const user: BaseSearchableResource = { id: 'u_123', name: 'Nabeel Farooq' };\n */\ntype BaseSearchableResource = {\n /** Unique identifier used as the input value. */\n id: string;\n /** Human-readable label shown to users. */\n name: string;\n};\n\n/**\n * Type guard to check if a value is an array of searchable resources\n */\nfunction isSearchableResourceArray<T extends BaseSearchableResource>(value: unknown): value is T[] {\n return (\n Array.isArray(value) && value.every(item => item && typeof item === 'object' && 'id' in item && 'name' in item)\n );\n}\n\n/**\n * - Generic, accessible ID-search building block.\n * - Search (powered by react-query)\n * - Renders an accessible Autocomplete + Menu listbox\n * - Exposes a controlled `value`/`onChange` contract so callers (and wrappers) can manage state\n * - Automatically generates search function based on resource name using RESOURCE_ENDPOINT_MAP\n *\n * @template T - resource type extending `BaseSearchableResource` (must have `id` and `name`)\n * @template V - controlled value type (e.g. `string` for single-select or `string[]` for multi-select)\n *\n * @param props - props object (see inline property JSDoc for the most important fields)\n *\n * @remarks\n * - Search is automatically handled based on the `resource` prop using the API client from context\n * - When the popover closes, `onBlur` (if provided) is called with the current `value`.\n * - `renderLabel` must convert `value` to a readable string for the control button.\n * - `defaultParams` can be used to pass additional query parameters to the search endpoint\n *\n * @example\n * <BaseIdSearchInput\n * label=\"Owner\"\n * resource=\"user\"\n * value={ownerId}\n * onChange={setOwnerId}\n * renderLabel={(v, data) => data?.find(d => d.id === v)?.name ?? v}\n * />\n *\n * @testing\n * - Ensure API client is provided via context; assert keyboard navigation, open/close behavior, and `onBlur` call on popover close.\n */\nfunction BaseIdSearchInput<T extends BaseSearchableResource, V>({\n label,\n description,\n errorMessage,\n requiredIndicator,\n isDisabled,\n isInvalid,\n onBlur,\n resource,\n onChange,\n value,\n renderLabel,\n accessor,\n defaultParams,\n className,\n ...props\n}: FormFieldProps & {\n resource: CtxResourceName;\n /** Disable interactions. */\n isDisabled?: boolean;\n /** Whether the field is invalid. */\n isInvalid?: boolean;\n /** Key used to access an alternate display accessor on item (kept for compatibility). */\n accessor: keyof BaseSearchableResource;\n /** Controlled value. */\n value: V;\n /** Called when popover closes or the field blurs with the current value. */\n onBlur?: (v: V) => void;\n /** Controlled change handler. */\n onChange: (v: V) => void;\n /** Render a human-readable label for the current value using the latest data. */\n renderLabel: (v: V, data: T[] | undefined) => string;\n /** Default parameters to include in the request. This is useful when using /v3/users?role='admin' or /v3/organizations/ID/user-groups */\n defaultParams?: Record<'path' | 'query', any>;\n /** Optional className to customize the trigger button styling. */\n className?: string;\n} & Omit<React.ComponentProps<typeof Menu>, 'items' | 'className'>) {\n if (resource === 'profile') {\n throw Error('Resource \"profile\" is not supported with IdSearch since it is not a searchable resource.');\n }\n\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n const client = useCtxClient();\n\n const [search, _setSearch] = useState('');\n const { data, isError, isFetching, error } = useQuery({\n queryKey: [resource, 'id', search],\n queryFn: async (): Promise<T[]> => {\n const result = await client.GET(RESOURCE_ENDPOINT_MAP[resource], {\n params: {\n query: {\n search,\n ...defaultParams?.query,\n },\n path: {\n ...defaultParams?.path,\n },\n },\n });\n\n // Type narrowing: result.data is inferred as never due to complex union types\n // We use unknown to bypass this and then validate with our type guard\n const responseData: unknown = result.data;\n if (responseData && isSearchableResourceArray<T>(responseData)) {\n return responseData;\n }\n return [];\n },\n });\n\n return (\n <div className=\"group form-field\" data-invalid={isInvalid ? '' : undefined}>\n <FormField {...{ label, description, errorMessage, requiredIndicator, htmlFor: fieldId }}>\n <AriaSelect isInvalid={isInvalid}>\n <PopoverTrigger\n onOpenChange={o => {\n if (!o) {\n // searchInputRef.current?.focus();\n onBlur?.(value);\n }\n }}\n >\n <SelectTrigger id={fieldId} isDisabled={isDisabled} className={className ?? 'w-full'}>\n {renderLabel(value, data)}\n </SelectTrigger>\n <SelectPopover placement=\"bottom start\">\n <Autocomplete inputValue={search} onInputChange={_setSearch}>\n <SearchField className={'p-2'} autoFocus />\n {isFetching && (\n <div className=\"p-input\">\n <Loader className=\"mx-auto\" />\n </div>\n )}\n {!isFetching && !isError && (\n <Menu\n {...props}\n className={'max-h-48'}\n items={data}\n renderEmptyState={() => <div className=\"body-sm p-2\">No results found.</div>}\n >\n {item => (\n <MenuItem key={item[accessor]} id={item[accessor]}>\n {item.name}\n </MenuItem>\n )}\n </Menu>\n )}\n {isError && <div className=\"text-destructive p-icon body-sm\">{error.message}</div>}\n </Autocomplete>\n </SelectPopover>\n </PopoverTrigger>\n </AriaSelect>\n </FormField>\n </div>\n );\n}\n\n/**\n * Single-selection ID search input.\n *\n * Thin, typed wrapper around `BaseIdSearchInput` specialized for the very common single-ID case.\n * Adapts the internal selection events into `onChange(id?: string)` and renders the selected label.\n *\n * @template T - resource type (extends BaseSearchableResource)\n *\n * @param props - Inherits `BaseIdSearchInput` props but uses `string[]` value type.\n *\n * @example\n * <SingleIdSearchInput\n * label=\"Reporter\"\n * value={reporterId}\n * onChange={setReporterId}\n * />\n *\n */\nexport function SingleIdSearchInput<T extends BaseSearchableResource>({\n ...props\n}: Omit<\n React.ComponentProps<typeof BaseIdSearchInput<T, string>>,\n 'onSelectionChange' | 'selectionMode' | 'selectedKeys' | 'renderLabel'\n>) {\n return (\n <BaseIdSearchInput\n selectedKeys={[props.value]}\n onSelectionChange={e => props.onChange(Array.from(e).filter(v => typeof v === 'string')[0])}\n renderLabel={(v, d) => d?.find(di => di.id === v)?.name ?? v}\n selectionMode=\"single\"\n {...props}\n />\n );\n}\n\n/**\n * Multi-selection ID search input.\n *\n * Thin wrapper around `BaseIdSearchInput` for the multiple-ID (`string[]`) case.\n * Adapts internal selection events into `onChange(ids: string[])`.\n *\n * @template T - resource type (extends BaseSearchableResource)\n *\n * @param props - Inherits `BaseIdSearchInput` props but uses `string[]` value type.\n *\n * @example\n * <MultipleIdSearchInput\n * label=\"Reviewers\"\n * value={reviewerIds}\n * onChange={setReviewerIds}\n * />\n *\n * @remarks\n * - The `renderLabel` joins selected item names with commas for compact display.\n */\nexport function MultipleIdSearchInput<T extends BaseSearchableResource>({\n ...props\n}: Omit<\n React.ComponentProps<typeof BaseIdSearchInput<T, string[]>>,\n 'renderLabel' | 'onSelectionChange' | 'selectionMode' | 'selectedKeys'\n>) {\n return (\n <BaseIdSearchInput\n selectedKeys={props.value}\n onSelectionChange={e => props.onChange(Array.from(e).filter(v => typeof v === 'string'))}\n selectionMode=\"multiple\"\n renderLabel={(v, d) => v?.map(vi => d?.find(di => di.id === vi)?.name ?? vi).join(',')}\n {...props}\n />\n );\n}\n\n/**\n * Form-integrated single-select ID input (field wrapper).\n *\n * Integrates `SingleIdSearchInput` into the form system using `useFieldContext`.\n * - wires `value`, `onChange`, and `onBlur`\n * - disables the control while the form is submitting\n * - surfaces field-level error messages\n *\n * @example\n * <TfSingleIdSearchInput name=\"ownerId\" label=\"Owner\" />\n \n */\nexport function TfSingleIdSearchInput({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof SingleIdSearchInput>, 'value' | 'onChange' | 'onBlur'>) {\n const field = useFieldContext<string>({ disabled: isDisabled });\n return (\n <SingleIdSearchInput\n {...props}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n onBlur={_ => field.handleBlur()}\n onChange={e => field.handleChange(e)}\n isInvalid={!!getFieldErrorMessage(field)}\n errorMessage={getFieldErrorMessage(field)}\n />\n );\n}\n\n/**\n * Form-integrated multi-select ID input (field wrapper).\n *\n * Integrates `MultipleIdSearchInput` into the form system using `useFieldContext`.\n * - wires `value`, `onChange`, and `onBlur`\n * - disables the control while the form is submitting\n * - surfaces field-level error messages\n *\n * @example\n * <TfMultipleIdSearchInput name=\"reviewerIds\" label=\"Reviewers\" />\n *\n */\nexport function TfMultipleIdSearchInput({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof MultipleIdSearchInput>, 'value' | 'onChange'>) {\n const field = useFieldContext<string[]>({ disabled: isDisabled });\n return (\n <MultipleIdSearchInput\n {...props}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n onBlur={_ => field.handleBlur()}\n onChange={e => field.handleChange(e)}\n isInvalid={!!getFieldErrorMessage(field)}\n errorMessage={getFieldErrorMessage(field)}\n />\n );\n}\n"],"names":["isSearchableResourceArray","value","item","BaseIdSearchInput","label","description","errorMessage","requiredIndicator","isDisabled","isInvalid","onBlur","resource","onChange","renderLabel","accessor","defaultParams","className","props","generatedId","useId","fieldId","client","useCtxClient","search","_setSearch","useState","data","isError","isFetching","error","useQuery","responseData","RESOURCE_ENDPOINT_MAP","jsx","FormField","AriaSelect","jsxs","PopoverTrigger","SelectTrigger","SelectPopover","Autocomplete","SearchField","Loader","Menu","MenuItem","SingleIdSearchInput","e","v","d","di","MultipleIdSearchInput","vi","TfSingleIdSearchInput","field","useFieldContext","_","getFieldErrorMessage","TfMultipleIdSearchInput"],"mappings":"i8BAkCA,SAASA,EAA4DC,EAA8B,CAC/F,OACI,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAMC,GAAQA,GAAQ,OAAOA,GAAS,UAAY,OAAQA,GAAQ,SAAUA,CAAI,CAEtH,CAgCA,SAASC,EAAuD,CAC5D,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,WAAAC,EACA,UAAAC,EACA,OAAAC,EACA,SAAAC,EACA,SAAAC,EACA,MAAAX,EACA,YAAAY,EACA,SAAAC,EACA,cAAAC,EAC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ACIyB,EAACY,EAAA,CACI,GAAG5B,EACJ,WAAYT,GAAc6C,EAAM,KAAK,MAAM,aAC3C,MAAOA,EAAM,MAAM,MACnB,OAAQE,GAAKF,EAAM,WAAA,EACnB,SAAUP,GAAKO,EAAM,aAAaP,CAAC,EACnC,UAAW,CAAC,CAACU,EAAqBH,CAAK,EACvC,aAAcG,EAAqBH,CAAK,CAAA,CAAA,CAGpD,CAcO,SAASI,GAAwB,CACpC,WAAAjD,EACA,GAAGS,CACP,EAAmF,CAC/E,MAAMoC,EAAQC,EAA0B,CAAE,SAAU9C,EAAY,EAChE,OACIyB,EAACiB,EAAA,CACI,GAAGjC,EACJ,WAAYT,GAAc6C,EAAM,KAAK,MAAM,aAC3C,MAAOA,EAAM,MAAM,MACnB,OAAQE,GAAKF,EAAM,WAAA,EACnB,SAAUP,GAAKO,EAAM,aAAaP,CAAC,EACnC,UAAW,CAAC,CAACU,EAAqBH,CAAK,EACvC,aAAcG,EAAqBH,CAAK,CAAA,CAAA,CAGpD"}
|
|
1
|
+
{"version":3,"file":"id-search.js","sources":["../../lib/components/id-search.tsx"],"sourcesContent":["'use client';\nimport { useQuery } from '@tanstack/react-query';\nimport { useId, useState } from 'react';\nimport { Select as AriaSelect, Autocomplete } from 'react-aria-components';\n\nimport type { ClientPathsWithMethod } from 'openapi-fetch';\nimport { Loader } from '../components/loader';\nimport { Menu, MenuItem } from '../components/menu';\nimport { PopoverTrigger } from '../components/popover';\nimport { SearchField } from '../components/searchfield';\nimport { useCtxClient, type CtxClientType } from '../utilities/ctx-client';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { FormField, type FormFieldProps } from './form';\nimport { SelectPopover, SelectTrigger } from './select';\n\n/**\n * Minimal resource shape used by the ID search inputs.\n * Only `id` and `name` are required.\n *\n * @example\n * const user: BaseSearchableResource = { id: 'u_123', name: 'Nabeel Farooq' };\n */\ntype BaseSearchableResource = {\n /** Unique identifier used as the input value. */\n id: string;\n /** Human-readable label shown to users. */\n name: string;\n};\n\n/**\n * Type guard to check if a value is an array of searchable resources\n */\nfunction isSearchableResourceArray<T extends BaseSearchableResource>(value: unknown): value is T[] {\n return (\n Array.isArray(value) && value.every(item => item && typeof item === 'object' && 'id' in item && 'name' in item)\n );\n}\n\n/**\n * - Generic, accessible ID-search building block.\n * - Search (powered by react-query)\n * - Renders an accessible Autocomplete + Menu listbox\n * - Exposes a controlled `value`/`onChange` contract so callers (and wrappers) can manage state\n *\n * @template T - resource type extending `BaseSearchableResource` (must have `id` and `name`)\n * @template V - controlled value type (e.g. `string` for single-select or `string[]` for multi-select)\n *\n * @param props - props object (see inline property JSDoc for the most important fields)\n *\n * @remarks\n * - Search is automatically handled based on the `resource` prop using the API client from context\n * - When the popover closes, `onBlur` (if provided) is called with the current `value`.\n * - `renderLabel` must convert `value` to a readable string for the control button.\n * - `defaultParams` can be used to pass additional query parameters to the search endpoint\n *\n * @example\n * <BaseIdSearchInput\n * label=\"Owner\"\n * resource=\"user\"\n * value={ownerId}\n * onChange={setOwnerId}\n * renderLabel={(v, data) => data?.find(d => d.id === v)?.name ?? v}\n * />\n *\n * @testing\n * - Ensure API client is provided via context; assert keyboard navigation, open/close behavior, and `onBlur` call on popover close.\n */\nfunction BaseIdSearchInput<T extends BaseSearchableResource, V>({\n label,\n description,\n errorMessage,\n requiredIndicator,\n isDisabled,\n isInvalid,\n onBlur,\n path,\n onChange,\n value,\n renderLabel,\n accessor,\n defaultParams,\n className,\n ...props\n}: FormFieldProps & {\n path: ClientPathsWithMethod<CtxClientType, 'get'>;\n /** Disable interactions. */\n isDisabled?: boolean;\n /** Whether the field is invalid. */\n isInvalid?: boolean;\n /** Key used to access an alternate display accessor on item (kept for compatibility). */\n accessor: keyof BaseSearchableResource;\n /** Controlled value. */\n value: V;\n /** Called when popover closes or the field blurs with the current value. */\n onBlur?: (v: V) => void;\n /** Controlled change handler. */\n onChange: (v: V) => void;\n /** Render a human-readable label for the current value using the latest data. */\n renderLabel: (v: V, data: T[] | undefined) => string;\n /** Default parameters to include in the request. This is useful when using /v3/users?role='admin' or /v3/organizations/ID/user-groups */\n defaultParams?: Record<'path' | 'query', any>;\n /** Optional className to customize the trigger button styling. */\n className?: string;\n} & Omit<React.ComponentProps<typeof Menu>, 'items' | 'className'>) {\n if (path === '/v3/me') {\n throw Error('Path \"/v3/me\" is not supported with IdSearch since it is not a searchable resource.');\n }\n\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n const client = useCtxClient();\n\n const [search, _setSearch] = useState('');\n const { data, isError, isFetching, error } = useQuery({\n // This is the schema that openapi-react-query follows as of 0.5.1\n queryKey: ['get', path],\n queryFn: async (): Promise<T[]> => {\n const result = await client.GET(path, {\n params: {\n query: {\n search,\n ...defaultParams?.query,\n },\n path: {\n ...defaultParams?.path,\n },\n },\n });\n\n // Type narrowing: result.data is inferred as never due to complex union types\n // We use unknown to bypass this and then validate with our type guard\n const responseData: unknown = result.data;\n if (responseData && isSearchableResourceArray<T>(responseData)) {\n return responseData;\n }\n return [];\n },\n });\n\n return (\n <div className=\"group form-field\" data-invalid={isInvalid ? '' : undefined}>\n <FormField {...{ label, description, errorMessage, requiredIndicator, htmlFor: fieldId }}>\n <AriaSelect isInvalid={isInvalid}>\n <PopoverTrigger\n onOpenChange={o => {\n if (!o) {\n // searchInputRef.current?.focus();\n onBlur?.(value);\n }\n }}\n >\n <SelectTrigger id={fieldId} isDisabled={isDisabled} className={className ?? 'w-full'}>\n {renderLabel(value, data)}\n </SelectTrigger>\n <SelectPopover placement=\"bottom start\">\n <Autocomplete inputValue={search} onInputChange={_setSearch}>\n <SearchField className={'p-2'} autoFocus />\n {isFetching && (\n <div className=\"p-input\">\n <Loader className=\"mx-auto\" />\n </div>\n )}\n {!isFetching && !isError && (\n <Menu\n {...props}\n className={'max-h-48'}\n items={data}\n renderEmptyState={() => <div className=\"body-sm p-2\">No results found.</div>}\n >\n {item => (\n <MenuItem key={item[accessor]} id={item[accessor]}>\n {item.name}\n </MenuItem>\n )}\n </Menu>\n )}\n {isError && <div className=\"text-destructive p-icon body-sm\">{error.message}</div>}\n </Autocomplete>\n </SelectPopover>\n </PopoverTrigger>\n </AriaSelect>\n </FormField>\n </div>\n );\n}\n\n/**\n * Single-selection ID search input.\n *\n * Thin, typed wrapper around `BaseIdSearchInput` specialized for the very common single-ID case.\n * Adapts the internal selection events into `onChange(id?: string)` and renders the selected label.\n *\n * @template T - resource type (extends BaseSearchableResource)\n *\n * @param props - Inherits `BaseIdSearchInput` props but uses `string[]` value type.\n *\n * @example\n * <SingleIdSearchInput\n * label=\"Reporter\"\n * value={reporterId}\n * onChange={setReporterId}\n * />\n *\n */\nexport function SingleIdSearchInput<T extends BaseSearchableResource>({\n ...props\n}: Omit<\n React.ComponentProps<typeof BaseIdSearchInput<T, string>>,\n 'onSelectionChange' | 'selectionMode' | 'selectedKeys' | 'renderLabel'\n>) {\n return (\n <BaseIdSearchInput\n selectedKeys={[props.value]}\n onSelectionChange={e => props.onChange(Array.from(e).filter(v => typeof v === 'string')[0])}\n renderLabel={(v, d) => d?.find(di => di.id === v)?.name ?? v}\n selectionMode=\"single\"\n {...props}\n />\n );\n}\n\n/**\n * Multi-selection ID search input.\n *\n * Thin wrapper around `BaseIdSearchInput` for the multiple-ID (`string[]`) case.\n * Adapts internal selection events into `onChange(ids: string[])`.\n *\n * @template T - resource type (extends BaseSearchableResource)\n *\n * @param props - Inherits `BaseIdSearchInput` props but uses `string[]` value type.\n *\n * @example\n * <MultipleIdSearchInput\n * label=\"Reviewers\"\n * value={reviewerIds}\n * onChange={setReviewerIds}\n * />\n *\n * @remarks\n * - The `renderLabel` joins selected item names with commas for compact display.\n */\nexport function MultipleIdSearchInput<T extends BaseSearchableResource>({\n ...props\n}: Omit<\n React.ComponentProps<typeof BaseIdSearchInput<T, string[]>>,\n 'renderLabel' | 'onSelectionChange' | 'selectionMode' | 'selectedKeys'\n>) {\n return (\n <BaseIdSearchInput\n selectedKeys={props.value}\n onSelectionChange={e => props.onChange(Array.from(e).filter(v => typeof v === 'string'))}\n selectionMode=\"multiple\"\n renderLabel={(v, d) => v?.map(vi => d?.find(di => di.id === vi)?.name ?? vi).join(',')}\n {...props}\n />\n );\n}\n\n/**\n * Form-integrated single-select ID input (field wrapper).\n *\n * Integrates `SingleIdSearchInput` into the form system using `useFieldContext`.\n * - wires `value`, `onChange`, and `onBlur`\n * - disables the control while the form is submitting\n * - surfaces field-level error messages\n *\n * @example\n * <TfSingleIdSearchInput name=\"ownerId\" label=\"Owner\" />\n \n */\nexport function TfSingleIdSearchInput({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof SingleIdSearchInput>, 'value' | 'onChange' | 'onBlur'>) {\n const field = useFieldContext<string>({ disabled: isDisabled });\n return (\n <SingleIdSearchInput\n requiredIndicator={field.isRequired}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n onBlur={_ => field.handleBlur()}\n onChange={e => field.handleChange(e)}\n isInvalid={!!getFieldErrorMessage(field)}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n\n/**\n * Form-integrated multi-select ID input (field wrapper).\n *\n * Integrates `MultipleIdSearchInput` into the form system using `useFieldContext`.\n * - wires `value`, `onChange`, and `onBlur`\n * - disables the control while the form is submitting\n * - surfaces field-level error messages\n *\n * @example\n * <TfMultipleIdSearchInput name=\"reviewerIds\" label=\"Reviewers\" />\n *\n */\nexport function TfMultipleIdSearchInput({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof MultipleIdSearchInput>, 'value' | 'onChange'>) {\n const field = useFieldContext<string[]>({ disabled: isDisabled });\n return (\n <MultipleIdSearchInput\n requiredIndicator={field.isRequired}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n onBlur={_ => field.handleBlur()}\n onChange={e => field.handleChange(e)}\n isInvalid={!!getFieldErrorMessage(field)}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n"],"names":["isSearchableResourceArray","value","item","BaseIdSearchInput","label","description","errorMessage","requiredIndicator","isDisabled","isInvalid","onBlur","path","onChange","renderLabel","accessor","defaultParams","className","props","generatedId","useId","fieldId","client","useCtxClient","search","_setSearch","useState","data","isError","isFetching","error","useQuery","responseData","jsx","FormField","AriaSelect","jsxs","PopoverTrigger","SelectTrigger","SelectPopover","Autocomplete","SearchField","Loader","Menu","MenuItem","SingleIdSearchInput","e","v","d","di","MultipleIdSearchInput","vi","TfSingleIdSearchInput","field","useFieldContext","_","getFieldErrorMessage","TfMultipleIdSearchInput"],"mappings":"80BAiCA,SAASA,EAA4DC,EAA8B,CAC/F,OACI,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAMC,GAAQA,GAAQ,OAAOA,GAAS,UAAY,OAAQA,GAAQ,SAAUA,CAAI,CAEtH,CA+BA,SAASC,EAAuD,CAC5D,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,WAAAC,EACA,UAAAC,EACA,OAAAC,EACA,KAAAC,EACA,SAAAC,EACA,MAAAX,EACA,YAAAY,EACA,SAAAC,EACA,cAAAC,EACA,UAAAC,EACA,GAAGC,CACP,EAoBoE,CAChE,GAAIN,IAAS,SACT,MAAM,MAAM,qFAAqF,EAGrG,MAAMO,EAAcC,EAAA,EACdC,EAAUH,EAAM,IAAMC,EACtBG,EAASC,EAAA,EAET,CAACC,EAAQC,CAAU,EAAIC,EAAS,EAAE,EAClC,CAAE,KAAAC,EAAM,QAAAC,EAAS,WAAAC,EAAY,MAAAC,CAAA,EAAUC,EAAS,CAElD,SAAU,CAAC,MAAOnB,CAAI,EACtB,QAAS,SAA0B,CAe/B,MAAMoB,GAdS,MAAMV,EAAO,IAAIV,EAAM,CAClC,OAAQ,CACJ,MAAO,CACH,OAAAY,EACA,GAAGR,GAAe,KAAA,EAEtB,KAAM,CACF,GAAGA,GAAe,IAAA,CACtB,CACJ,CACH,GAIoC,KACrC,OAAIgB,GAAgB/B,EAA6B+B,CAAY,EAClDA,EAEJ,C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ACnC,UAAW,CAAC,CAACU,EAAqBH,CAAK,EACvC,aAAcG,EAAqBH,CAAK,EACvC,GAAGnC,CAAA,CAAA,CAGhB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as i}from"react/jsx-runtime";import{useId as c}from"react";import{EasyMenu as f,MenuItem as p}from"./menu.js";import{getFieldErrorMessage as g}from"../utilities/form.js";import{useFieldContext as h}from"../utilities/form-context.js";import{FormField as b}from"./form.js";import"react-aria-components";import"../utilities/theme.js";import"clsx";import"./icons.js";import"./list-box.js";import"./select.js";import"./button.js";import"class-variance-authority";import"./loader.js";import"./popover.js";import"@tanstack/react-form";function M({items:t,value:e,onChange:o,label:d,errorMessage:s,description:
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{useId as c}from"react";import{EasyMenu as f,MenuItem as p}from"./menu.js";import{getFieldErrorMessage as g}from"../utilities/form.js";import{useFieldContext as h}from"../utilities/form-context.js";import{FormField as b}from"./form.js";import"react-aria-components";import"../utilities/theme.js";import"clsx";import"./icons.js";import"./list-box.js";import"./select.js";import"./button.js";import"class-variance-authority";import"./loader.js";import"./popover.js";import"@tanstack/react-form";function M({items:t,value:e,onChange:o,label:d,errorMessage:s,description:a,requiredIndicator:m,...l}){const u=c(),n=l.id||u;return i("div",{className:"group form-field",children:i(b,{label:d,description:a,errorMessage:s,requiredIndicator:m,htmlFor:n,children:i(f,{id:n,isNonModal:!1,selectionMode:"multiple",selectedKeys:e,onSelectionChange:r=>{typeof r!="string"&&o(r)},items:t,label:l.triggerLabel??i("span",{className:"tabular-nums",children:e.size}),...l,children:r=>i(p,{id:r.id,isDisabled:r?.disabled,children:r.label},r.id)})})})}function L({...t}){const e=h({disabled:t.isDisabled});return i(M,{requiredIndicator:e.isRequired,value:new Set(e.state.value),onChange:o=>e.setValue(Array.from(o)),onClose:e.handleBlur,errorMessage:g(e),...t})}export{M as MultiSelect,L as TfMultiSelect};
|
|
2
2
|
//# sourceMappingURL=multi-select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-select.js","sources":["../../lib/components/multi-select.tsx"],"sourcesContent":["'use client';\nimport React, { useId } from 'react';\nimport { EasyMenu, MenuItem } from '../components/menu';\nimport type { SelectOption } from '../components/select-options';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { FormField, type FormFieldProps } from './form';\n\ninterface MultipleSelectionProps {\n value: Set<string | number>;\n onChange: (v: Set<string | number>) => void;\n buttonLabel?: React.ReactNode;\n items: SelectOption[];\n}\n\nexport interface MultiSelectProps\n extends MultipleSelectionProps,\n FormFieldProps,\n Omit<React.ComponentProps<typeof EasyMenu>, 'label' | 'items'> {\n triggerLabel?: React.ReactNode;\n}\n\nexport function MultiSelect({\n items,\n value,\n onChange: setValue,\n label,\n errorMessage,\n description,\n requiredIndicator,\n ...props\n}: MultiSelectProps) {\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n\n return (\n <div className=\"group form-field\">\n <FormField {...{ label, description, errorMessage, requiredIndicator, htmlFor: fieldId }}>\n <EasyMenu\n id={fieldId}\n isNonModal={false}\n selectionMode=\"multiple\"\n selectedKeys={value}\n onSelectionChange={v => {\n if (typeof v === 'string') return;\n setValue(v);\n }}\n items={items}\n label={props.triggerLabel ?? <span className=\"tabular-nums\">{value.size}</span>}\n {...props}\n >\n {item => (\n <MenuItem id={item.id} key={item.id} isDisabled={item?.disabled}>\n {item.label}\n </MenuItem>\n )}\n </EasyMenu>\n </FormField>\n </div>\n );\n}\n\nexport interface TfMultiSelectProps extends Omit<MultiSelectProps, 'value' | 'onChange'> {}\nexport function TfMultiSelect({ ...props }: TfMultiSelectProps) {\n const field = useFieldContext<string[]>({\n disabled: props.isDisabled,\n });\n\n return (\n <MultiSelect\n value={new Set(field.state.value)}\n // @ts-expect-error\n onChange={e => field.setValue(Array.from(e))}\n onClose={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n"],"names":["MultiSelect","items","value","setValue","label","errorMessage","description","requiredIndicator","props","generatedId","useId","fieldId","jsx","FormField","EasyMenu","v","item","MenuItem","TfMultiSelect","field","useFieldContext","e","getFieldErrorMessage"],"mappings":"wiBAsBO,SAASA,EAAY,CACxB,MAAAC,EACA,MAAAC,EACA,SAAUC,EACV,MAAAC,EACA,aAAAC,EACA,YAAAC,EACA,kBAAAC,EACA,GAAGC,CACP,EAAqB,CACjB,MAAMC,EAAcC,EAAA,EACdC,EAAUH,EAAM,IAAMC,EAE5B,OACIG,EAAC,MAAA,CAAI,UAAU,mBACX,WAACC,EAAA,CAAgB,MAAAT,EAAO,YAAAE,EAAa,aAAAD,EAAc,kBAAAE,EAAmB,QAASI,EAC3E,SAAAC,EAACE,EAAA,CACG,GAAIH,EACJ,WAAY,GACZ,cAAc,WACd,aAAcT,EACd,kBAAmBa,GAAK,CAChB,OAAOA,GAAM,UACjBZ,EAASY,CAAC,CACd,EACA,MAAAd,EACA,MAAOO,EAAM,cAAgBI,EAAC,QAAK,UAAU,eAAgB,WAAM,IAAA,CAAK,EACvE,GAAGJ,EAEH,SAAAQ,GACGJ,EAACK,EAAA,CAAS,GAAID,EAAK,GAAkB,WAAYA,GAAM,SAClD,SAAAA,EAAK,KAAA,EADkBA,EAAK,EAEjC,CAAA,CAAA,EAGZ,CAAA,CACJ,CAER,CAGO,SAASE,EAAc,CAAE,GAAGV,GAA6B,CAC5D,MAAMW,EAAQC,EAA0B,CACpC,SAAUZ,EAAM,UAAA,CACnB,EAED,OACII,EAACZ,EAAA,CACG,MAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"multi-select.js","sources":["../../lib/components/multi-select.tsx"],"sourcesContent":["'use client';\nimport React, { useId } from 'react';\nimport { EasyMenu, MenuItem } from '../components/menu';\nimport type { SelectOption } from '../components/select-options';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { FormField, type FormFieldProps } from './form';\n\ninterface MultipleSelectionProps {\n value: Set<string | number>;\n onChange: (v: Set<string | number>) => void;\n buttonLabel?: React.ReactNode;\n items: SelectOption[];\n}\n\nexport interface MultiSelectProps\n extends MultipleSelectionProps,\n FormFieldProps,\n Omit<React.ComponentProps<typeof EasyMenu>, 'label' | 'items'> {\n triggerLabel?: React.ReactNode;\n}\n\nexport function MultiSelect({\n items,\n value,\n onChange: setValue,\n label,\n errorMessage,\n description,\n requiredIndicator,\n ...props\n}: MultiSelectProps) {\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n\n return (\n <div className=\"group form-field\">\n <FormField {...{ label, description, errorMessage, requiredIndicator, htmlFor: fieldId }}>\n <EasyMenu\n id={fieldId}\n isNonModal={false}\n selectionMode=\"multiple\"\n selectedKeys={value}\n onSelectionChange={v => {\n if (typeof v === 'string') return;\n setValue(v);\n }}\n items={items}\n label={props.triggerLabel ?? <span className=\"tabular-nums\">{value.size}</span>}\n {...props}\n >\n {item => (\n <MenuItem id={item.id} key={item.id} isDisabled={item?.disabled}>\n {item.label}\n </MenuItem>\n )}\n </EasyMenu>\n </FormField>\n </div>\n );\n}\n\nexport interface TfMultiSelectProps extends Omit<MultiSelectProps, 'value' | 'onChange'> {}\nexport function TfMultiSelect({ ...props }: TfMultiSelectProps) {\n const field = useFieldContext<string[]>({\n disabled: props.isDisabled,\n });\n\n return (\n <MultiSelect\n requiredIndicator={field.isRequired}\n value={new Set(field.state.value)}\n // @ts-expect-error\n onChange={e => field.setValue(Array.from(e))}\n onClose={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n"],"names":["MultiSelect","items","value","setValue","label","errorMessage","description","requiredIndicator","props","generatedId","useId","fieldId","jsx","FormField","EasyMenu","v","item","MenuItem","TfMultiSelect","field","useFieldContext","e","getFieldErrorMessage"],"mappings":"wiBAsBO,SAASA,EAAY,CACxB,MAAAC,EACA,MAAAC,EACA,SAAUC,EACV,MAAAC,EACA,aAAAC,EACA,YAAAC,EACA,kBAAAC,EACA,GAAGC,CACP,EAAqB,CACjB,MAAMC,EAAcC,EAAA,EACdC,EAAUH,EAAM,IAAMC,EAE5B,OACIG,EAAC,MAAA,CAAI,UAAU,mBACX,WAACC,EAAA,CAAgB,MAAAT,EAAO,YAAAE,EAAa,aAAAD,EAAc,kBAAAE,EAAmB,QAASI,EAC3E,SAAAC,EAACE,EAAA,CACG,GAAIH,EACJ,WAAY,GACZ,cAAc,WACd,aAAcT,EACd,kBAAmBa,GAAK,CAChB,OAAOA,GAAM,UACjBZ,EAASY,CAAC,CACd,EACA,MAAAd,EACA,MAAOO,EAAM,cAAgBI,EAAC,QAAK,UAAU,eAAgB,WAAM,IAAA,CAAK,EACvE,GAAGJ,EAEH,SAAAQ,GACGJ,EAACK,EAAA,CAAS,GAAID,EAAK,GAAkB,WAAYA,GAAM,SAClD,SAAAA,EAAK,KAAA,EADkBA,EAAK,EAEjC,CAAA,CAAA,EAGZ,CAAA,CACJ,CAER,CAGO,SAASE,EAAc,CAAE,GAAGV,GAA6B,CAC5D,MAAMW,EAAQC,EAA0B,CACpC,SAAUZ,EAAM,UAAA,CACnB,EAED,OACII,EAACZ,EAAA,CACG,kBAAmBmB,EAAM,WACzB,MAAO,IAAI,IAAIA,EAAM,MAAM,KAAK,EAEhC,SAAUE,GAAKF,EAAM,SAAS,MAAM,KAAKE,CAAC,CAAC,EAC3C,QAASF,EAAM,WACf,aAAcG,EAAqBH,CAAK,EACvC,GAAGX,CAAA,CAAA,CAGhB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as m}from"react/jsx-runtime";import{NumberField as F,composeRenderProps as u,Input as v}from"react-aria-components";import{Button as x}from"./button.js";import{getFieldErrorMessage as d}from"../utilities/form.js";import{useFieldContext as p}from"../utilities/form-context.js";import{classNames as a}from"../utilities/theme.js";import{FormField as f,FieldGroup as h}from"./form.js";import{IcUp as
|
|
1
|
+
"use client";import{jsx as r,jsxs as m}from"react/jsx-runtime";import{NumberField as F,composeRenderProps as u,Input as v}from"react-aria-components";import{Button as x}from"./button.js";import{getFieldErrorMessage as d}from"../utilities/form.js";import{useFieldContext as p}from"../utilities/form-context.js";import{classNames as a}from"../utilities/theme.js";import{FormField as f,FieldGroup as h}from"./form.js";import{IcUp as I,IcDown as C}from"./icons.js";import"class-variance-authority";import"./loader.js";import"clsx";import"react";import"@tanstack/react-form";const b=F;function N({className:i,...t}){return r(v,{className:u(i,e=>a("w-fit min-w-0 flex-1 border-r border-transparent bg-elevation-2 outline-0 placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden",e)),...t})}function w({className:i,...t}){return m("div",{className:a("absolute right-0 flex h-full flex-col border-l",i),...t,children:[r(c,{slot:"increment",children:r(I,{"aria-hidden":!0,className:"size-icon"})}),r("div",{className:"border-b"}),r(c,{slot:"decrement",children:r(C,{"aria-hidden":!0,className:"size-icon"})})]})}function c({className:i,...t}){return r(x,{className:u(i,e=>a("w-auto grow h-3 px-0.5 text-muted-foreground",e)),variant:"ghost",size:"none",...t})}function D({label:i,description:t,errorMessage:e,requiredIndicator:n,className:o,...l}){return r(b,{className:u(o,s=>a("group form-field",s)),...l,children:r(f,{label:i,description:t,errorMessage:e,requiredIndicator:n,children:m(h,{children:[r(N,{className:"pr-input"}),r(w,{})]})})})}function G({isDisabled:i,...t}){const e=p({disabled:i});return r(D,{isInvalid:!!d(e),isDisabled:i||e.form.state.isSubmitting,value:e.state.value,id:e.name,onChange:e.handleChange,onBlur:e.handleBlur,errorMessage:d(e),requiredIndicator:e.isRequired,...t})}function S({label:i,description:t,errorMessage:e,requiredIndicator:n,className:o,...l}){return r(b,{className:u(o,s=>a("group form-field",s)),...l,children:r(f,{label:i,description:t,errorMessage:e,requiredIndicator:n,children:m(h,{children:[r(N,{className:"pr-input"}),r("div",{className:"absolute right-1 select-none text-muted",children:"days"})]})})})}function O({isDisabled:i,...t}){const e=p({disabled:i}),n=86400,o=e.state.value!=null?e.state.value/n:void 0,l=s=>{const g=s*n;e.handleChange(g)};return r(S,{isInvalid:!!d(e),isDisabled:i||e.form.state.isSubmitting,value:o,id:e.name,onChange:l,onBlur:e.handleBlur,errorMessage:d(e),requiredIndicator:e.isRequired,...t})}export{S as DaysField,D as NumberField,N as NumberFieldInput,O as TfDaysField,G as TfNumberField};
|
|
2
2
|
//# sourceMappingURL=numberfield.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberfield.js","sources":["../../lib/components/numberfield.tsx"],"sourcesContent":["'use client';\nimport {\n ButtonProps as AriaButtonProps,\n Input as AriaInput,\n InputProps as AriaInputProps,\n NumberField as AriaNumberField,\n NumberFieldProps as AriaNumberFieldProps,\n composeRenderProps,\n} from 'react-aria-components';\n\nimport { Button } from '../components/button';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { classNames } from '../utilities/theme';\nimport { FieldGroup, FormField, type FormFieldProps } from './form';\nimport { IcDown, IcUp } from './icons';\n\nconst ANumberField = AriaNumberField;\n\nexport function NumberFieldInput({ className, ...props }: AriaInputProps) {\n return (\n <AriaInput\n className={composeRenderProps(className, className =>\n classNames(\n 'w-fit min-w-0 flex-1 border-r border-transparent bg-elevation-2 outline-0 placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden',\n className\n )\n )}\n {...props}\n />\n );\n}\n\nfunction NumberFieldSteppers({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div className={classNames('absolute right-0 flex h-full flex-col border-l', className)} {...props}>\n <NumberFieldStepper slot=\"increment\">\n <IcUp aria-hidden className=\"size-icon\" />\n </NumberFieldStepper>\n <div className=\"border-b\" />\n <NumberFieldStepper slot=\"decrement\">\n <IcDown aria-hidden className=\"size-icon\" />\n </NumberFieldStepper>\n </div>\n );\n}\n\nfunction NumberFieldStepper({ className, ...props }: AriaButtonProps) {\n return (\n <Button\n className={composeRenderProps(className, className =>\n classNames('w-auto grow h-3 px-0.5 text-muted-foreground', className)\n )}\n variant={'ghost'}\n size={'none'}\n {...props}\n />\n );\n}\n\nexport type NumberFieldProps = AriaNumberFieldProps & FormFieldProps;\nexport function NumberField({\n label,\n description,\n errorMessage,\n requiredIndicator,\n className,\n ...props\n}: NumberFieldProps) {\n return (\n <ANumberField\n className={composeRenderProps(className, className => classNames('group form-field', className))}\n {...props}\n >\n <FormField {...{ label, description, errorMessage, requiredIndicator }}>\n <FieldGroup>\n <NumberFieldInput className={'pr-input'} />\n <NumberFieldSteppers />\n </FieldGroup>\n </FormField>\n </ANumberField>\n );\n}\n\nexport function TfNumberField({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof NumberField>, 'value' | 'id' | 'onChange' | 'onBlur'>) {\n const field = useFieldContext<number>({ disabled: isDisabled });\n\n return (\n <NumberField\n isInvalid={!!getFieldErrorMessage(field)}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n id={field.name}\n onChange={field.handleChange}\n onBlur={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n\nexport function DaysField({\n label,\n description,\n errorMessage,\n requiredIndicator,\n className,\n ...props\n}: NumberFieldProps) {\n return (\n <ANumberField\n className={composeRenderProps(className, className => classNames('group form-field', className))}\n {...props}\n >\n <FormField {...{ label, description, errorMessage, requiredIndicator }}>\n <FieldGroup>\n <NumberFieldInput className={'pr-input'} />\n <div className=\"absolute right-1 select-none text-muted\">days</div>\n </FieldGroup>\n </FormField>\n </ANumberField>\n );\n}\n\nexport function TfDaysField({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof DaysField>, 'value' | 'id' | 'onChange' | 'onBlur'>) {\n const field = useFieldContext<number>({ disabled: isDisabled });\n\n const SECONDS_PER_DAY = 86400; // 24 * 60 * 60\n\n // Convert seconds to days for display\n const daysValue = field.state.value != null ? field.state.value / SECONDS_PER_DAY : undefined;\n\n // Convert days to seconds when value changes\n const handleDaysChange = (days: number) => {\n const seconds = days * SECONDS_PER_DAY;\n field.handleChange(seconds);\n };\n\n return (\n <DaysField\n isInvalid={!!getFieldErrorMessage(field)}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={daysValue}\n id={field.name}\n onChange={handleDaysChange}\n onBlur={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n"],"names":["ANumberField","AriaNumberField","NumberFieldInput","className","props","jsx","AriaInput","composeRenderProps","classNames","NumberFieldSteppers","jsxs","NumberFieldStepper","IcUp","IcDown","Button","NumberField","label","description","errorMessage","requiredIndicator","FormField","FieldGroup","TfNumberField","isDisabled","field","useFieldContext","getFieldErrorMessage","DaysField","TfDaysField","SECONDS_PER_DAY","daysValue","handleDaysChange","days","seconds"],"mappings":"0jBAiBA,MAAMA,EAAeC,EAEd,SAASC,EAAiB,CAAE,UAAAC,EAAW,GAAGC,GAAyB,CACtE,OACIC,EAACC,EAAA,CACG,UAAWC,EAAmBJ,EAAWA,GACrCK,EACI,uJACAL,CAAA,CACJ,EAEH,GAAGC,CAAA,CAAA,CAGhB,CAEA,SAASK,EAAoB,CAAE,UAAAN,EAAW,GAAGC,GAAsC,CAC/E,OACIM,EAAC,OAAI,UAAWF,EAAW,iDAAkDL,CAAS,EAAI,GAAGC,EACzF,SAAA,CAAAC,EAACM,EAAA,CAAmB,KAAK,YACrB,SAAAN,EAACO,GAAK,cAAW,GAAC,UAAU,WAAA,CAAY,CAAA,CAC5C,EACAP,EAAC,MAAA,CAAI,UAAU,UAAA,CAAW,EAC1BA,EAACM,EAAA,CAAmB,KAAK,YACrB,SAAAN,EAACQ,GAAO,cAAW,GAAC,UAAU,WAAA,CAAY,CAAA,CAC9C,CAAA,EACJ,CAER,CAEA,SAASF,EAAmB,CAAE,UAAAR,EAAW,GAAGC,GAA0B,CAClE,OACIC,EAACS,EAAA,CACG,UAAWP,EAAmBJ,EAAWA,GACrCK,EAAW,+CAAgDL,CAAS,CAAA,EAExE,QAAS,QACT,KAAM,OACL,GAAGC,CAAA,CAAA,CAGhB,CAGO,SAASW,EAAY,CACxB,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,UAAAhB,EACA,GAAGC,CACP,EAAqB,CACjB,OACIC,EAACL,EAAA,CACG,UAAWO,EAAmBJ,EAAWA,GAAaK,EAAW,mBAAoBL,CAAS,CAAC,EAC9F,GAAGC,EAEJ,SAAAC,EAACe,EAAA,CAAgB,MAAAJ,EAAO,YAAAC,EAAa,aAAAC,EAAc,kBAAAC,EAC/C,SAAAT,EAACW,EAAA,CACG,SAAA,CAAAhB,EAACH,EAAA,CAAiB,UAAW,UAAA,CAAY,IACxCO,EAAA,CAAA,CAAoB,CAAA,CAAA,CACzB,CAAA,CACJ,CAAA,CAAA,CAGZ,CAEO,SAASa,EAAc,CAC1B,WAAAC,EACA,GAAGnB,CACP,EAA2F,CACvF,MAAMoB,EAAQC,EAAwB,CAAE,SAAUF,EAAY,EAE9D,OACIlB,EAACU,EAAA,CACG,UAAW,CAAC,CAACW,EAAqBF,CAAK,EACvC,WAAYD,GAAcC,EAAM,KAAK,MAAM,aAC3C,MAAOA,EAAM,MAAM,MACnB,GAAIA,EAAM,KACV,SAAUA,EAAM,aAChB,OAAQA,EAAM,WACd,aAAcE,EAAqBF,CAAK,
|
|
1
|
+
{"version":3,"file":"numberfield.js","sources":["../../lib/components/numberfield.tsx"],"sourcesContent":["'use client';\nimport {\n ButtonProps as AriaButtonProps,\n Input as AriaInput,\n InputProps as AriaInputProps,\n NumberField as AriaNumberField,\n NumberFieldProps as AriaNumberFieldProps,\n composeRenderProps,\n} from 'react-aria-components';\n\nimport { Button } from '../components/button';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { classNames } from '../utilities/theme';\nimport { FieldGroup, FormField, type FormFieldProps } from './form';\nimport { IcDown, IcUp } from './icons';\n\nconst ANumberField = AriaNumberField;\n\nexport function NumberFieldInput({ className, ...props }: AriaInputProps) {\n return (\n <AriaInput\n className={composeRenderProps(className, className =>\n classNames(\n 'w-fit min-w-0 flex-1 border-r border-transparent bg-elevation-2 outline-0 placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden',\n className\n )\n )}\n {...props}\n />\n );\n}\n\nfunction NumberFieldSteppers({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div className={classNames('absolute right-0 flex h-full flex-col border-l', className)} {...props}>\n <NumberFieldStepper slot=\"increment\">\n <IcUp aria-hidden className=\"size-icon\" />\n </NumberFieldStepper>\n <div className=\"border-b\" />\n <NumberFieldStepper slot=\"decrement\">\n <IcDown aria-hidden className=\"size-icon\" />\n </NumberFieldStepper>\n </div>\n );\n}\n\nfunction NumberFieldStepper({ className, ...props }: AriaButtonProps) {\n return (\n <Button\n className={composeRenderProps(className, className =>\n classNames('w-auto grow h-3 px-0.5 text-muted-foreground', className)\n )}\n variant={'ghost'}\n size={'none'}\n {...props}\n />\n );\n}\n\nexport type NumberFieldProps = AriaNumberFieldProps & FormFieldProps;\nexport function NumberField({\n label,\n description,\n errorMessage,\n requiredIndicator,\n className,\n ...props\n}: NumberFieldProps) {\n return (\n <ANumberField\n className={composeRenderProps(className, className => classNames('group form-field', className))}\n {...props}\n >\n <FormField {...{ label, description, errorMessage, requiredIndicator }}>\n <FieldGroup>\n <NumberFieldInput className={'pr-input'} />\n <NumberFieldSteppers />\n </FieldGroup>\n </FormField>\n </ANumberField>\n );\n}\n\nexport function TfNumberField({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof NumberField>, 'value' | 'id' | 'onChange' | 'onBlur'>) {\n const field = useFieldContext<number>({ disabled: isDisabled });\n\n return (\n <NumberField\n isInvalid={!!getFieldErrorMessage(field)}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n id={field.name}\n onChange={field.handleChange}\n onBlur={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n requiredIndicator={field.isRequired}\n {...props}\n />\n );\n}\n\nexport function DaysField({\n label,\n description,\n errorMessage,\n requiredIndicator,\n className,\n ...props\n}: NumberFieldProps) {\n return (\n <ANumberField\n className={composeRenderProps(className, className => classNames('group form-field', className))}\n {...props}\n >\n <FormField {...{ label, description, errorMessage, requiredIndicator }}>\n <FieldGroup>\n <NumberFieldInput className={'pr-input'} />\n <div className=\"absolute right-1 select-none text-muted\">days</div>\n </FieldGroup>\n </FormField>\n </ANumberField>\n );\n}\n\nexport function TfDaysField({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof DaysField>, 'value' | 'id' | 'onChange' | 'onBlur'>) {\n const field = useFieldContext<number>({ disabled: isDisabled });\n\n const SECONDS_PER_DAY = 86400; // 24 * 60 * 60\n\n // Convert seconds to days for display\n const daysValue = field.state.value != null ? field.state.value / SECONDS_PER_DAY : undefined;\n\n // Convert days to seconds when value changes\n const handleDaysChange = (days: number) => {\n const seconds = days * SECONDS_PER_DAY;\n field.handleChange(seconds);\n };\n\n return (\n <DaysField\n isInvalid={!!getFieldErrorMessage(field)}\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={daysValue}\n id={field.name}\n onChange={handleDaysChange}\n onBlur={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n requiredIndicator={field.isRequired}\n {...props}\n />\n );\n}\n"],"names":["ANumberField","AriaNumberField","NumberFieldInput","className","props","jsx","AriaInput","composeRenderProps","classNames","NumberFieldSteppers","jsxs","NumberFieldStepper","IcUp","IcDown","Button","NumberField","label","description","errorMessage","requiredIndicator","FormField","FieldGroup","TfNumberField","isDisabled","field","useFieldContext","getFieldErrorMessage","DaysField","TfDaysField","SECONDS_PER_DAY","daysValue","handleDaysChange","days","seconds"],"mappings":"0jBAiBA,MAAMA,EAAeC,EAEd,SAASC,EAAiB,CAAE,UAAAC,EAAW,GAAGC,GAAyB,CACtE,OACIC,EAACC,EAAA,CACG,UAAWC,EAAmBJ,EAAWA,GACrCK,EACI,uJACAL,CAAA,CACJ,EAEH,GAAGC,CAAA,CAAA,CAGhB,CAEA,SAASK,EAAoB,CAAE,UAAAN,EAAW,GAAGC,GAA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GAAIA,EAAM,KACV,SAAUA,EAAM,aAChB,OAAQA,EAAM,WACd,aAAcE,EAAqBF,CAAK,EACxC,kBAAmBA,EAAM,WACxB,GAAGpB,CAAA,CAAA,CAGhB,CAEO,SAASuB,EAAU,CACtB,MAAAX,EACA,YAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,UAAAhB,EACA,GAAGC,CACP,EAAqB,CACjB,OACIC,EAACL,EAAA,CACG,UAAWO,EAAmBJ,EAAWA,GAAaK,EAAW,mBAAoBL,CAAS,CAAC,EAC9F,GAAGC,EAEJ,SAAAC,EAACe,EAAA,CAAgB,MAAAJ,EAAO,YAAAC,EAAa,aAAAC,EAAc,kBAAAC,EAC/C,SAAAT,EAACW,EAAA,CACG,SAAA,CAAAhB,EAACH,EAAA,CAAiB,UAAW,UAAA,CAAY,EACzCG,EAAC,MAAA,CAAI,UAAU,0CAA0C,SAAA,MAAA,CAAI,CAAA,CAAA,CACjE,CAAA,CACJ,CAAA,CAAA,CAGZ,CAEO,SAASuB,EAAY,CACxB,WAAAL,EACA,GAAGnB,CACP,EAAyF,CACrF,MAAMoB,EAAQC,EAAwB,CAAE,SAAUF,EAAY,EAExDM,EAAkB,MAGlBC,EAAYN,EAAM,MAAM,OAAS,KAAOA,EAAM,MAAM,MAAQK,EAAkB,OAG9EE,EAAoBC,GAAiB,CACvC,MAAMC,EAAUD,EAAOH,EACvBL,EAAM,aAAaS,CAAO,CAC9B,EAEA,OACI5B,EAACsB,EAAA,CACG,UAAW,CAAC,CAACD,EAAqBF,CAAK,EACvC,WAAYD,GAAcC,EAAM,KAAK,MAAM,aAC3C,MAAOM,EACP,GAAIN,EAAM,KACV,SAAUO,EACV,OAAQP,EAAM,WACd,aAAcE,EAAqBF,CAAK,EACxC,kBAAmBA,EAAM,WACxB,GAAGpB,CAAA,CAAA,CAGhB"}
|
|
@@ -15,3 +15,4 @@ export declare function getCountryFlag(country: string): string;
|
|
|
15
15
|
export declare function getCountryName(country: string): string;
|
|
16
16
|
/** Options for MultiSelect component */
|
|
17
17
|
export declare const COUNTRY_OPTIONS: SelectOption[];
|
|
18
|
+
export declare const DATA_REGION_OPTIONS: SelectOption[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as n,Fragment as i,jsx as e}from"react/jsx-runtime";import{IcNodeLocked as
|
|
1
|
+
import{jsxs as n,Fragment as i,jsx as e}from"react/jsx-runtime";import{IcNodeLocked as s,IcHostedFloating as d,IcLexFloatServer as u}from"./icons.js";import"react";const C=[{label:n(i,{children:["Node-locked",e(s,{})]}),id:"node-locked"},{label:n(i,{children:["Hosted floating",e(d,{})]}),id:"hosted-floating"},{label:n(i,{children:["LexFloatServer",e(u,{})]}),id:"on-premise-floating"}],m=[{label:"License Creation",id:"creation"},{label:"License Activation",id:"activation"}];function o(a){function r(l){return String.fromCodePoint(127397+l.toUpperCase().charCodeAt(0))}return r(a[0])+r(a[1])}const t={AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia (Plurinational State of)",BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",CV:"Caboe Verde",KH:"Cambodia",CM:"Cameroon",CA:"Canada",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, Democratic Republic of the",CK:"Cook Islands",CR:"Costa Rica",CI:"Côte d'voire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czechia",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",SZ:"Eswatini",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and Mcdonald Islands",VA:"Holy See",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran (Islamic Republic of)",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"Korea (Democratic People's Republic of)",KR:"Korea (Republic of)",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia (Federated States of)",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands, Kingdom of the",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MK:"North Macedonia",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension Island, Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Türkiye",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom of Great Britain and Northern Ireland",UM:"United States Minor Outlying Islands",US:"United States of America",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela (Bolivarian Republic of)",VN:"Viet Nam",VG:"Virgin Islands (British)",VI:"Virgin Islands (U.S)",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"};function T(a){return t[a]}const A=Object.entries(t).map(a=>({label:n(i,{children:[o(a[0])," ",a[1]]}),id:a[0]})),S={us:"United States",eu:"European Union"},G=Object.entries(S).map(a=>({label:n(i,{children:[o(a[0])," ",a[1]]}),id:a[0]}));export{A as COUNTRY_OPTIONS,G as DATA_REGION_OPTIONS,C as LICENSE_TYPE_OPTIONS,m as SUBSCRIPTION_START_TRIGGER_OPTIONS,o as getCountryFlag,T as getCountryName};
|
|
2
2
|
//# sourceMappingURL=select-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-options.js","sources":["../../lib/components/select-options.tsx"],"sourcesContent":["import { IcHostedFloating, IcLexFloatServer, IcNodeLocked } from './icons';\n\nexport type SelectOption = {\n id: string;\n label: React.ReactNode;\n disabled?: boolean;\n};\n\n// TODO, use icons\nexport const LICENSE_TYPE_OPTIONS: SelectOption[] = [\n {\n label: (\n <>\n Node-locked\n <IcNodeLocked />\n </>\n ),\n id: 'node-locked',\n },\n {\n label: (\n <>\n Hosted floating\n <IcHostedFloating />\n </>\n ),\n id: 'hosted-floating',\n },\n {\n label: (\n <>\n LexFloatServer\n <IcLexFloatServer />\n </>\n ),\n id: 'on-premise-floating',\n },\n];\n\nexport const SUBSCRIPTION_START_TRIGGER_OPTIONS: SelectOption[] = [\n {\n label: 'License Creation',\n id: 'creation',\n },\n {\n label: 'License Activation',\n id: 'activation',\n },\n];\n\n/**\n * Creates Unicode flag from a two-letter ISO country code.\n * https://stackoverflow.com/questions/24050671/how-to-put-japan-flag-character-in-a-string\n * @param {string} country — A two-letter ISO country code (case-insensitive).\n * @return {string}\n */\nexport function getCountryFlag(country: string) {\n function getRegionalIndicatorSymbol(letter: string) {\n return String.fromCodePoint(0x1f1e6 - 65 + letter.toUpperCase().charCodeAt(0));\n }\n\n return getRegionalIndicatorSymbol(country[0]) + getRegionalIndicatorSymbol(country[1]);\n}\n\nconst ALL_COUNTRIES: { [key: string]: string } = {\n AF: 'Afghanistan',\n AX: 'Åland Islands',\n AL: 'Albania',\n DZ: 'Algeria',\n AS: 'American Samoa',\n AD: 'Andorra',\n AO: 'Angola',\n AI: 'Anguilla',\n AQ: 'Antarctica',\n AG: 'Antigua and Barbuda',\n AR: 'Argentina',\n AM: 'Armenia',\n AW: 'Aruba',\n AU: 'Australia',\n AT: 'Austria',\n AZ: 'Azerbaijan',\n BS: 'Bahamas',\n BH: 'Bahrain',\n BD: 'Bangladesh',\n BB: 'Barbados',\n BY: 'Belarus',\n BE: 'Belgium',\n BZ: 'Belize',\n BJ: 'Benin',\n BM: 'Bermuda',\n BT: 'Bhutan',\n BO: 'Bolivia (Plurinational State of)',\n BQ: 'Bonaire, Sint Eustatius and Saba',\n BA: 'Bosnia and Herzegovina',\n BW: 'Botswana',\n BV: 'Bouvet Island',\n BR: 'Brazil',\n IO: 'British Indian Ocean Territory',\n BN: 'Brunei Darussalam',\n BG: 'Bulgaria',\n BF: 'Burkina Faso',\n BI: 'Burundi',\n CV: 'Caboe Verde',\n KH: 'Cambodia',\n CM: 'Cameroon',\n CA: 'Canada',\n KY: 'Cayman Islands',\n CF: 'Central African Republic',\n TD: 'Chad',\n CL: 'Chile',\n CN: 'China',\n CX: 'Christmas Island',\n CC: 'Cocos (Keeling) Islands',\n CO: 'Colombia',\n KM: 'Comoros',\n CG: 'Congo',\n CD: 'Congo, Democratic Republic of the',\n CK: 'Cook Islands',\n CR: 'Costa Rica',\n CI: \"Côte d'voire\",\n HR: 'Croatia',\n CU: 'Cuba',\n CW: 'Curaçao',\n CY: 'Cyprus',\n CZ: 'Czechia',\n DK: 'Denmark',\n DJ: 'Djibouti',\n DM: 'Dominica',\n DO: 'Dominican Republic',\n EC: 'Ecuador',\n EG: 'Egypt',\n SV: 'El Salvador',\n GQ: 'Equatorial Guinea',\n ER: 'Eritrea',\n EE: 'Estonia',\n SZ: 'Eswatini',\n ET: 'Ethiopia',\n FK: 'Falkland Islands (Malvinas)',\n FO: 'Faroe Islands',\n FJ: 'Fiji',\n FI: 'Finland',\n FR: 'France',\n GF: 'French Guiana',\n PF: 'French Polynesia',\n TF: 'French Southern Territories',\n GA: 'Gabon',\n GM: 'Gambia',\n GE: 'Georgia',\n DE: 'Germany',\n GH: 'Ghana',\n GI: 'Gibraltar',\n GR: 'Greece',\n GL: 'Greenland',\n GD: 'Grenada',\n GP: 'Guadeloupe',\n GU: 'Guam',\n GT: 'Guatemala',\n GG: 'Guernsey',\n GN: 'Guinea',\n GW: 'Guinea-Bissau',\n GY: 'Guyana',\n HT: 'Haiti',\n HM: 'Heard Island and Mcdonald Islands',\n VA: 'Holy See',\n HN: 'Honduras',\n HK: 'Hong Kong',\n HU: 'Hungary',\n IS: 'Iceland',\n IN: 'India',\n ID: 'Indonesia',\n IR: 'Iran (Islamic Republic of)',\n IQ: 'Iraq',\n IE: 'Ireland',\n IM: 'Isle of Man',\n IL: 'Israel',\n IT: 'Italy',\n JM: 'Jamaica',\n JP: 'Japan',\n JE: 'Jersey',\n JO: 'Jordan',\n KZ: 'Kazakhstan',\n KE: 'Kenya',\n KI: 'Kiribati',\n KP: \"Korea (Democratic People's Republic of)\",\n KR: 'Korea (Republic of)',\n KW: 'Kuwait',\n KG: 'Kyrgyzstan',\n LA: \"Lao People's Democratic Republic\",\n LV: 'Latvia',\n LB: 'Lebanon',\n LS: 'Lesotho',\n LR: 'Liberia',\n LY: 'Libya',\n LI: 'Liechtenstein',\n LT: 'Lithuania',\n LU: 'Luxembourg',\n MO: 'Macao',\n MG: 'Madagascar',\n MW: 'Malawi',\n MY: 'Malaysia',\n MV: 'Maldives',\n ML: 'Mali',\n MT: 'Malta',\n MH: 'Marshall Islands',\n MQ: 'Martinique',\n MR: 'Mauritania',\n MU: 'Mauritius',\n YT: 'Mayotte',\n MX: 'Mexico',\n FM: 'Micronesia (Federated States of)',\n MD: 'Moldova, Republic of',\n MC: 'Monaco',\n MN: 'Mongolia',\n ME: 'Montenegro',\n MS: 'Montserrat',\n MA: 'Morocco',\n MZ: 'Mozambique',\n MM: 'Myanmar',\n NA: 'Namibia',\n NR: 'Nauru',\n NP: 'Nepal',\n NL: 'Netherlands, Kingdom of the',\n NC: 'New Caledonia',\n NZ: 'New Zealand',\n NI: 'Nicaragua',\n NE: 'Niger',\n NG: 'Nigeria',\n NU: 'Niue',\n NF: 'Norfolk Island',\n MK: 'North Macedonia',\n MP: 'Northern Mariana Islands',\n NO: 'Norway',\n OM: 'Oman',\n PK: 'Pakistan',\n PW: 'Palau',\n PS: 'Palestine, State of',\n PA: 'Panama',\n PG: 'Papua New Guinea',\n PY: 'Paraguay',\n PE: 'Peru',\n PH: 'Philippines',\n PN: 'Pitcairn',\n PL: 'Poland',\n PT: 'Portugal',\n PR: 'Puerto Rico',\n QA: 'Qatar',\n RE: 'Réunion',\n RO: 'Romania',\n RU: 'Russian Federation',\n RW: 'Rwanda',\n BL: 'Saint Barthélemy',\n SH: 'Saint Helena, Ascension Island, Tristan da Cunha',\n KN: 'Saint Kitts and Nevis',\n LC: 'Saint Lucia',\n MF: 'Saint Martin (French part)',\n PM: 'Saint Pierre and Miquelon',\n VC: 'Saint Vincent and the Grenadines',\n WS: 'Samoa',\n SM: 'San Marino',\n ST: 'Sao Tome and Principe',\n SA: 'Saudi Arabia',\n SN: 'Senegal',\n RS: 'Serbia',\n SC: 'Seychelles',\n SL: 'Sierra Leone',\n SG: 'Singapore',\n SX: 'Sint Maarten (Dutch part)',\n SK: 'Slovakia',\n SI: 'Slovenia',\n SB: 'Solomon Islands',\n SO: 'Somalia',\n ZA: 'South Africa',\n GS: 'South Georgia and the South Sandwich Islands',\n SS: 'South Sudan',\n ES: 'Spain',\n LK: 'Sri Lanka',\n SD: 'Sudan',\n SR: 'Suriname',\n SJ: 'Svalbard and Jan Mayen',\n SE: 'Sweden',\n CH: 'Switzerland',\n SY: 'Syrian Arab Republic',\n TW: 'Taiwan, Province of China',\n TJ: 'Tajikistan',\n TZ: 'Tanzania, United Republic of',\n TH: 'Thailand',\n TL: 'Timor-Leste',\n TG: 'Togo',\n TK: 'Tokelau',\n TO: 'Tonga',\n TT: 'Trinidad and Tobago',\n TN: 'Tunisia',\n TR: 'Türkiye',\n TM: 'Turkmenistan',\n TC: 'Turks and Caicos Islands',\n TV: 'Tuvalu',\n UG: 'Uganda',\n UA: 'Ukraine',\n AE: 'United Arab Emirates',\n GB: 'United Kingdom of Great Britain and Northern Ireland',\n UM: 'United States Minor Outlying Islands',\n US: 'United States of America',\n UY: 'Uruguay',\n UZ: 'Uzbekistan',\n VU: 'Vanuatu',\n VE: 'Venezuela (Bolivarian Republic of)',\n VN: 'Viet Nam',\n VG: 'Virgin Islands (British)',\n VI: 'Virgin Islands (U.S)',\n WF: 'Wallis and Futuna',\n EH: 'Western Sahara',\n YE: 'Yemen',\n ZM: 'Zambia',\n ZW: 'Zimbabwe',\n};\n\nexport function getCountryName(country: string) {\n return ALL_COUNTRIES[country];\n}\n\n/** Options for MultiSelect component */\nexport const COUNTRY_OPTIONS: SelectOption[] = Object.entries(ALL_COUNTRIES).map(v => {\n return {\n label: (\n <>\n {getCountryFlag(v[0])} {v[1]}\n </>\n ),\n id: v[0],\n };\n});\n"],"names":["LICENSE_TYPE_OPTIONS","jsxs","Fragment","IcNodeLocked","IcHostedFloating","IcLexFloatServer","SUBSCRIPTION_START_TRIGGER_OPTIONS","getCountryFlag","country","getRegionalIndicatorSymbol","letter","ALL_COUNTRIES","getCountryName","COUNTRY_OPTIONS","v"],"mappings":"oKASO,MAAMA,EAAuC,CAChD,CACI,MACIC,EAAAC,EAAA,CAAE,SAAA,CAAA,gBAEGC,EAAA,CAAA,CAAa,CAAA,EAClB,EAEJ,GAAI,aAAA,EAER,CACI,MACIF,EAAAC,EAAA,CAAE,SA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IG,IACtE,CACH,MACIb,EAAAC,EAAA,CACK,SAAA,CAAAK,EAAeO,EAAE,CAAC,CAAC,EAAE,IAAEA,EAAE,CAAC,CAAA,EAC/B,EAEJ,GAAIA,EAAE,CAAC,CAAA,EAEd"}
|
|
1
|
+
{"version":3,"file":"select-options.js","sources":["../../lib/components/select-options.tsx"],"sourcesContent":["import { IcHostedFloating, IcLexFloatServer, IcNodeLocked } from './icons';\n\nexport type SelectOption = {\n id: string;\n label: React.ReactNode;\n disabled?: boolean;\n};\n\n// TODO, use icons\nexport const LICENSE_TYPE_OPTIONS: SelectOption[] = [\n {\n label: (\n <>\n Node-locked\n <IcNodeLocked />\n </>\n ),\n id: 'node-locked',\n },\n {\n label: (\n <>\n Hosted floating\n <IcHostedFloating />\n </>\n ),\n id: 'hosted-floating',\n },\n {\n label: (\n <>\n LexFloatServer\n <IcLexFloatServer />\n </>\n ),\n id: 'on-premise-floating',\n },\n];\n\nexport const SUBSCRIPTION_START_TRIGGER_OPTIONS: SelectOption[] = [\n {\n label: 'License Creation',\n id: 'creation',\n },\n {\n label: 'License Activation',\n id: 'activation',\n },\n];\n\n/**\n * Creates Unicode flag from a two-letter ISO country code.\n * https://stackoverflow.com/questions/24050671/how-to-put-japan-flag-character-in-a-string\n * @param {string} country — A two-letter ISO country code (case-insensitive).\n * @return {string}\n */\nexport function getCountryFlag(country: string) {\n function getRegionalIndicatorSymbol(letter: string) {\n return String.fromCodePoint(0x1f1e6 - 65 + letter.toUpperCase().charCodeAt(0));\n }\n\n return getRegionalIndicatorSymbol(country[0]) + getRegionalIndicatorSymbol(country[1]);\n}\n\nconst ALL_COUNTRIES: { [key: string]: string } = {\n AF: 'Afghanistan',\n AX: 'Åland Islands',\n AL: 'Albania',\n DZ: 'Algeria',\n AS: 'American Samoa',\n AD: 'Andorra',\n AO: 'Angola',\n AI: 'Anguilla',\n AQ: 'Antarctica',\n AG: 'Antigua and Barbuda',\n AR: 'Argentina',\n AM: 'Armenia',\n AW: 'Aruba',\n AU: 'Australia',\n AT: 'Austria',\n AZ: 'Azerbaijan',\n BS: 'Bahamas',\n BH: 'Bahrain',\n BD: 'Bangladesh',\n BB: 'Barbados',\n BY: 'Belarus',\n BE: 'Belgium',\n BZ: 'Belize',\n BJ: 'Benin',\n BM: 'Bermuda',\n BT: 'Bhutan',\n BO: 'Bolivia (Plurinational State of)',\n BQ: 'Bonaire, Sint Eustatius and Saba',\n BA: 'Bosnia and Herzegovina',\n BW: 'Botswana',\n BV: 'Bouvet Island',\n BR: 'Brazil',\n IO: 'British Indian Ocean Territory',\n BN: 'Brunei Darussalam',\n BG: 'Bulgaria',\n BF: 'Burkina Faso',\n BI: 'Burundi',\n CV: 'Caboe Verde',\n KH: 'Cambodia',\n CM: 'Cameroon',\n CA: 'Canada',\n KY: 'Cayman Islands',\n CF: 'Central African Republic',\n TD: 'Chad',\n CL: 'Chile',\n CN: 'China',\n CX: 'Christmas Island',\n CC: 'Cocos (Keeling) Islands',\n CO: 'Colombia',\n KM: 'Comoros',\n CG: 'Congo',\n CD: 'Congo, Democratic Republic of the',\n CK: 'Cook Islands',\n CR: 'Costa Rica',\n CI: \"Côte d'voire\",\n HR: 'Croatia',\n CU: 'Cuba',\n CW: 'Curaçao',\n CY: 'Cyprus',\n CZ: 'Czechia',\n DK: 'Denmark',\n DJ: 'Djibouti',\n DM: 'Dominica',\n DO: 'Dominican Republic',\n EC: 'Ecuador',\n EG: 'Egypt',\n SV: 'El Salvador',\n GQ: 'Equatorial Guinea',\n ER: 'Eritrea',\n EE: 'Estonia',\n SZ: 'Eswatini',\n ET: 'Ethiopia',\n FK: 'Falkland Islands (Malvinas)',\n FO: 'Faroe Islands',\n FJ: 'Fiji',\n FI: 'Finland',\n FR: 'France',\n GF: 'French Guiana',\n PF: 'French Polynesia',\n TF: 'French Southern Territories',\n GA: 'Gabon',\n GM: 'Gambia',\n GE: 'Georgia',\n DE: 'Germany',\n GH: 'Ghana',\n GI: 'Gibraltar',\n GR: 'Greece',\n GL: 'Greenland',\n GD: 'Grenada',\n GP: 'Guadeloupe',\n GU: 'Guam',\n GT: 'Guatemala',\n GG: 'Guernsey',\n GN: 'Guinea',\n GW: 'Guinea-Bissau',\n GY: 'Guyana',\n HT: 'Haiti',\n HM: 'Heard Island and Mcdonald Islands',\n VA: 'Holy See',\n HN: 'Honduras',\n HK: 'Hong Kong',\n HU: 'Hungary',\n IS: 'Iceland',\n IN: 'India',\n ID: 'Indonesia',\n IR: 'Iran (Islamic Republic of)',\n IQ: 'Iraq',\n IE: 'Ireland',\n IM: 'Isle of Man',\n IL: 'Israel',\n IT: 'Italy',\n JM: 'Jamaica',\n JP: 'Japan',\n JE: 'Jersey',\n JO: 'Jordan',\n KZ: 'Kazakhstan',\n KE: 'Kenya',\n KI: 'Kiribati',\n KP: \"Korea (Democratic People's Republic of)\",\n KR: 'Korea (Republic of)',\n KW: 'Kuwait',\n KG: 'Kyrgyzstan',\n LA: \"Lao People's Democratic Republic\",\n LV: 'Latvia',\n LB: 'Lebanon',\n LS: 'Lesotho',\n LR: 'Liberia',\n LY: 'Libya',\n LI: 'Liechtenstein',\n LT: 'Lithuania',\n LU: 'Luxembourg',\n MO: 'Macao',\n MG: 'Madagascar',\n MW: 'Malawi',\n MY: 'Malaysia',\n MV: 'Maldives',\n ML: 'Mali',\n MT: 'Malta',\n MH: 'Marshall Islands',\n MQ: 'Martinique',\n MR: 'Mauritania',\n MU: 'Mauritius',\n YT: 'Mayotte',\n MX: 'Mexico',\n FM: 'Micronesia (Federated States of)',\n MD: 'Moldova, Republic of',\n MC: 'Monaco',\n MN: 'Mongolia',\n ME: 'Montenegro',\n MS: 'Montserrat',\n MA: 'Morocco',\n MZ: 'Mozambique',\n MM: 'Myanmar',\n NA: 'Namibia',\n NR: 'Nauru',\n NP: 'Nepal',\n NL: 'Netherlands, Kingdom of the',\n NC: 'New Caledonia',\n NZ: 'New Zealand',\n NI: 'Nicaragua',\n NE: 'Niger',\n NG: 'Nigeria',\n NU: 'Niue',\n NF: 'Norfolk Island',\n MK: 'North Macedonia',\n MP: 'Northern Mariana Islands',\n NO: 'Norway',\n OM: 'Oman',\n PK: 'Pakistan',\n PW: 'Palau',\n PS: 'Palestine, State of',\n PA: 'Panama',\n PG: 'Papua New Guinea',\n PY: 'Paraguay',\n PE: 'Peru',\n PH: 'Philippines',\n PN: 'Pitcairn',\n PL: 'Poland',\n PT: 'Portugal',\n PR: 'Puerto Rico',\n QA: 'Qatar',\n RE: 'Réunion',\n RO: 'Romania',\n RU: 'Russian Federation',\n RW: 'Rwanda',\n BL: 'Saint Barthélemy',\n SH: 'Saint Helena, Ascension Island, Tristan da Cunha',\n KN: 'Saint Kitts and Nevis',\n LC: 'Saint Lucia',\n MF: 'Saint Martin (French part)',\n PM: 'Saint Pierre and Miquelon',\n VC: 'Saint Vincent and the Grenadines',\n WS: 'Samoa',\n SM: 'San Marino',\n ST: 'Sao Tome and Principe',\n SA: 'Saudi Arabia',\n SN: 'Senegal',\n RS: 'Serbia',\n SC: 'Seychelles',\n SL: 'Sierra Leone',\n SG: 'Singapore',\n SX: 'Sint Maarten (Dutch part)',\n SK: 'Slovakia',\n SI: 'Slovenia',\n SB: 'Solomon Islands',\n SO: 'Somalia',\n ZA: 'South Africa',\n GS: 'South Georgia and the South Sandwich Islands',\n SS: 'South Sudan',\n ES: 'Spain',\n LK: 'Sri Lanka',\n SD: 'Sudan',\n SR: 'Suriname',\n SJ: 'Svalbard and Jan Mayen',\n SE: 'Sweden',\n CH: 'Switzerland',\n SY: 'Syrian Arab Republic',\n TW: 'Taiwan, Province of China',\n TJ: 'Tajikistan',\n TZ: 'Tanzania, United Republic of',\n TH: 'Thailand',\n TL: 'Timor-Leste',\n TG: 'Togo',\n TK: 'Tokelau',\n TO: 'Tonga',\n TT: 'Trinidad and Tobago',\n TN: 'Tunisia',\n TR: 'Türkiye',\n TM: 'Turkmenistan',\n TC: 'Turks and Caicos Islands',\n TV: 'Tuvalu',\n UG: 'Uganda',\n UA: 'Ukraine',\n AE: 'United Arab Emirates',\n GB: 'United Kingdom of Great Britain and Northern Ireland',\n UM: 'United States Minor Outlying Islands',\n US: 'United States of America',\n UY: 'Uruguay',\n UZ: 'Uzbekistan',\n VU: 'Vanuatu',\n VE: 'Venezuela (Bolivarian Republic of)',\n VN: 'Viet Nam',\n VG: 'Virgin Islands (British)',\n VI: 'Virgin Islands (U.S)',\n WF: 'Wallis and Futuna',\n EH: 'Western Sahara',\n YE: 'Yemen',\n ZM: 'Zambia',\n ZW: 'Zimbabwe',\n};\n\nexport function getCountryName(country: string) {\n return ALL_COUNTRIES[country];\n}\n\n/** Options for MultiSelect component */\nexport const COUNTRY_OPTIONS: SelectOption[] = Object.entries(ALL_COUNTRIES).map(v => {\n return {\n label: (\n <>\n {getCountryFlag(v[0])} {v[1]}\n </>\n ),\n id: v[0],\n };\n});\n\nconst DATA_REGIONS: { [key: string]: string } = {\n us: 'United States',\n eu: 'European Union',\n};\nexport const DATA_REGION_OPTIONS: SelectOption[] = Object.entries(DATA_REGIONS).map(v => {\n return {\n label: (\n <>\n {getCountryFlag(v[0])} {v[1]}\n </>\n ),\n id: v[0],\n };\n});\n"],"names":["LICENSE_TYPE_OPTIONS","jsxs","Fragment","IcNodeLocked","IcHostedFloating","IcLexFloatServer","SUBSCRIPTION_START_TRIGGER_OPTIONS","getCountryFlag","country","getRegionalIndicatorSymbol","letter","ALL_COUNTRIES","getCountryName","COUNTRY_OPTIONS","v","DATA_REGIONS","DATA_REGION_OPTIONS"],"mappings":"oKASO,MAAMA,EAAuC,CAChD,CACI,MACIC,EAAAC,EAAA,CAAE,SAAA,CAAA,gBAEGC,EAAA,CAAA,CAAa,CAAA,EAClB,EAEJ,GAAI,aAAA,EAER,CACI,MACIF,EAAAC,EAAA,CAAE,SAAA,CAAA,oBAEGE,EAAA,CAAA,CAAiB,CAAA,EACtB,EAEJ,GAAI,iBAAA,EAER,CACI,MACIH,EAAAC,EAAA,CAAE,SAAA,CAAA,mBAEGG,EAAA,CAAA,CAAiB,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AA,EAEd,EAEKC,EAA0C,CAC5C,GAAI,gBACJ,GAAI,gBACR,EACaC,EAAsC,OAAO,QAAQD,CAAY,EAAE,IAAID,IACzE,CACH,MACIb,EAAAC,EAAA,CACK,SAAA,CAAAK,EAAeO,EAAE,CAAC,CAAC,EAAE,IAAEA,EAAE,CAAC,CAAA,EAC/B,EAEJ,GAAIA,EAAE,CAAC,CAAA,EAEd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as r,jsxs as a,Fragment as p}from"react/jsx-runtime";import{useId as h}from"react";import{Select as g,composeRenderProps as l,SelectValue as S,ListBox as x}from"react-aria-components";import{Button as N}from"./button.js";import{getFieldErrorMessage as B}from"../utilities/form.js";import{useFieldContext as w}from"../utilities/form-context.js";import{classNames as i}from"../utilities/theme.js";import{FormField as I}from"./form.js";import{IcDown as F}from"./icons.js";import{ListBoxItem as b,ListBoxHeader as v,ListBoxCollection as C}from"./list-box.js";import{Popover as L}from"./popover.js";import"class-variance-authority";import"./loader.js";import"clsx";import"@tanstack/react-form";const j=g,y=b,X=v,Y=C,P=({className:o,...e})=>r(S,{className:l(o,t=>i("line-clamp-1 data-[placeholder]:text-muted-foreground","[&>[slot=description]]:hidden",t)),...e});function V({className:o,children:e,...t}){return r(N,{type:"button",...t,className:i("justify-between px-2",o),children:l(e,n=>a(p,{children:[r("span",{className:"inline-flex gap-1",children:n}),r(F,{"aria-hidden":"true"})]}))})}function q({className:o,...e}){return r(L,{className:l(o,t=>i("w-auto min-w-[--trigger-width]",t)),...e})}function D({className:o,...e}){return r(x,{className:l(o,t=>i("overflow-auto p-1 outline-none",t)),...e})}function H({label:o,description:e,errorMessage:t,children:n,className:d,requiredIndicator:m,items:u,...c}){const f=h(),s=c.id||f;return r("div",{className:i("group form-field",d),children:r(I,{label:o,description:e,errorMessage:t,requiredIndicator:m,htmlFor:s,children:a(j,{...c,children:[r(V,{className:"w-full",id:s,children:r(P,{className:"inline-flex gap-1 items-center"})}),r(q,{children:r(D,{items:u,children:n})})]})})})}function Z({...o}){const e=w({disabled:o.isDisabled});return r(H,{requiredIndicator:e.isRequired,selectedKey:e.state.value,onSelectionChange:t=>e.handleChange(t.toString()),onBlur:e.handleBlur,errorMessage:B(e),...o,children:t=>r(y,{id:t.id,children:t.label},t.id)})}export{Y as SelectCollection,X as SelectHeader,y as SelectItem,q as SelectPopover,V as SelectTrigger,P as SelectValue,H as SingleSelect,Z as TfSingleSelect};
|
|
2
2
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":["../../lib/components/select.tsx"],"sourcesContent":["'use client';\nimport { useId } from 'react';\nimport {\n ListBox as AriaListBox,\n ListBoxProps as AriaListBoxProps,\n PopoverProps as AriaPopoverProps,\n Select as AriaSelect,\n SelectProps as AriaSelectProps,\n SelectValue as AriaSelectValue,\n SelectValueProps as AriaSelectValueProps,\n composeRenderProps,\n} from 'react-aria-components';\n\nimport { Button } from '../components/button';\nimport type { SelectOption } from '../components/select-options';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { classNames } from '../utilities/theme';\nimport { FormField, type FormFieldProps } from './form';\nimport { IcDown } from './icons';\nimport { ListBoxCollection, ListBoxHeader, ListBoxItem } from './list-box';\nimport { Popover } from './popover';\n\nconst ASelect = AriaSelect;\nexport const SelectItem = ListBoxItem;\nexport const SelectHeader = ListBoxHeader;\nexport const SelectCollection = ListBoxCollection;\n\nexport const SelectValue = <T extends object>({ className, ...props }: AriaSelectValueProps<T>) => (\n <AriaSelectValue\n className={composeRenderProps(className, className =>\n classNames(\n 'line-clamp-1 data-[placeholder]:text-muted-foreground',\n /* Description */\n '[&>[slot=description]]:hidden',\n className\n )\n )}\n {...props}\n />\n);\nexport function SelectTrigger({ className, children, ...props }: React.ComponentProps<typeof Button>) {\n return (\n <Button type=\"button\" {...props} className={classNames('justify-between px-2', className)}>\n {composeRenderProps(children, children => (\n <>\n <span className=\"inline-flex gap-1\">{children}</span>\n <IcDown aria-hidden=\"true\" />\n </>\n ))}\n </Button>\n );\n}\n\nexport function SelectPopover({ className, ...props }: AriaPopoverProps) {\n return (\n <Popover\n className={composeRenderProps(className, className =>\n classNames('w-auto min-w-[--trigger-width]', className)\n )}\n {...props}\n />\n );\n}\n\nfunction SelectListBox<T extends object>({ className, ...props }: AriaListBoxProps<T>) {\n return (\n <AriaListBox\n className={composeRenderProps(className, className =>\n classNames('overflow-auto p-1 outline-none', className)\n )}\n {...props}\n />\n );\n}\n\nexport interface SingleSelectProps<T extends SelectOption>\n extends Omit<AriaSelectProps<T>, 'children'>,\n FormFieldProps {\n items: Iterable<T>;\n children: React.ReactNode | ((item: T) => React.ReactNode);\n}\n\nexport function SingleSelect<T extends SelectOption>({\n label,\n description,\n errorMessage,\n children,\n className,\n requiredIndicator,\n items,\n ...props\n}: SingleSelectProps<T>) {\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n\n return (\n <div className={classNames('group form-field', className)}>\n <FormField {...{ label, description, errorMessage, requiredIndicator, htmlFor: fieldId }}>\n <ASelect {...props}>\n <SelectTrigger className={'w-full'} id={fieldId}>\n <SelectValue className={'inline-flex gap-1 items-center'} />\n </SelectTrigger>\n <SelectPopover>\n <SelectListBox items={items}>{children}</SelectListBox>\n </SelectPopover>\n </ASelect>\n </FormField>\n </div>\n );\n}\n\ntype TfSingleSelectProps<T extends SelectOption> = Omit<SingleSelectProps<T>, 'value' | 'setValue' | 'children'>;\n\nexport function TfSingleSelect<T extends SelectOption>({ ...props }: TfSingleSelectProps<T>) {\n const field = useFieldContext<string>({ disabled: props.isDisabled });\n\n return (\n <SingleSelect\n selectedKey={field.state.value}\n onSelectionChange={e => field.handleChange(e!.toString())}\n onBlur={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n >\n {item => (\n <SelectItem id={item.id} key={item.id}>\n {item.label}\n </SelectItem>\n )}\n </SingleSelect>\n );\n}\n"],"names":["ASelect","AriaSelect","SelectItem","ListBoxItem","SelectHeader","ListBoxHeader","SelectCollection","ListBoxCollection","SelectValue","className","props","jsx","AriaSelectValue","composeRenderProps","classNames","SelectTrigger","children","Button","jsxs","Fragment","IcDown","SelectPopover","Popover","SelectListBox","AriaListBox","SingleSelect","label","description","errorMessage","requiredIndicator","items","generatedId","useId","fieldId","FormField","TfSingleSelect","field","useFieldContext","getFieldErrorMessage","item"],"mappings":"ysBAuBA,MAAMA,EAAUC,EACHC,EAAaC,EACbC,EAAeC,EACfC,EAAmBC,EAEnBC,EAAc,CAAmB,CAAE,UAAAC,EAAW,GAAGC,KAC1DC,EAACC,EAAA,CACG,UAAWC,EAAmBJ,EAAWA,GACrCK,EACI,wDAEA,gCACAL,CAAA,CACJ,EAEH,GAAGC,CAAA,CACR,EAEG,SAASK,EAAc,CAAE,UAAAN,EAAW,SAAAO,EAAU,GAAGN,GAA8C,CAClG,OACIC,EAACM,EAAA,CAAO,KAAK,SAAU,GAAGP,EAAO,UAAWI,EAAW,uBAAwBL,CAAS,EACnF,SAAAI,EAAmBG,EAAUA,GAC1BE,EAAAC,EAAA,CACI,SAAA,CAAAR,EAAC,OAAA,CAAK,UAAU,oBAAqB,SAAAK,EAAS,EAC9CL,EAACS,EAAA,CAAO,cAAY,MAAA,CAAO,CAAA,CAAA,CAC/B,CACH,CAAA,CACL,CAER,CAEO,SAASC,EAAc,CAAE,UAAAZ,EAAW,GAAGC,GAA2B,CACrE,OACIC,EAACW,EAAA,CACG,UAAWT,EAAmBJ,EAAWA,GACrCK,EAAW,iCAAkCL,CAAS,CAAA,EAEzD,GAAGC,CAAA,CAAA,CAGhB,CAEA,SAASa,EAAgC,CAAE,UAAAd,EAAW,GAAGC,GAA8B,CACnF,OACIC,EAACa,EAAA,CACG,UAAWX,EAAmBJ,EAAWA,GACrCK,EAAW,iCAAkCL,CAAS,CAAA,EAEzD,GAAGC,CAAA,CAAA,CAGhB,CASO,SAASe,EAAqC,CACjD,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,SAAAZ,EACA,UAAAP,EACA,kBAAAoB,EACA,MAAAC,EACA,GAAGpB,CACP,EAAyB,CACrB,MAAMqB,EAAcC,EAAA,EACdC,EAAUvB,EAAM,IAAMqB,EAE5B,OACIpB,EAAC,OAAI,UAAWG,EAAW,mBAAoBL,CAAS,EACpD,WAACyB,EAAA,CAAgB,MAAAR,EAAO,YAAAC,EAAa,aAAAC,EAAc,kBAAAC,EAAmB,QAASI,EAC3E,SAAAf,EAAClB,EAAA,CAAS,GAAGU,EACT,SAAA,CAAAC,EAACI,EAAA,CAAc,UAAW,SAAU,GAAIkB,EACpC,SAAAtB,EAACH,EAAA,CAAY,UAAW,gCAAA,CAAkC,CAAA,CAC9D,IACCa,EAAA,CACG,SAAAV,EAACY,EAAA,CAAc,MAAAO,EAAe,SAAAd,EAAS,CAAA,CAC3C,CAAA,CAAA,CACJ,EACJ,EACJ,CAER,CAIO,SAASmB,EAAuC,CAAE,GAAGzB,GAAiC,CACzF,MAAM0B,EAAQC,EAAwB,CAAE,SAAU3B,EAAM,WAAY,EAEpE,OACIC,EAACc,EAAA,CACG,
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../lib/components/select.tsx"],"sourcesContent":["'use client';\nimport { useId } from 'react';\nimport {\n ListBox as AriaListBox,\n ListBoxProps as AriaListBoxProps,\n PopoverProps as AriaPopoverProps,\n Select as AriaSelect,\n SelectProps as AriaSelectProps,\n SelectValue as AriaSelectValue,\n SelectValueProps as AriaSelectValueProps,\n composeRenderProps,\n} from 'react-aria-components';\n\nimport { Button } from '../components/button';\nimport type { SelectOption } from '../components/select-options';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { classNames } from '../utilities/theme';\nimport { FormField, type FormFieldProps } from './form';\nimport { IcDown } from './icons';\nimport { ListBoxCollection, ListBoxHeader, ListBoxItem } from './list-box';\nimport { Popover } from './popover';\n\nconst ASelect = AriaSelect;\nexport const SelectItem = ListBoxItem;\nexport const SelectHeader = ListBoxHeader;\nexport const SelectCollection = ListBoxCollection;\n\nexport const SelectValue = <T extends object>({ className, ...props }: AriaSelectValueProps<T>) => (\n <AriaSelectValue\n className={composeRenderProps(className, className =>\n classNames(\n 'line-clamp-1 data-[placeholder]:text-muted-foreground',\n /* Description */\n '[&>[slot=description]]:hidden',\n className\n )\n )}\n {...props}\n />\n);\nexport function SelectTrigger({ className, children, ...props }: React.ComponentProps<typeof Button>) {\n return (\n <Button type=\"button\" {...props} className={classNames('justify-between px-2', className)}>\n {composeRenderProps(children, children => (\n <>\n <span className=\"inline-flex gap-1\">{children}</span>\n <IcDown aria-hidden=\"true\" />\n </>\n ))}\n </Button>\n );\n}\n\nexport function SelectPopover({ className, ...props }: AriaPopoverProps) {\n return (\n <Popover\n className={composeRenderProps(className, className =>\n classNames('w-auto min-w-[--trigger-width]', className)\n )}\n {...props}\n />\n );\n}\n\nfunction SelectListBox<T extends object>({ className, ...props }: AriaListBoxProps<T>) {\n return (\n <AriaListBox\n className={composeRenderProps(className, className =>\n classNames('overflow-auto p-1 outline-none', className)\n )}\n {...props}\n />\n );\n}\n\nexport interface SingleSelectProps<T extends SelectOption>\n extends Omit<AriaSelectProps<T>, 'children'>,\n FormFieldProps {\n items: Iterable<T>;\n children: React.ReactNode | ((item: T) => React.ReactNode);\n}\n\nexport function SingleSelect<T extends SelectOption>({\n label,\n description,\n errorMessage,\n children,\n className,\n requiredIndicator,\n items,\n ...props\n}: SingleSelectProps<T>) {\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n\n return (\n <div className={classNames('group form-field', className)}>\n <FormField {...{ label, description, errorMessage, requiredIndicator, htmlFor: fieldId }}>\n <ASelect {...props}>\n <SelectTrigger className={'w-full'} id={fieldId}>\n <SelectValue className={'inline-flex gap-1 items-center'} />\n </SelectTrigger>\n <SelectPopover>\n <SelectListBox items={items}>{children}</SelectListBox>\n </SelectPopover>\n </ASelect>\n </FormField>\n </div>\n );\n}\n\ntype TfSingleSelectProps<T extends SelectOption> = Omit<SingleSelectProps<T>, 'value' | 'setValue' | 'children'>;\n\nexport function TfSingleSelect<T extends SelectOption>({ ...props }: TfSingleSelectProps<T>) {\n const field = useFieldContext<string>({ disabled: props.isDisabled });\n\n return (\n <SingleSelect\n requiredIndicator={field.isRequired}\n selectedKey={field.state.value}\n onSelectionChange={e => field.handleChange(e!.toString())}\n onBlur={field.handleBlur}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n >\n {item => (\n <SelectItem id={item.id} key={item.id}>\n {item.label}\n </SelectItem>\n )}\n </SingleSelect>\n );\n}\n"],"names":["ASelect","AriaSelect","SelectItem","ListBoxItem","SelectHeader","ListBoxHeader","SelectCollection","ListBoxCollection","SelectValue","className","props","jsx","AriaSelectValue","composeRenderProps","classNames","SelectTrigger","children","Button","jsxs","Fragment","IcDown","SelectPopover","Popover","SelectListBox","AriaListBox","SingleSelect","label","description","errorMessage","requiredIndicator","items","generatedId","useId","fieldId","FormField","TfSingleSelect","field","useFieldContext","e","getFieldErrorMessage","item"],"mappings":"ysBAuBA,MAAMA,EAAUC,EACHC,EAAaC,EACbC,EAAeC,EACfC,EAAmBC,EAEnBC,EAAc,CAAmB,CAAE,UAAAC,EAAW,GAAGC,KAC1DC,EAACC,EAAA,CACG,UAAWC,EAAmBJ,EAAWA,GACrCK,EACI,wDAEA,gCACAL,CAAA,CACJ,EAEH,GAAGC,CAAA,CACR,EAEG,SAASK,EAAc,CAAE,UAAAN,EAAW,SAAAO,EAAU,GAAGN,GAA8C,CAClG,OACIC,EAACM,EAAA,CAAO,KAAK,SAAU,GAAGP,EAAO,UAAWI,EAAW,uBAAwBL,CAAS,EACnF,SAAAI,EAAmBG,EAAUA,GAC1BE,EAAAC,EAAA,CACI,SAAA,CAAAR,EAAC,OAAA,CAAK,UAAU,oBAAqB,SAAAK,EAAS,EAC9CL,EAACS,EAAA,CAAO,cAAY,MAAA,CAAO,CAAA,CAAA,CAC/B,CACH,C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CAAK,EACvC,GAAG1B,EAEH,SAAA8B,KACItC,EAAA,CAAW,GAAIsC,EAAK,GAChB,SAAAA,EAAK,KAAA,EADoBA,EAAK,EAEnC,CAAA,CAAA,CAIhB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{TextField as c,composeRenderProps as o,TextArea as x,Input as g}from"react-aria-components";import{getFieldErrorMessage as s}from"../utilities/form.js";import{useFieldContext as F}from"../utilities/form-context.js";import{classNames as n}from"../utilities/theme.js";import{FormField as T,fieldGroupVariants as m}from"./form.js";import"@tanstack/react-form";import"react";import"clsx";import"class-variance-authority";import"./icons.js";const h=c;function b({className:r,...i}){return t(g,{className:o(r,e=>n(m(),"file:border-0 file:bg-transparent file:body-sm file:font-medium","disabled-muted","focus-ring",e)),...i})}function I({className:r,...i}){return t(x,{className:o(r,e=>n(m(),"h-full min-h-32",e)),...i})}function N({label:r,description:i,errorMessage:e,textArea:l,className:d,inputClassName:a,requiredIndicator:u,...f}){return t(h,{className:o(d,p=>n("group form-field",p)),...f,children:t(T,{label:r,description:i,errorMessage:e,requiredIndicator:u,children:l?t(I,{className:a}):t(b,{className:a})})})}function G({isDisabled:r,...i}){const e=F({disabled:r});return t(N,{isDisabled:r||e.form.state.isSubmitting,value:e.state.value,id:e.name,name:e.name,onBlur:e.handleBlur,onChange:e.handleChange,isInvalid:!!s(e),errorMessage:s(e),requiredIndicator:e.isRequired,...i})}export{N as TextField,G as TfTextField};
|
|
2
2
|
//# sourceMappingURL=textfield.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textfield.js","sources":["../../lib/components/textfield.tsx"],"sourcesContent":["'use client';\nimport {\n Input as AriaInput,\n InputProps as AriaInputProps,\n TextArea as AriaTextArea,\n TextAreaProps as AriaTextAreaProps,\n TextField as AriaTextField,\n TextFieldProps as AriaTextFieldProps,\n composeRenderProps,\n} from 'react-aria-components';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { classNames } from '../utilities/theme';\nimport { fieldGroupVariants, FormField, type FormFieldProps } from './form';\n\nconst ATextField = AriaTextField;\n\nfunction Input({ className, ...props }: AriaInputProps) {\n return (\n <AriaInput\n className={composeRenderProps(className, className =>\n classNames(\n fieldGroupVariants(),\n 'file:border-0 file:bg-transparent file:body-sm file:font-medium',\n /* Disabled */\n 'disabled-muted',\n /* Focused */\n 'focus-ring',\n className\n )\n )}\n {...props}\n />\n );\n}\n\nfunction TextArea({ className, ...props }: AriaTextAreaProps) {\n return (\n <AriaTextArea\n className={composeRenderProps(className, className =>\n classNames(fieldGroupVariants(), 'h-full min-h-32', className)\n )}\n {...props}\n />\n );\n}\n\nexport interface TextFieldProps extends AriaTextFieldProps, FormFieldProps {\n textArea?: boolean;\n inputClassName?: string;\n}\n\nexport function TextField({\n label,\n description,\n errorMessage,\n textArea,\n className,\n inputClassName,\n requiredIndicator,\n ...props\n}: TextFieldProps) {\n return (\n <ATextField\n className={composeRenderProps(className, className => classNames('group form-field', className))}\n {...props}\n >\n <FormField {...{ label, description, errorMessage, requiredIndicator }}>\n {textArea ? <TextArea className={inputClassName} /> : <Input className={inputClassName} />}\n </FormField>\n </ATextField>\n );\n}\n\nexport function TfTextField({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof TextField>, 'onBlur' | 'onChange'>) {\n const field = useFieldContext<string>({ disabled: isDisabled });\n\n return (\n <TextField\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n id={field.name}\n name={field.name}\n onBlur={field.handleBlur}\n onChange={field.handleChange}\n isInvalid={!!getFieldErrorMessage(field)}\n errorMessage={getFieldErrorMessage(field)}\n {...props}\n />\n );\n}\n"],"names":["ATextField","AriaTextField","Input","className","props","jsx","AriaInput","composeRenderProps","classNames","fieldGroupVariants","TextArea","AriaTextArea","TextField","label","description","errorMessage","textArea","inputClassName","requiredIndicator","FormField","TfText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.js","sources":["../../lib/components/textfield.tsx"],"sourcesContent":["'use client';\nimport {\n Input as AriaInput,\n InputProps as AriaInputProps,\n TextArea as AriaTextArea,\n TextAreaProps as AriaTextAreaProps,\n TextField as AriaTextField,\n TextFieldProps as AriaTextFieldProps,\n composeRenderProps,\n} from 'react-aria-components';\nimport { getFieldErrorMessage } from '../utilities/form';\nimport { useFieldContext } from '../utilities/form-context';\nimport { classNames } from '../utilities/theme';\nimport { fieldGroupVariants, FormField, type FormFieldProps } from './form';\n\nconst ATextField = AriaTextField;\n\nfunction Input({ className, ...props }: AriaInputProps) {\n return (\n <AriaInput\n className={composeRenderProps(className, className =>\n classNames(\n fieldGroupVariants(),\n 'file:border-0 file:bg-transparent file:body-sm file:font-medium',\n /* Disabled */\n 'disabled-muted',\n /* Focused */\n 'focus-ring',\n className\n )\n )}\n {...props}\n />\n );\n}\n\nfunction TextArea({ className, ...props }: AriaTextAreaProps) {\n return (\n <AriaTextArea\n className={composeRenderProps(className, className =>\n classNames(fieldGroupVariants(), 'h-full min-h-32', className)\n )}\n {...props}\n />\n );\n}\n\nexport interface TextFieldProps extends AriaTextFieldProps, FormFieldProps {\n textArea?: boolean;\n inputClassName?: string;\n}\n\nexport function TextField({\n label,\n description,\n errorMessage,\n textArea,\n className,\n inputClassName,\n requiredIndicator,\n ...props\n}: TextFieldProps) {\n return (\n <ATextField\n className={composeRenderProps(className, className => classNames('group form-field', className))}\n {...props}\n >\n <FormField {...{ label, description, errorMessage, requiredIndicator }}>\n {textArea ? <TextArea className={inputClassName} /> : <Input className={inputClassName} />}\n </FormField>\n </ATextField>\n );\n}\n\nexport function TfTextField({\n isDisabled,\n ...props\n}: Omit<React.ComponentProps<typeof TextField>, 'onBlur' | 'onChange'>) {\n const field = useFieldContext<string>({ disabled: isDisabled });\n\n return (\n <TextField\n isDisabled={isDisabled || field.form.state.isSubmitting}\n value={field.state.value}\n id={field.name}\n name={field.name}\n onBlur={field.handleBlur}\n onChange={field.handleChange}\n isInvalid={!!getFieldErrorMessage(field)}\n errorMessage={getFieldErrorMessage(field)}\n requiredIndicator={field.isRequired}\n {...props}\n />\n );\n}\n"],"names":["ATextField","AriaTextField","Input","className","props","jsx","AriaInput","composeRenderProps","classNames","fieldGroupVariants","TextArea","AriaTextArea","TextField","label","description","errorMessage","textArea","inputClassName","requiredIndicator","FormField","TfTextField","isDisabled","field","useFieldContext","getFieldErrorMessage"],"mappings":"gfAeA,MAAMA,EAAaC,EAEnB,SAASC,EAAM,CAAE,UAAAC,EAAW,GAAGC,GAAyB,CACpD,OACIC,EAACC,EAAA,CACG,UAAWC,EAAmBJ,EAAWA,GACrCK,EACIC,EAAA,EACA,kEAEA,iBAEA,aACAN,CAAA,CACJ,EAEH,GAAGC,CAAA,CAAA,CAGhB,CAEA,SAASM,EAAS,CAAE,UAAAP,EAAW,GAAGC,GAA4B,CAC1D,OACIC,EAACM,EAAA,CACG,UAAWJ,EAAmBJ,EAAWA,GACrCK,EAAWC,EAAA,EAAsB,kBAAmBN,CAAS,CAAA,EAEhE,GAAGC,CAAA,CAAA,CAGhB,CAOO,SAASQ,EAAU,CACtB,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,SAAAC,EACA,UAAAb,EACA,eAAAc,EACA,kBAAAC,EACA,GAAGd,CACP,EAAmB,CACf,OACIC,EAACL,EAAA,CACG,UAAWO,EAAmBJ,EAAWA,GAAaK,EAAW,mBAAoBL,CAAS,CAAC,EAC9F,GAAGC,EAEJ,WAACe,EAAA,CAAgB,MAAAN,EAAO,YAAAC,EAAa,aAAAC,EAAc,kBAAAG,EAC9C,WAAWb,EAACK,EAAA,CAAS,UAAWO,EAAgB,IAAMf,EAAA,CAAM,UAAWe,EAAgB,CAAA,CAC5F,CAAA,CAAA,CAGZ,CAEO,SAASG,EAAY,CACxB,WAAAC,EACA,GAAGjB,CACP,EAAwE,CACpE,MAAMkB,EAAQC,EAAwB,CAAE,SAAUF,EAAY,EAE9D,OACIhB,EAACO,EAAA,CACG,WAAYS,GAAcC,EAAM,KAAK,MAAM,aAC3C,MAAOA,EAAM,MAAM,MACnB,GAAIA,EAAM,KACV,KAAMA,EAAM,KACZ,OAAQA,EAAM,WACd,SAAUA,EAAM,aAChB,UAAW,CAAC,CAACE,EAAqBF,CAAK,EACvC,aAAcE,EAAqBF,CAAK,EACxC,kBAAmBA,EAAM,WACxB,GAAGlB,CAAA,CAAA,CAGhB"}
|
|
@@ -5,7 +5,8 @@ export interface ToastProps {
|
|
|
5
5
|
description?: string;
|
|
6
6
|
variant: VariantProps<typeof alertVariants>['variant'];
|
|
7
7
|
action?: () => void;
|
|
8
|
-
|
|
8
|
+
actionLabel?: string;
|
|
9
|
+
autoDismiss?: boolean;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Toast provider.
|
|
@@ -17,11 +18,6 @@ export declare function ToastProvider(): import("react/jsx-runtime").JSX.Element
|
|
|
17
18
|
* @param title - The title of the toast.
|
|
18
19
|
* @param description - The description of the toast.
|
|
19
20
|
* @param variant - The variant of the toast.
|
|
20
|
-
* @param
|
|
21
|
+
* @param autoDismiss - Whether to automatically dismiss the toast.
|
|
21
22
|
*/
|
|
22
|
-
export declare function toast({ title, description, variant,
|
|
23
|
-
title: string;
|
|
24
|
-
description?: string;
|
|
25
|
-
variant: ToastProps['variant'];
|
|
26
|
-
timeout?: number;
|
|
27
|
-
}): void;
|
|
23
|
+
export declare function toast({ title, description, variant, autoDismiss, action, actionLabel }: ToastProps): void;
|
package/dist/components/toast.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as n}from"react/jsx-runtime";import{UNSTABLE_ToastQueue as u,UNSTABLE_ToastRegion as f,UNSTABLE_Toast as p,UNSTABLE_ToastContent as h}from"react-aria-components";import{flushSync as N}from"react-dom";import{classNames as x}from"../utilities/theme.js";import{alertVariants as T}from"./alert.js";import{Button as r}from"./button.js";import{IcClose as v,IcInfo as o,IcCheck as w,IcError as g}from"./icons.js";import"clsx";import"class-variance-authority";import"react";import"./loader.js";const a=new u({wrapUpdate(e){"startViewTransition"in document?document.startViewTransition(()=>{N(e)}):e()}});function z(){return t(f,{queue:a,className:"fixed z-50 top-4 right-4 flex flex-col-reverse justify-end gap-2",children:({toast:e})=>t(p,{style:{viewTransitionName:e.key},toast:e,className:"animate-in fade-in-0 slide-in-from-right duration-300 ease-out",children:n(h,{className:x(T({variant:e.content.variant}),"flex flex-col items-stretch max-w-sm gap-2 w-full min-w-sm"),children:[n("div",{className:"flex flex-row items-start gap-3",children:[t("span",{className:"shrink-0",children:y(e.content.variant)}),n("div",{className:"flex-1 min-w-0",children:[t("p",{slot:"title",className:"font-medium text-sm",children:e.content.title}),e.content.description&&t("p",{slot:"description",className:"text-xs",children:e.content.description})]}),!e.content.autoDismiss&&n(r,{slot:"close",size:"icon",variant:"neutral",className:"rounded-full shrink-0 -mr-1 -mt-1",children:[t(v,{className:"size-4"}),t("span",{className:"sr-only",children:"Close"})]})]}),e.content.action&&t("div",{className:"flex w-full justify-end gap-2 mt-1",children:t(r,{slot:"close",onPress:()=>{e.content.action?.()},variant:"neutral",className:"shrink-0",children:e.content.actionLabel||"Action"})})]})})})}function y(e){switch(e){case"destructive":return t(g,{});case"success":return t(w,{});case"muted":return t(o,{});default:return t(o,{})}}function V({title:e,description:c,variant:l,autoDismiss:i=!0,action:s,actionLabel:m}){const d=i&&!s?{timeout:3e3}:{};a.add({title:e,description:c,variant:l,autoDismiss:i,action:s,actionLabel:m},d)}export{z as ToastProvider,V as toast};
|
|
2
2
|
//# sourceMappingURL=toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","sources":["../../lib/components/toast.tsx"],"sourcesContent":["import type { VariantProps } from 'class-variance-authority';\nimport {\n UNSTABLE_Toast as AriaToast,\n UNSTABLE_ToastContent as AriaToastContent,\n UNSTABLE_ToastQueue as AriaToastQueue,\n UNSTABLE_ToastRegion as AriaToastRegion,\n} from 'react-aria-components';\nimport { flushSync } from 'react-dom';\nimport { classNames } from '../utilities/theme';\nimport { alertVariants } from './alert';\nimport { Button } from './button';\nimport { IcCheck, IcError, IcInfo } from './icons';\n\nexport interface ToastProps {\n title: string;\n description?: string;\n variant: VariantProps<typeof alertVariants>['variant'];\n action?: () => void;\n
|
|
1
|
+
{"version":3,"file":"toast.js","sources":["../../lib/components/toast.tsx"],"sourcesContent":["import type { VariantProps } from 'class-variance-authority';\nimport {\n UNSTABLE_Toast as AriaToast,\n UNSTABLE_ToastContent as AriaToastContent,\n UNSTABLE_ToastQueue as AriaToastQueue,\n UNSTABLE_ToastRegion as AriaToastRegion,\n} from 'react-aria-components';\nimport { flushSync } from 'react-dom';\nimport { classNames } from '../utilities/theme';\nimport { alertVariants } from './alert';\nimport { Button } from './button';\nimport { IcCheck, IcClose, IcError, IcInfo } from './icons';\n\nexport interface ToastProps {\n title: string;\n description?: string;\n variant: VariantProps<typeof alertVariants>['variant'];\n action?: () => void;\n actionLabel?: string;\n autoDismiss?: boolean;\n}\n\n/**\n * Toast queue.\n * @returns The toast queue.\n */\nconst queue = new AriaToastQueue<ToastProps>({\n wrapUpdate(fn) {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n });\n } else {\n fn();\n }\n },\n});\n\n/**\n * Toast provider.\n * @returns The toast provider.\n */\nexport function ToastProvider() {\n return (\n <AriaToastRegion queue={queue} className=\"fixed z-50 top-4 right-4 flex flex-col-reverse justify-end gap-2\">\n {({ toast }) => (\n <AriaToast\n style={{ viewTransitionName: toast.key }}\n toast={toast}\n className=\"animate-in fade-in-0 slide-in-from-right duration-300 ease-out\"\n >\n <AriaToastContent\n className={classNames(\n alertVariants({ variant: toast.content.variant }),\n 'flex flex-col items-stretch max-w-sm gap-2 w-full min-w-sm'\n )}\n >\n <div className=\"flex flex-row items-start gap-3\">\n <span className=\"shrink-0\">{getToastIcon(toast.content.variant)}</span>\n <div className=\"flex-1 min-w-0\">\n <p slot=\"title\" className=\"font-medium text-sm\">\n {toast.content.title}\n </p>\n {toast.content.description && (\n <p slot=\"description\" className=\"text-xs\">\n {toast.content.description}\n </p>\n )}\n </div>\n {!toast.content.autoDismiss && (\n <Button\n slot=\"close\"\n size=\"icon\"\n variant=\"neutral\"\n className=\"rounded-full shrink-0 -mr-1 -mt-1\"\n >\n <IcClose className=\"size-4\" />\n <span className=\"sr-only\">Close</span>\n </Button>\n )}\n </div>\n {toast.content.action && (\n <div className=\"flex w-full justify-end gap-2 mt-1\">\n <Button\n slot=\"close\"\n onPress={() => {\n toast.content.action?.();\n }}\n variant=\"neutral\"\n className=\"shrink-0\"\n >\n {toast.content.actionLabel || 'Action'}\n </Button>\n </div>\n )}\n </AriaToastContent>\n </AriaToast>\n )}\n </AriaToastRegion>\n );\n}\n\n/**\n * Get the icon for a toast notification.\n * @param variant - The variant of the toast.\n * @returns The icon for the toast.\n */\nfunction getToastIcon(variant: ToastProps['variant']) {\n switch (variant) {\n case 'destructive':\n return <IcError />;\n case 'success':\n return <IcCheck />;\n case 'muted':\n return <IcInfo />;\n default:\n return <IcInfo />;\n }\n}\n\n/**\n * Show a toast notification.\n * @param title - The title of the toast.\n * @param description - The description of the toast.\n * @param variant - The variant of the toast.\n * @param autoDismiss - Whether to automatically dismiss the toast.\n */\nexport function toast({ title, description, variant, autoDismiss = true, action, actionLabel }: ToastProps) {\n const options = autoDismiss && !action ? { timeout: 3000 } : {};\n queue.add({ title, description, variant, autoDismiss, action, actionLabel }, options);\n}\n"],"names":["queue","AriaToastQueue","fn","flushSync","ToastProvider","jsx","AriaToastRegion","toast","AriaToast","jsxs","AriaToastContent","classNames","alertVariants","Button","IcClose","getToastIcon","variant","IcError","IcCheck","IcInfo","title","description","autoDismiss","action","actionLabel","options"],"mappings":"2fA0BA,MAAMA,EAAQ,IAAIC,EAA2B,CACzC,WAAWC,EAAI,CACP,wBAAyB,SACzB,SAAS,oBAAoB,IAAM,CAC/BC,EAAUD,CAAE,CAChB,CAAC,EAE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AQ,EACpB,IAAK,UACD,SAAQC,EAAA,EAAQ,EACpB,IAAK,QACD,SAAQC,EAAA,EAAO,EACnB,QACI,SAAQA,EAAA,EAAO,CAAA,CAE3B,CASO,SAASZ,EAAM,CAAE,MAAAa,EAAO,YAAAC,EAAa,QAAAL,EAAS,YAAAM,EAAc,GAAM,OAAAC,EAAQ,YAAAC,GAA2B,CACxG,MAAMC,EAAUH,GAAe,CAACC,EAAS,CAAE,QAAS,GAAA,EAAS,CAAA,EAC7DvB,EAAM,IAAI,CAAE,MAAAoB,EAAO,YAAAC,EAAa,QAAAL,EAAS,YAAAM,EAAa,OAAAC,EAAQ,YAAAC,CAAA,EAAeC,CAAO,CACxF"}
|
|
@@ -21,4 +21,6 @@ export { fieldContext, formContext };
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function useFieldContext<T>({ disabled }: {
|
|
23
23
|
disabled?: boolean;
|
|
24
|
-
}): import('@tanstack/react-form').FieldApi<any, string, T, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any
|
|
24
|
+
}): import('@tanstack/react-form').FieldApi<any, string, T, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
25
|
+
isRequired: boolean;
|
|
26
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createFormHookContexts as
|
|
1
|
+
import{createFormHookContexts as r}from"@tanstack/react-form";import{useEffect as a}from"react";const{fieldContext:d,formContext:p,useFieldContext:l}=r();function x({disabled:e}){const o=l();a(()=>{o.setMeta(t=>({...t,disabled:!!e}))},[e,o]);const s=o.options?.validators?.onBlur||o.options?.validators?.onChange||o.options?.validators?.onMount,i=!!s&&!(t=>{if(!t||typeof t!="object"||typeof t.safeParse!="function")return!1;const n=t;return n.safeParse(void 0).success||n.safeParse(null).success})(s);return Object.assign(o,{isRequired:i})}export{d as fieldContext,p as formContext,x as useFieldContext};
|
|
2
2
|
//# sourceMappingURL=form-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-context.js","sources":["../../lib/utilities/form-context.tsx"],"sourcesContent":["import { createFormHookContexts } from '@tanstack/react-form';\nimport { useEffect } from 'react';\n\n/**\n * Exports contexts and hooks used by all form-related field components.\n *\n * These contexts come from @tanstack/react-form's createFormHookContexts helper\n * and provide a lightweight, strongly-typed way for nested field components\n * (text inputs, selects, checkboxes, etc.) to access the current field\n * and form instances.\n *\n * Usage example:\n * ```ts\n * import { useFieldContext } from './form-context';\n * const field = useFieldContext<MyFieldType>();\n * ```\n */\nconst { fieldContext, formContext, useFieldContext: _useFieldContext } = createFormHookContexts();\n\nexport { fieldContext, formContext };\n/**\n * Custom hook to handle disabled state for form fields\n * @param {boolean} disabled - The disabled prop passed to the component\n * @returns The field context with disabled state properly managed\n */\nexport function useFieldContext<T>({ disabled }: { disabled?: boolean }) {\n const field = _useFieldContext<T>();\n\n useEffect(() => {\n field.setMeta(meta => ({\n ...meta,\n disabled: !!disabled,\n }));\n }, [disabled, field]);\n\n return field;\n}\n"],"names":["fieldContext","formContext","_useFieldContext","createFormHookContexts","useFieldContext","disabled","field","useEffect","meta"],"mappings":"
|
|
1
|
+
{"version":3,"file":"form-context.js","sources":["../../lib/utilities/form-context.tsx"],"sourcesContent":["import { createFormHookContexts } from '@tanstack/react-form';\nimport { useEffect } from 'react';\n\ntype ZodLikeSchema = {\n safeParse: (input: unknown) => { success: boolean };\n};\n\n/**\n * Exports contexts and hooks used by all form-related field components.\n *\n * These contexts come from @tanstack/react-form's createFormHookContexts helper\n * and provide a lightweight, strongly-typed way for nested field components\n * (text inputs, selects, checkboxes, etc.) to access the current field\n * and form instances.\n *\n * Usage example:\n * ```ts\n * import { useFieldContext } from './form-context';\n * const field = useFieldContext<MyFieldType>();\n * ```\n */\nconst { fieldContext, formContext, useFieldContext: _useFieldContext } = createFormHookContexts();\n\nexport { fieldContext, formContext };\n/**\n * Custom hook to handle disabled state for form fields\n * @param {boolean} disabled - The disabled prop passed to the component\n * @returns The field context with disabled state properly managed\n */\nexport function useFieldContext<T>({ disabled }: { disabled?: boolean }) {\n const field = _useFieldContext<T>();\n\n useEffect(() => {\n field.setMeta(meta => ({\n ...meta,\n disabled: !!disabled,\n }));\n }, [disabled, field]);\n\n // Detect if field is required based on validators\n const validator =\n field.options?.validators?.onBlur || field.options?.validators?.onChange || field.options?.validators?.onMount;\n\n // Check if the validator allows missing values (undefined/null)\n const allowsMissingValue = (schema: unknown): boolean => {\n // Type guard: ensure it's a Zod-like schema with safeParse method\n if (!schema || typeof schema !== 'object' || typeof (schema as any).safeParse !== 'function') {\n return false;\n }\n\n const zodSchema = schema as ZodLikeSchema;\n\n // Check if undefined or null are valid inputs\n return zodSchema.safeParse(undefined).success || zodSchema.safeParse(null).success;\n };\n\n const isRequired = !!validator && !allowsMissingValue(validator);\n\n return Object.assign(field, { isRequired });\n}\n"],"names":["fieldContext","formContext","_useFieldContext","createFormHookContexts","useFieldContext","disabled","field","useEffect","meta","validator","isRequired","schema","zodSchema"],"mappings":"gGAqBA,KAAM,CAAE,aAAAA,EAAc,YAAAC,EAAa,gBAAiBC,CAAA,EAAqBC,EAAA,EAQlE,SAASC,EAAmB,CAAE,SAAAC,GAAoC,CACrE,MAAMC,EAAQJ,EAAA,EAEdK,EAAU,IAAM,CACZD,EAAM,QAAQE,IAAS,CACnB,GAAGA,EACH,SAAU,CAAC,CAACH,CAAA,EACd,CACN,EAAG,CAACA,EAAUC,CAAK,CAAC,EAGpB,MAAMG,EACFH,EAAM,SAAS,YAAY,QAAUA,EAAM,SAAS,YAAY,UAAYA,EAAM,SAAS,YAAY,QAerGI,EAAa,CAAC,CAACD,GAAa,EAZNE,GAA6B,CAErD,GAAI,CAACA,GAAU,OAAOA,GAAW,UAAY,OAAQA,EAAe,WAAc,WAC9E,MAAO,GAGX,MAAMC,EAAYD,EAGlB,OAAOC,EAAU,UAAU,MAAS,EAAE,SAAWA,EAAU,UAAU,IAAI,EAAE,OAC/E,GAEsDH,CAAS,EAE/D,OAAO,OAAO,OAAOH,EAAO,CAAE,WAAAI,EAAY,CAC9C"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { components, operations } from '@cryptlex/web-api-types/develop';
|
|
2
|
-
import { ClientPathsWithMethod } from 'openapi-fetch';
|
|
3
|
-
import { CtxClientType } from './ctx-client';
|
|
4
2
|
export type ApiSchema<T extends keyof components['schemas']> = components['schemas'][T];
|
|
3
|
+
export type ApiResponseBody<T extends keyof operations> = operations[T] extends {
|
|
4
|
+
responses: {
|
|
5
|
+
200: {
|
|
6
|
+
content: {
|
|
7
|
+
'application/json': infer R;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
} ? R extends Array<infer U> ? U : R : never;
|
|
5
12
|
export type ApiQuery<T extends keyof operations> = NonNullable<operations[T]['parameters']['query']>;
|
|
6
13
|
export type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;
|
|
7
14
|
export type ApiFilters<T extends keyof operations> = NonNullable<ApiFilter<T>>;
|
|
@@ -14,11 +21,6 @@ export declare function ProjectProvider({ projectName, children }: {
|
|
|
14
21
|
children: React.ReactNode;
|
|
15
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
16
23
|
export declare function useProjectName(): CtxPortals;
|
|
17
|
-
/**
|
|
18
|
-
* Mapping from resource names to their API endpoint paths.
|
|
19
|
-
* Based on the OpenAPI spec paths.
|
|
20
|
-
*/
|
|
21
|
-
export declare const RESOURCE_ENDPOINT_MAP: Record<CtxResourceName, ClientPathsWithMethod<CtxClientType, 'get'>>;
|
|
22
24
|
export declare function useResourceFormatter(): (resourceName: string) => string;
|
|
23
25
|
/**
|
|
24
26
|
* Format multiple license parameters (expired, suspended, revoked) into a single status
|