@cryptlex/web-components 6.6.6-alpha40 → 6.6.6-alpha45
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.d.ts +4 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- 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 +8 -10
- 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/dialog-action-utils.d.ts +38 -0
- package/dist/components/dialog-action-utils.js +2 -0
- package/dist/components/dialog-action-utils.js.map +1 -0
- package/dist/components/dialog-menu.d.ts +3 -3
- package/dist/components/dialog-menu.js +1 -1
- package/dist/components/dialog-menu.js.map +1 -1
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/id-search.d.ts +12 -11
- package/dist/components/id-search.js +1 -1
- package/dist/components/id-search.js.map +1 -1
- package/dist/components/select-options.d.ts +8 -0
- package/dist/components/select-options.js +1 -1
- package/dist/components/select-options.js.map +1 -1
- package/dist/components/table-actions.d.ts +46 -0
- package/dist/components/table-actions.js +2 -0
- package/dist/components/table-actions.js.map +1 -0
- package/dist/utilities/countries.d.ts +3 -0
- package/dist/utilities/countries.js +2 -0
- package/dist/utilities/countries.js.map +1 -0
- package/dist/utilities/numbers.d.ts +1 -0
- package/dist/utilities/numbers.js +1 -1
- package/dist/utilities/numbers.js.map +1 -1
- package/dist/utilities/resources.d.ts +8 -1
- package/dist/utilities/resources.js +1 -1
- package/dist/utilities/resources.js.map +1 -1
- package/dist/utilities/string.d.ts +5 -0
- package/dist/utilities/string.js +1 -1
- package/dist/utilities/string.js.map +1 -1
- package/dist/utilities/validators.d.ts +16 -0
- package/dist/utilities/validators.js +2 -0
- package/dist/utilities/validators.js.map +1 -0
- package/package.json +3 -3
|
@@ -19,7 +19,7 @@ type BaseSearchableResource = {
|
|
|
19
19
|
* - Search (powered by react-query)
|
|
20
20
|
* - Renders an accessible Autocomplete + Menu listbox
|
|
21
21
|
* - Exposes a controlled `value`/`onChange` contract so callers (and wrappers) can manage state
|
|
22
|
-
* -
|
|
22
|
+
* - Automatically generates search function based on resource name using RESOURCE_ENDPOINT_MAP
|
|
23
23
|
*
|
|
24
24
|
* @template T - resource type extending `BaseSearchableResource` (must have `id` and `name`)
|
|
25
25
|
* @template V - controlled value type (e.g. `string` for single-select or `string[]` for multi-select)
|
|
@@ -27,26 +27,25 @@ type BaseSearchableResource = {
|
|
|
27
27
|
* @param props - props object (see inline property JSDoc for the most important fields)
|
|
28
28
|
*
|
|
29
29
|
* @remarks
|
|
30
|
-
* -
|
|
30
|
+
* - Search is automatically handled based on the `resource` prop using the API client from context
|
|
31
31
|
* - When the popover closes, `onBlur` (if provided) is called with the current `value`.
|
|
32
32
|
* - `renderLabel` must convert `value` to a readable string for the control button.
|
|
33
|
+
* - `defaultParams` can be used to pass additional query parameters to the search endpoint
|
|
33
34
|
*
|
|
34
35
|
* @example
|
|
35
36
|
* <BaseIdSearchInput
|
|
36
37
|
* label="Owner"
|
|
37
|
-
*
|
|
38
|
+
* resource="user"
|
|
38
39
|
* value={ownerId}
|
|
39
40
|
* onChange={setOwnerId}
|
|
40
41
|
* renderLabel={(v, data) => data?.find(d => d.id === v)?.name ?? v}
|
|
41
42
|
* />
|
|
42
43
|
*
|
|
43
44
|
* @testing
|
|
44
|
-
* -
|
|
45
|
+
* - Ensure API client is provided via context; assert keyboard navigation, open/close behavior, and `onBlur` call on popover close.
|
|
45
46
|
*/
|
|
46
|
-
declare function BaseIdSearchInput<T extends BaseSearchableResource, V>({ label, description, errorMessage, requiredIndicator,
|
|
47
|
+
declare function BaseIdSearchInput<T extends BaseSearchableResource, V>({ label, description, errorMessage, requiredIndicator, isDisabled, isInvalid, onBlur, resource, onChange, value, renderLabel, accessor, defaultParams, className, ...props }: FormFieldProps & {
|
|
47
48
|
resource: CtxResourceName;
|
|
48
|
-
/** Function that returns matching resources for the current query. */
|
|
49
|
-
searchFn: (q: string) => Promise<T[] | undefined>;
|
|
50
49
|
/** Disable interactions. */
|
|
51
50
|
isDisabled?: boolean;
|
|
52
51
|
/** Whether the field is invalid. */
|
|
@@ -61,6 +60,10 @@ declare function BaseIdSearchInput<T extends BaseSearchableResource, V>({ label,
|
|
|
61
60
|
onChange: (v: V) => void;
|
|
62
61
|
/** Render a human-readable label for the current value using the latest data. */
|
|
63
62
|
renderLabel: (v: V, data: T[] | undefined) => string;
|
|
63
|
+
/** Default parameters to include in the request. This is useful when using /v3/users?role='admin' or /v3/organizations/ID/user-groups */
|
|
64
|
+
defaultParams?: Record<'path' | 'query', any>;
|
|
65
|
+
/** Optional className to customize the trigger button styling. */
|
|
66
|
+
className?: string;
|
|
64
67
|
} & Omit<React.ComponentProps<typeof Menu>, 'items' | 'className'>): import("react/jsx-runtime").JSX.Element;
|
|
65
68
|
/**
|
|
66
69
|
* Single-selection ID search input.
|
|
@@ -77,7 +80,6 @@ declare function BaseIdSearchInput<T extends BaseSearchableResource, V>({ label,
|
|
|
77
80
|
* label="Reporter"
|
|
78
81
|
* value={reporterId}
|
|
79
82
|
* onChange={setReporterId}
|
|
80
|
-
* searchFn={q => api.searchUsers(q)}
|
|
81
83
|
* />
|
|
82
84
|
*
|
|
83
85
|
*/
|
|
@@ -97,7 +99,6 @@ export declare function SingleIdSearchInput<T extends BaseSearchableResource>({
|
|
|
97
99
|
* label="Reviewers"
|
|
98
100
|
* value={reviewerIds}
|
|
99
101
|
* onChange={setReviewerIds}
|
|
100
|
-
* searchFn={q => api.searchUsers(q)}
|
|
101
102
|
* />
|
|
102
103
|
*
|
|
103
104
|
* @remarks
|
|
@@ -113,7 +114,7 @@ export declare function MultipleIdSearchInput<T extends BaseSearchableResource>(
|
|
|
113
114
|
* - surfaces field-level error messages
|
|
114
115
|
*
|
|
115
116
|
* @example
|
|
116
|
-
* <TfSingleIdSearchInput name="ownerId" label="Owner"
|
|
117
|
+
* <TfSingleIdSearchInput name="ownerId" label="Owner" />
|
|
117
118
|
|
|
118
119
|
*/
|
|
119
120
|
export declare function TfSingleIdSearchInput({ isDisabled, ...props }: Omit<React.ComponentProps<typeof SingleIdSearchInput>, 'value' | 'onChange' | 'onBlur'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -126,7 +127,7 @@ export declare function TfSingleIdSearchInput({ isDisabled, ...props }: Omit<Rea
|
|
|
126
127
|
* - surfaces field-level error messages
|
|
127
128
|
*
|
|
128
129
|
* @example
|
|
129
|
-
* <TfMultipleIdSearchInput name="reviewerIds" label="Reviewers"
|
|
130
|
+
* <TfMultipleIdSearchInput name="reviewerIds" label="Reviewers" />
|
|
130
131
|
*
|
|
131
132
|
*/
|
|
132
133
|
export declare function TfMultipleIdSearchInput({ isDisabled, ...props }: Omit<React.ComponentProps<typeof MultipleIdSearchInput>, 'value' | 'onChange'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import"react/jsx-runtime";import"@tanstack/react-query";import"react";import"react-aria-components";import{M as pp,S as tp,a as rp,T as ip}from"./data-table.js";import"./loader.js";import"./menu.js";import"./popover.js";import"./searchfield.js";import"../utilities/form.js";import"../utilities/form-context.js";import"../utilities/resources.js";import"./form.js";import"./select.js";import"./button.js";import"class-variance-authority";import"../utilities/theme.js";import"clsx";import"./icons.js";import"@dnd-kit/core";import"@dnd-kit/sortable";import"@dnd-kit/utilities";import"@tanstack/react-table";import"@uidotdev/usehooks";import"lodash-es";import"./badge.js";import"./date-picker.js";import"@internationalized/date";import"./calendar.js";import"./datefield.js";import"@tanstack/react-form";import"../utilities/form-hook.js";import"./checkbox.js";import"./multi-select.js";import"./list-box.js";import"./numberfield.js";import"./textfield.js";import"openapi-fetch";import"./dialog.js";import"./toast.js";import"react-dom";import"./alert.js";import"./dialog-menu.js";import"../utilities/string.js";import"./dialog-action-utils.js";import"./table.js";import"../utilities/countries.js";import"./select-options.js";import"../utilities/date.js";import"../utilities/numbers.js";import"zod";import"../utilities/duration.js";import"./table-actions.js";export{pp as MultipleIdSearchInput,tp as SingleIdSearchInput,rp as TfMultipleIdSearchInput,ip as TfSingleIdSearchInput};
|
|
2
2
|
//# sourceMappingURL=id-search.js.map
|
|
@@ -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 { 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 { 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 * - 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 * - Clear separation of concerns: this component only handles UI search/display; callers provide `searchFn`\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 * - `searchFn` should return `Promise<T[] | undefined>`. Returning `undefined` indicates no results / handled error.\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 *\n * @example\n * <BaseIdSearchInput\n * label=\"Owner\"\n * searchFn={q => api.searchUsers(q)}\n * value={ownerId}\n * onChange={setOwnerId}\n * renderLabel={(v, data) => data?.find(d => d.id === v)?.name ?? v}\n * />\n *\n * @testing\n * - Mock `searchFn` in unit tests; 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 searchFn,\n isDisabled,\n isInvalid,\n onBlur,\n resource,\n onChange,\n value,\n renderLabel,\n ...props\n}: FormFieldProps & {\n resource: CtxResourceName;\n /** Function that returns matching resources for the current query. */\n searchFn: (q: string) => Promise<T[] | undefined>;\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} & Omit<React.ComponentProps<typeof Menu>, 'items' | 'className'>) {\n const generatedId = useId();\n const fieldId = props.id || generatedId;\n\n const [search, _setSearch] = useState('');\n const { data, isError, isFetching, error } = useQuery({\n queryKey: [resource, 'id', search],\n queryFn: () => searchFn(search),\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={'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['id']} id={item['id']}>\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 * searchFn={q => api.searchUsers(q)}\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 * searchFn={q => api.searchUsers(q)}\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\" searchFn={q => api.searchUsers(q)} />\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\" searchFn={q => api.searchUsers(q)} />\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":["BaseIdSearchInput","label","description","errorMessage","requiredIndicator","searchFn","isDisabled","isInvalid","onBlur","resource","onChange","value","renderLabel","props","generatedId","useId","fieldId","search","_setSearch","useState","data","isError","isFetching","error","useQuery","jsx","FormField","AriaSelect","jsxs","PopoverTrigger","SelectTrigger","SelectPopover","Autocomplete","SearchField","Loader","Menu","item","MenuItem","SingleIdSearchInput","e","v","d","di","MultipleIdSearchInput","vi","TfSingleIdSearchInput","field","useFieldContext","_","getFieldErrorMessage","TfMultipleIdSearchInput"],"mappings":"oxBA0DA,SAASA,EAAuD,CAC5D,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,WAAAC,EACA,UAAAC,EACA,OAAAC,EACA,SAAAC,EACA,SAAAC,EACA,MAAAC,EACA,YAAAC,EACA,GAAGC,CACP,EAkBoE,CAChE,MAAMC,EAAcC,EAAA,EACdC,EAAUH,EAAM,IAAMC,EAEtB,CAACG,EAAQC,CAAU,EAAIC,EAAS,EAAE,EAClC,CAAE,KAAAC,EAAM,QAAAC,EAAS,WAAAC,EAAY,MAAAC,CAAA,EAAUC,EAAS,CAClD,SAAU,CAACf,EAAU,KAAMQ,CAAM,EACjC,QAAS,IAAMZ,EAASY,CAAM,CAAA,CACjC,EAED,OACIQ,EAAC,OAAI,UAAU,mBAAmB,eAAclB,EAAY,GAAK,OAC7D,SAAAkB,EAACC,EAAA,CAAgB,MAAAzB,EAAO,YAAAC,EAAa,aAAAC,EAAc,kBAAAC,EAAmB,QAASY,EAC3E,SAAAS,EAACE,EAAA,CAAW,UAAApB,EACR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,EAAM,MACpB,kBAAmB0B,GAAK1B,EAAM,SAAS,MAAM,KAAK0B,CAAC,EAAE,OAAOC,GAAK,OAAOA,GAAM,QAAQ,CAAC,EACvF,cAAc,WACd,YAAa,CAACA,EAAGC,IAAMD,GAAG,OAAUC,GAAG,KAAKC,GAAMA,EAAG,KAAOE,CAAE,GAAG,MAAQA,CAAE,EAAE,KAAK,GAAG,EACpF,GAAG/B,CAAA,CAAA,CAGhB,CAcO,SAASgC,GAAsB,CAClC,WAAAvC,EACA,GAAGO,CACP,EAA4F,CACxF,MAAMiC,EAAQC,EAAwB,CAAE,SAAUzC,EAAY,EAC9D,OACImB,EAACa,EAAA,CACI,GAAGzB,EACJ,WAAYP,GAAcwC,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,WAAA5C,EACA,GAAGO,CACP,EAAmF,CAC/E,MAAMiC,EAAQC,EAA0B,CAAE,SAAUzC,EAAY,EAChE,OACImB,EAACkB,EAAA,CACI,GAAG9B,EACJ,WAAYP,GAAcwC,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":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -5,5 +5,13 @@ export type SelectOption = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare const LICENSE_TYPE_OPTIONS: SelectOption[];
|
|
7
7
|
export declare const SUBSCRIPTION_START_TRIGGER_OPTIONS: SelectOption[];
|
|
8
|
+
/**
|
|
9
|
+
* Creates Unicode flag from a two-letter ISO country code.
|
|
10
|
+
* https://stackoverflow.com/questions/24050671/how-to-put-japan-flag-character-in-a-string
|
|
11
|
+
* @param {string} country — A two-letter ISO country code (case-insensitive).
|
|
12
|
+
* @return {string}
|
|
13
|
+
*/
|
|
14
|
+
export declare function getCountryFlag(country: string): string;
|
|
15
|
+
export declare function getCountryName(country: string): string;
|
|
8
16
|
/** Options for MultiSelect component */
|
|
9
17
|
export declare const COUNTRY_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 l,IcHostedFloating as s,IcLexFloatServer as d}from"./icons.js";import"react";const C=[{label:n(i,{children:["Node-locked",e(l,{})]}),id:"node-locked"},{label:n(i,{children:["Hosted floating",e(s,{})]}),id:"hosted-floating"},{label:n(i,{children:["LexFloatServer",e(d,{})]}),id:"on-premise-floating"}],I=[{label:"License Creation",id:"creation"},{label:"License Activation",id:"activation"}];function u(a){function r(t){return String.fromCodePoint(127397+t.toUpperCase().charCodeAt(0))}return r(a[0])+r(a[1])}const o={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 m(a){return o[a]}const T=Object.entries(o).map(a=>({label:n(i,{children:[u(a[0])," ",a[1]]}),id:a[0]}));export{T as COUNTRY_OPTIONS,C as LICENSE_TYPE_OPTIONS,I as SUBSCRIPTION_START_TRIGGER_OPTIONS,u as getCountryFlag,m 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 */\nfunction 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\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","COUNTRY_OPTIONS","v"],"mappings":"oKASO,MAAMA,EAAuC,CAChD,CACI,MACIC,EAAAC,EAAA,CAAE,SAAA,CAAA,gBA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QAAQD,CAAa,EAAE,IAAIE,IACtE,CACH,MACIZ,EAAAC,EAAA,CACK,SAAA,CAAAK,EAAeM,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"],"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,SAAA,CAAA,oBAEGE,EAAA,CAAA,CAAiB,CAAA,EACtB,EAEJ,GAAI,iBAAA,EAER,CACI,MACIH,EAAAC,EAAA,CAAE,SAAA,CAAA,mBAEGG,EAAA,CAAA,CAAiB,CAAA,EACtB,EAEJ,GAAI,qBAAA,CAEZ,EAEaC,EAAqD,CAC9D,CACI,MAAO,mBACP,GAAI,UAAA,EAER,CACI,MAAO,qBACP,GAAI,YAAA,CAEZ,EAQO,SAASC,EAAeC,EAAiB,CAC5C,SAASC,EAA2BC,EAAgB,CAChD,O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AI,mDACJ,GAAI,wBACJ,GAAI,cACJ,GAAI,6BACJ,GAAI,4BACJ,GAAI,mCACJ,GAAI,QACJ,GAAI,aACJ,GAAI,wBACJ,GAAI,eACJ,GAAI,UACJ,GAAI,SACJ,GAAI,aACJ,GAAI,eACJ,GAAI,YACJ,GAAI,4BACJ,GAAI,WACJ,GAAI,WACJ,GAAI,kBACJ,GAAI,UACJ,GAAI,eACJ,GAAI,+CACJ,GAAI,cACJ,GAAI,QACJ,GAAI,YACJ,GAAI,QACJ,GAAI,WACJ,GAAI,yBACJ,GAAI,SACJ,GAAI,cACJ,GAAI,uBACJ,GAAI,4BACJ,GAAI,aACJ,GAAI,+BACJ,GAAI,WACJ,GAAI,cACJ,GAAI,OACJ,GAAI,UACJ,GAAI,QACJ,GAAI,sBACJ,GAAI,UACJ,GAAI,UACJ,GAAI,eACJ,GAAI,2BACJ,GAAI,SACJ,GAAI,SACJ,GAAI,UACJ,GAAI,uBACJ,GAAI,uDACJ,GAAI,uCACJ,GAAI,2BACJ,GAAI,UACJ,GAAI,aACJ,GAAI,UACJ,GAAI,qCACJ,GAAI,WACJ,GAAI,2BACJ,GAAI,uBACJ,GAAI,oBACJ,GAAI,iBACJ,GAAI,QACJ,GAAI,SACJ,GAAI,UACR,EAEO,SAASC,EAAeJ,EAAiB,CAC5C,OAAOG,EAAcH,CAAO,CAChC,CAGO,MAAMK,EAAkC,OAAO,QAAQF,CAAa,EAAE,IAAIG,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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PressEvent } from 'react-aria-components';
|
|
3
|
+
import { Button } from './button';
|
|
4
|
+
import { CtxIcon } from './icons';
|
|
5
|
+
export type TableActionDialogContentProps<T> = {
|
|
6
|
+
/** Callback to close the dialog */
|
|
7
|
+
close: () => void;
|
|
8
|
+
/** The data passed to the dialog - array of selected rows */
|
|
9
|
+
data: T[];
|
|
10
|
+
/** Flag to identify table action dialogs */
|
|
11
|
+
tableAction: true;
|
|
12
|
+
};
|
|
13
|
+
/** Base properties shared by all table actions */
|
|
14
|
+
export type TableActionBase<T> = {
|
|
15
|
+
label: string;
|
|
16
|
+
/** Optional function to determine if the action is disabled. Receives the rows and returns a boolean. Defaults to false if not provided */
|
|
17
|
+
isDisabled?: (rows: T[]) => boolean;
|
|
18
|
+
icon: CtxIcon;
|
|
19
|
+
bulk: boolean;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
/** Optional button variant to pass through to Button (defaults to neutral) */
|
|
22
|
+
variant?: React.ComponentProps<typeof Button>['variant'];
|
|
23
|
+
};
|
|
24
|
+
/** Action that triggers a callback */
|
|
25
|
+
export type TableActionAction<T> = TableActionBase<T> & {
|
|
26
|
+
type: 'action';
|
|
27
|
+
/** Callback triggered when the action is pressed. Receives the press event and selected rows as parameters */
|
|
28
|
+
onClick: (e: PressEvent, rows: T[]) => void;
|
|
29
|
+
};
|
|
30
|
+
/** Action that opens a dialog */
|
|
31
|
+
export type TableActionDialog<T> = TableActionBase<T> & {
|
|
32
|
+
type: 'dialog';
|
|
33
|
+
/** Component to render in the dialog */
|
|
34
|
+
component: React.ComponentType<TableActionDialogContentProps<T>>;
|
|
35
|
+
};
|
|
36
|
+
/** Common table action type that works for both action and dialog types */
|
|
37
|
+
export type TableAction<T> = TableActionAction<T> | TableActionDialog<T>;
|
|
38
|
+
export type TableActionsProps<T> = {
|
|
39
|
+
/** Array of table actions to render */
|
|
40
|
+
readonly items: TableAction<T>[];
|
|
41
|
+
/** Array of selected rows */
|
|
42
|
+
readonly rowsSelected: T[];
|
|
43
|
+
/** Whether the table is currently fetching data */
|
|
44
|
+
readonly isFetching?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare function TableActions<T>({ items, rowsSelected, isFetching }: TableActionsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{jsxs as s,Fragment as b,jsx as r}from"react/jsx-runtime";import{normalizeLabel as d}from"../utilities/string.js";import{Button as g}from"./button.js";import{useDialogState as D,DialogActionRenderer as A,findItemByNormalizedLabel as y}from"./dialog-action-utils.js";import"lodash-es";import"class-variance-authority";import"react-aria-components";import"../utilities/theme.js";import"clsx";import"./loader.js";import"./icons.js";import"react";import"./dialog.js";function h(t){return t.type==="action"}function c(t){return t.type==="dialog"}function I(t,i){return t.isDisabled?t.isDisabled(i):!1}function k({items:t,rowsSelected:i,isFetching:p}){const{openKey:u,setOpenKey:e}=D();return s(b,{children:[t.map((n,o)=>{const a=d(n.label),f=n.icon,l=I(n,i)||p;return s(g,{"aria-label":n.label,type:"button",isDisabled:l,className:"animate-in fade-in slide-in-from-left-15 duration-300 transition-transform",onPress:m=>{l||(h(n)?n.onClick(m,i):c(n)&&e(a))},variant:n.variant??"neutral",children:[r(f,{}),r("span",{children:n.label})]},`${a}-${o}`)}),r(A,{openKey:u,onOpenChange:n=>{n||e(null)},findItem:n=>{const o=y(t,n);return!o||!c(o)?null:{component:o.component}},getDialogProps:n=>({data:i,tableAction:!0,close:n})})]})}export{k as TableActions};
|
|
2
|
+
//# sourceMappingURL=table-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-actions.js","sources":["../../lib/components/table-actions.tsx"],"sourcesContent":["'use client';\nimport type React from 'react';\nimport type { PressEvent } from 'react-aria-components';\nimport { normalizeLabel } from '../utilities/string';\nimport { Button } from './button';\nimport { DialogActionRenderer, findItemByNormalizedLabel, useDialogState } from './dialog-action-utils';\nimport type { CtxIcon } from './icons';\n\nexport type TableActionDialogContentProps<T> = {\n /** Callback to close the dialog */\n close: () => void;\n /** The data passed to the dialog - array of selected rows */\n data: T[];\n /** Flag to identify table action dialogs */\n tableAction: true;\n};\n\n/** Base properties shared by all table actions */\nexport type TableActionBase<T> = {\n label: string;\n /** Optional function to determine if the action is disabled. Receives the rows and returns a boolean. Defaults to false if not provided */\n isDisabled?: (rows: T[]) => boolean;\n icon: CtxIcon;\n bulk: boolean;\n tooltip?: string;\n /** Optional button variant to pass through to Button (defaults to neutral) */\n variant?: React.ComponentProps<typeof Button>['variant'];\n};\n\n/** Action that triggers a callback */\nexport type TableActionAction<T> = TableActionBase<T> & {\n type: 'action';\n /** Callback triggered when the action is pressed. Receives the press event and selected rows as parameters */\n onClick: (e: PressEvent, rows: T[]) => void;\n};\n\n/** Action that opens a dialog */\nexport type TableActionDialog<T> = TableActionBase<T> & {\n type: 'dialog';\n /** Component to render in the dialog */\n component: React.ComponentType<TableActionDialogContentProps<T>>;\n};\n\n/** Common table action type that works for both action and dialog types */\nexport type TableAction<T> = TableActionAction<T> | TableActionDialog<T>;\n\nfunction isTableActionAction<T>(item: TableAction<T>): item is TableActionAction<T> {\n return item.type === 'action';\n}\n\nfunction isTableActionDialog<T>(item: TableAction<T>): item is TableActionDialog<T> {\n return item.type === 'dialog';\n}\n\nfunction getTableActionIsDisabled<T>(item: TableAction<T>, rows: T[]): boolean {\n return item.isDisabled ? item.isDisabled(rows) : false;\n}\n\nexport type TableActionsProps<T> = {\n /** Array of table actions to render */\n readonly items: TableAction<T>[];\n /** Array of selected rows */\n readonly rowsSelected: T[];\n /** Whether the table is currently fetching data */\n readonly isFetching?: boolean;\n};\n\nexport function TableActions<T>({ items, rowsSelected, isFetching }: TableActionsProps<T>) {\n const { openKey, setOpenKey } = useDialogState();\n\n return (\n <>\n {items.map((item, i) => {\n const id = normalizeLabel(item.label);\n const Icon = item.icon;\n const isDisabled = getTableActionIsDisabled(item, rowsSelected) || isFetching;\n\n return (\n <Button\n key={`${id}-${i}`}\n aria-label={item.label}\n type=\"button\"\n isDisabled={isDisabled}\n className=\"animate-in fade-in slide-in-from-left-15 duration-300 transition-transform\"\n onPress={e => {\n if (isDisabled) return;\n\n if (isTableActionAction(item)) {\n item.onClick(e, rowsSelected);\n } else if (isTableActionDialog(item)) {\n setOpenKey(id);\n }\n }}\n variant={item.variant ?? 'neutral'}\n >\n <Icon />\n <span>{item.label}</span>\n </Button>\n );\n })}\n\n <DialogActionRenderer<TableActionDialogContentProps<T>>\n openKey={openKey}\n onOpenChange={open => {\n if (!open) setOpenKey(null);\n }}\n findItem={key => {\n const item = findItemByNormalizedLabel(items, key);\n if (!item || !isTableActionDialog(item)) return null;\n return { component: item.component };\n }}\n getDialogProps={close => ({ data: rowsSelected, tableAction: true, close })}\n />\n </>\n );\n}\n"],"names":["isTableActionAction","item","isTableActionDialog","getTableActionIsDisabled","rows","TableActions","items","rowsSelected","isFetching","openKey","setOpenKey","useDialogState","jsxs","Fragment","i","id","normalizeLabel","Icon","isDisabled","Button","e","jsx","DialogActionRenderer","open","key","findItemByNormalizedLabel","close"],"mappings":"keA8CA,SAASA,EAAuBC,EAAoD,CAChF,OAAOA,EAAK,OAAS,QACzB,CAEA,SAASC,EAAuBD,EAAoD,CAChF,OAAOA,EAAK,OAAS,QACzB,CAEA,SAASE,EAA4BF,EAAsBG,EAAoB,CAC3E,OAAOH,EAAK,WAAaA,EAAK,WAAWG,CAAI,EAAI,EACrD,CAWO,SAASC,EAAgB,CAAE,MAAAC,EAAO,aAAAC,EAAc,WAAAC,GAAoC,CACvF,KAAM,CAAE,QAAAC,EAAS,WAAAC,CAAA,EAAeC,EAAA,EAEhC,OACIC,EAAAC,EAAA,CACK,SAAA,CAAAP,EAAM,IAAI,CAACL,EAAMa,IAAM,CACpB,MAAMC,EAAKC,EAAef,EAAK,KAAK,EAC9BgB,EAAOhB,EAAK,KACZiB,EAAaf,EAAyBF,EAAMM,CAAY,GAAKC,EAEnE,OACII,EAACO,EAAA,CAEG,aAAYlB,EAAK,MACjB,KAAK,SACL,WAAAiB,EACA,UAAU,6EACV,QAASE,GAAK,CACNF,IAEAlB,EAAoBC,CAAI,EACxBA,EAAK,QAAQmB,EAAGb,CAAY,EACrBL,EAAoBD,CAAI,GAC/BS,EAAWK,CAAE,EAErB,EACA,QAASd,EAAK,SAAW,UAEzB,SAAA,CAAAoB,EAACJ,EAAA,EAAK,EACNI,EAAC,OAAA,CAAM,SAAApB,EAAK,KAAA,CAAM,CAAA,CAAA,EAjBb,GAAGc,CAAE,IAAID,CAAC,EAAA,CAoB3B,CAAC,EAEDO,EAACC,EAAA,CACG,QAAAb,EACA,aAAcc,GAAQ,CACbA,GAAMb,EAAW,IAAI,CAC9B,EACA,SAAUc,GAAO,CACb,MAAMvB,EAAOwB,EAA0BnB,EAAOkB,CAAG,EACjD,MAAI,CAACvB,GAAQ,CAACC,EAAoBD,CAAI,EAAU,KACzC,CAAE,UAAWA,EAAK,SAAA,CAC7B,EACA,eAAgByB,IAAU,CAAE,KAAMnB,EAAc,YAAa,GAAM,MAAAmB,CAAA,EAAM,CAAA,CAC7E,EACJ,CAER"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as t,Fragment as o}from"react/jsx-runtime";import{getCountryFlag as n,getCountryName as m}from"../components/select-options.js";import"../components/icons.js";import"react";function f({value:r}){return r?t(o,{children:[n(r)," ",m(r)]}):null}export{f as CountryName};
|
|
2
|
+
//# sourceMappingURL=countries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countries.js","sources":["../../lib/utilities/countries.tsx"],"sourcesContent":["import { getCountryFlag, getCountryName } from '../components/select-options';\n\nexport function CountryName({ value }: { value: string }) {\n if (!value) return null;\n return (\n <>\n {getCountryFlag(value)} {getCountryName(value)}\n </>\n );\n}\n"],"names":["CountryName","value","jsxs","Fragment","getCountryFlag","getCountryName"],"mappings":"yLAEO,SAASA,EAAY,CAAE,MAAAC,GAA4B,CACtD,OAAKA,EAEDC,EAAAC,EAAA,CACK,SAAA,CAAAC,EAAeH,CAAK,EAAE,IAAEI,EAAeJ,CAAK,CAAA,EACjD,EAJe,IAMvB"}
|
|
@@ -5,6 +5,7 @@ export declare const MIN_INT32 = -2147483648;
|
|
|
5
5
|
export declare const MIN_INT32_DAYS: number;
|
|
6
6
|
export declare function getNumberValidator(min: number, max: number): z.ZodNumber;
|
|
7
7
|
export declare function getDaysValidator(min: number): z.ZodNumber;
|
|
8
|
+
export declare function formatDays(seconds: number): string;
|
|
8
9
|
export declare function formatNumber(num: number | bigint, options?: Intl.NumberFormatOptions): string;
|
|
9
10
|
/**
|
|
10
11
|
* @returns A formatted string for the number of bytes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import m from"zod";import{Duration as c}from"./duration.js";const d=2147483647,i=Math.floor(d/86400),
|
|
1
|
+
import m from"zod";import{Duration as c}from"./duration.js";const d=2147483647,i=Math.floor(d/86400),f=-2147483648,y=Math.ceil(f/86400);function _(e,t){return m.number().min(e,{error:n=>{if(n.code==="too_small")return`The number must be at least ${a(e)}.`}}).max(t,{error:n=>{if(n.code==="too_big")return`The number must be at most ${a(t)}.`}})}const o=86400;function b(e){const t=e*o,n=i*o;return m.number().min(t,{error:`The number must be at least ${a(e)} days.`}).max(n,{error:`The number must be at most ${a(i)} days.`})}function g(e){return`${Math.floor(e/o)} days`}function a(e,t){return Intl.NumberFormat(navigator.language,t).format(e)}function D(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function N(e=10){const t=365*e,n=s=>{try{const r=c.parse(s);return{years:r.years??0,months:r.months??0,days:(r.days??0)+(r.weeks??0)*7,hours:r.hours??0,minutes:r.minutes??0,seconds:r.seconds??0}}catch{return{years:0,months:0,days:0,hours:0,minutes:0,seconds:0}}};return m.string().refine(s=>{const r=n(s);return Object.values(r).some(u=>u>0)},{message:"At least one value (years, months, days, hours, minutes, or seconds) must be non-zero"}).refine(s=>{const r=n(s),u=(r.hours*3600+r.minutes*60+r.seconds)/o;return r.years*365+r.months*30+r.days+u<=t},{message:`Subscription interval cannot exceed ${e} years`})}export{d as MAX_INT32,i as MAX_INT32_DAYS,f as MIN_INT32,y as MIN_INT32_DAYS,g as formatDays,D as formatFilesize,a as formatNumber,b as getDaysValidator,N as getISO8601DurationValidator,_ as getNumberValidator};
|
|
2
2
|
//# sourceMappingURL=numbers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.js","sources":["../../lib/utilities/numbers.ts"],"sourcesContent":["import z from 'zod';\nimport { Duration } from './duration';\n\nexport const MAX_INT32 = 2147483647;\nexport const MAX_INT32_DAYS = Math.floor(MAX_INT32 / 86400);\nexport const MIN_INT32 = -2147483648;\nexport const MIN_INT32_DAYS = Math.ceil(MIN_INT32 / 86400);\n\nexport function getNumberValidator(min: number, max: number) {\n return z\n .number()\n .min(min, {\n error: issue => {\n if (issue.code === 'too_small') return `The number must be at least ${formatNumber(min)}.`;\n },\n })\n .max(max, {\n error: issue => {\n if (issue.code === 'too_big') return `The number must be at most ${formatNumber(max)}.`;\n },\n });\n}\n\nconst SECONDS_PER_DAY = 86400;\n\nexport function getDaysValidator(min: number) {\n const minSeconds = min * SECONDS_PER_DAY;\n const maxSeconds = MAX_INT32_DAYS * SECONDS_PER_DAY;\n\n return z\n .number()\n .min(minSeconds, {\n error: `The number must be at least ${formatNumber(min)} days.`,\n })\n .max(maxSeconds, {\n error: `The number must be at most ${formatNumber(MAX_INT32_DAYS)} days.`,\n });\n}\n\nexport function formatNumber(num: number | bigint, options?: Intl.NumberFormatOptions) {\n return Intl.NumberFormat(navigator.language, options).format(num);\n}\n\n/**\n * @returns A formatted string for the number of bytes\n */\nexport function formatFilesize(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n } else if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(1)} KB`;\n } else if (bytes < 1024 * 1024 * 1024) {\n return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;\n } else {\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n }\n}\n\n/**\n * Validates an ISO8601 duration string\n * @param maxYears Maximum allowed years (default: 10)\n * @returns A Zod validator that checks:\n * - Duration format is valid (matches ISO8601 pattern)\n * - Duration is not empty\n * - At least one value (years, months, days, hours, minutes, or seconds) is non-zero\n * - Total duration does not exceed maxYears\n */\nexport function getISO8601DurationValidator(maxYears: number = 10) {\n const MAX_DURATION_DAYS = 365 * maxYears;\n\n const getParts = (value: string) => {\n try {\n const parsed = Duration.parse(value);\n return {\n years: parsed.years ?? 0,\n months: parsed.months ?? 0,\n days: (parsed.days ?? 0) + (parsed.weeks ?? 0) * 7,\n hours: parsed.hours ?? 0,\n minutes: parsed.minutes ?? 0,\n seconds: parsed.seconds ?? 0,\n };\n } catch {\n return { years: 0, months: 0, days: 0, hours: 0, minutes: 0, seconds: 0 };\n }\n };\n\n return z\n .string()\n .refine(\n value => {\n const parts = getParts(value);\n return Object.values(parts).some(v => v > 0);\n },\n {\n message: 'At least one value (years, months, days, hours, minutes, or seconds) must be non-zero',\n }\n )\n .refine(\n value => {\n const parts = getParts(value);\n const timeInDays = (parts.hours * 3600 + parts.minutes * 60 + parts.seconds) / SECONDS_PER_DAY;\n return parts.years * 365 + parts.months * 30 + parts.days + timeInDays <= MAX_DURATION_DAYS;\n },\n {\n message: `Subscription interval cannot exceed ${maxYears} years`,\n }\n );\n}\n"],"names":["MAX_INT32","MAX_INT32_DAYS","MIN_INT32","MIN_INT32_DAYS","getNumberValidator","min","max","z","issue","formatNumber","SECONDS_PER_DAY","getDaysValidator","minSeconds","maxSeconds","num","options","formatFilesize","bytes","getISO8601DurationValidator","maxYears","MAX_DURATION_DAYS","getParts","value","parsed","Duration","parts","v","timeInDays"],"mappings":"4DAGO,MAAMA,EAAY,WACZC,EAAiB,KAAK,MAAMD,EAAY,KAAK,EAC7CE,EAAY,YACZC,EAAiB,KAAK,KAAKD,EAAY,KAAK,EAElD,SAASE,EAAmBC,EAAaC,EAAa,CACzD,OAAOC,EACF,SACA,IAAIF,EAAK,CACN,MAAOG,GAAS,CACZ,GAAIA,EAAM,OAAS,kBAAoB,+BAA+BC,EAAaJ,CAAG,CAAC,GAC3F,CAAA,CACH,EACA,IAAIC,EAAK,CACN,MAAOE,GAAS,CACZ,GAAIA,EAAM,OAAS,gBAAkB,8BAA8BC,EAAaH,CAAG,CAAC,GACxF,CAAA,CACH,CACT,CAEA,MAAMI,EAAkB,MAEjB,SAASC,EAAiBN,EAAa,CAC1C,MAAMO,EAAaP,EAAMK,EACnBG,EAAaZ,EAAiBS,EAEpC,OAAOH,EACF,SACA,IAAIK,EAAY,CACb,MAAO,+BAA+BH,EAAaJ,CAAG,CAAC,QAAA,CAC1D,EACA,IAAIQ,EAAY,CACb,MAAO,8BAA8BJ,EAAaR,CAAc,CAAC,QAAA,CACpE,CACT,CAEO,
|
|
1
|
+
{"version":3,"file":"numbers.js","sources":["../../lib/utilities/numbers.ts"],"sourcesContent":["import z from 'zod';\nimport { Duration } from './duration';\n\nexport const MAX_INT32 = 2147483647;\nexport const MAX_INT32_DAYS = Math.floor(MAX_INT32 / 86400);\nexport const MIN_INT32 = -2147483648;\nexport const MIN_INT32_DAYS = Math.ceil(MIN_INT32 / 86400);\n\nexport function getNumberValidator(min: number, max: number) {\n return z\n .number()\n .min(min, {\n error: issue => {\n if (issue.code === 'too_small') return `The number must be at least ${formatNumber(min)}.`;\n },\n })\n .max(max, {\n error: issue => {\n if (issue.code === 'too_big') return `The number must be at most ${formatNumber(max)}.`;\n },\n });\n}\n\nconst SECONDS_PER_DAY = 86400;\n\nexport function getDaysValidator(min: number) {\n const minSeconds = min * SECONDS_PER_DAY;\n const maxSeconds = MAX_INT32_DAYS * SECONDS_PER_DAY;\n\n return z\n .number()\n .min(minSeconds, {\n error: `The number must be at least ${formatNumber(min)} days.`,\n })\n .max(maxSeconds, {\n error: `The number must be at most ${formatNumber(MAX_INT32_DAYS)} days.`,\n });\n}\n\nexport function formatDays(seconds: number): string {\n return `${Math.floor(seconds / SECONDS_PER_DAY)} days`;\n}\nexport function formatNumber(num: number | bigint, options?: Intl.NumberFormatOptions) {\n return Intl.NumberFormat(navigator.language, options).format(num);\n}\n\n/**\n * @returns A formatted string for the number of bytes\n */\nexport function formatFilesize(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n } else if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(1)} KB`;\n } else if (bytes < 1024 * 1024 * 1024) {\n return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;\n } else {\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n }\n}\n\n/**\n * Validates an ISO8601 duration string\n * @param maxYears Maximum allowed years (default: 10)\n * @returns A Zod validator that checks:\n * - Duration format is valid (matches ISO8601 pattern)\n * - Duration is not empty\n * - At least one value (years, months, days, hours, minutes, or seconds) is non-zero\n * - Total duration does not exceed maxYears\n */\nexport function getISO8601DurationValidator(maxYears: number = 10) {\n const MAX_DURATION_DAYS = 365 * maxYears;\n\n const getParts = (value: string) => {\n try {\n const parsed = Duration.parse(value);\n return {\n years: parsed.years ?? 0,\n months: parsed.months ?? 0,\n days: (parsed.days ?? 0) + (parsed.weeks ?? 0) * 7,\n hours: parsed.hours ?? 0,\n minutes: parsed.minutes ?? 0,\n seconds: parsed.seconds ?? 0,\n };\n } catch {\n return { years: 0, months: 0, days: 0, hours: 0, minutes: 0, seconds: 0 };\n }\n };\n\n return z\n .string()\n .refine(\n value => {\n const parts = getParts(value);\n return Object.values(parts).some(v => v > 0);\n },\n {\n message: 'At least one value (years, months, days, hours, minutes, or seconds) must be non-zero',\n }\n )\n .refine(\n value => {\n const parts = getParts(value);\n const timeInDays = (parts.hours * 3600 + parts.minutes * 60 + parts.seconds) / SECONDS_PER_DAY;\n return parts.years * 365 + parts.months * 30 + parts.days + timeInDays <= MAX_DURATION_DAYS;\n },\n {\n message: `Subscription interval cannot exceed ${maxYears} years`,\n }\n );\n}\n"],"names":["MAX_INT32","MAX_INT32_DAYS","MIN_INT32","MIN_INT32_DAYS","getNumberValidator","min","max","z","issue","formatNumber","SECONDS_PER_DAY","getDaysValidator","minSeconds","maxSeconds","formatDays","seconds","num","options","formatFilesize","bytes","getISO8601DurationValidator","maxYears","MAX_DURATION_DAYS","getParts","value","parsed","Duration","parts","v","timeInDays"],"mappings":"4DAGO,MAAMA,EAAY,WACZC,EAAiB,KAAK,MAAMD,EAAY,KAAK,EAC7CE,EAAY,YACZC,EAAiB,KAAK,KAAKD,EAAY,KAAK,EAElD,SAASE,EAAmBC,EAAaC,EAAa,CACzD,OAAOC,EACF,SACA,IAAIF,EAAK,CACN,MAAOG,GAAS,CACZ,GAAIA,EAAM,OAAS,kBAAoB,+BAA+BC,EAAaJ,CAAG,CAAC,GAC3F,CAAA,CACH,EACA,IAAIC,EAAK,CACN,MAAOE,GAAS,CACZ,GAAIA,EAAM,OAAS,gBAAkB,8BAA8BC,EAAaH,CAAG,CAAC,GACxF,CAAA,CACH,CACT,CAEA,MAAMI,EAAkB,MAEjB,SAASC,EAAiBN,EAAa,CAC1C,MAAMO,EAAaP,EAAMK,EACnBG,EAAaZ,EAAiBS,EAEpC,OAAOH,EACF,SACA,IAAIK,EAAY,CACb,MAAO,+BAA+BH,EAAaJ,CAAG,CAAC,QAAA,CAC1D,EACA,IAAIQ,EAAY,CACb,MAAO,8BAA8BJ,EAAaR,CAAc,CAAC,QAAA,CACpE,CACT,CAEO,SAASa,EAAWC,EAAyB,CAChD,MAAO,GAAG,KAAK,MAAMA,EAAUL,CAAe,CAAC,OACnD,CACO,SAASD,EAAaO,EAAsBC,EAAoC,CACnF,OAAO,KAAK,aAAa,UAAU,SAAUA,CAAO,EAAE,OAAOD,CAAG,CACpE,CAKO,SAASE,EAAeC,EAAuB,CAClD,OAAIA,EAAQ,KACD,GAAGA,CAAK,KACRA,EAAQ,KAAO,KACf,IAAIA,EAAQ,MAAM,QAAQ,CAAC,CAAC,MAC5BA,EAAQ,KAAO,KAAO,KACtB,IAAIA,GAAS,KAAO,OAAO,QAAQ,CAAC,CAAC,MAErC,IAAIA,GAAS,KAAO,KAAO,OAAO,QAAQ,CAAC,CAAC,KAE3D,CAWO,SAASC,EAA4BC,EAAmB,GAAI,CAC/D,MAAMC,EAAoB,IAAMD,EAE1BE,EAAYC,GAAkB,CAChC,GAAI,CACA,MAAMC,EAASC,EAAS,MAAMF,CAAK,EACnC,MAAO,CACH,MAAOC,EAAO,OAAS,EACvB,OAAQA,EAAO,QAAU,EACzB,MAAOA,EAAO,MAAQ,IAAMA,EAAO,OAAS,GAAK,EACjD,MAAOA,EAAO,OAAS,EACvB,QAASA,EAAO,SAAW,EAC3B,QAASA,EAAO,SAAW,CAAA,CAEnC,MAAQ,CACJ,MAAO,CAAE,MAAO,EAAG,OAAQ,EAAG,KAAM,EAAG,MAAO,EAAG,QAAS,EAAG,QAAS,CAAA,CAC1E,CACJ,EAEA,OAAOlB,EACF,SACA,OACGiB,GAAS,CACL,MAAMG,EAAQJ,EAASC,CAAK,EAC5B,OAAO,OAAO,OAAOG,CAAK,EAAE,KAAKC,GAAKA,EAAI,CAAC,CAC/C,EACA,CACI,QAAS,uFAAA,CACb,EAEH,OACGJ,GAAS,CACL,MAAMG,EAAQJ,EAASC,CAAK,EACtBK,GAAcF,EAAM,MAAQ,KAAOA,EAAM,QAAU,GAAKA,EAAM,SAAWjB,EAC/E,OAAOiB,EAAM,MAAQ,IAAMA,EAAM,OAAS,GAAKA,EAAM,KAAOE,GAAcP,CAC9E,EACA,CACI,QAAS,uCAAuCD,CAAQ,QAAA,CAC5D,CAEZ"}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { components, operations } from '@cryptlex/web-api-types/develop';
|
|
2
|
+
import { ClientPathsWithMethod } from 'openapi-fetch';
|
|
3
|
+
import { ctxClient } from '../../stories/story-commons';
|
|
2
4
|
export type ApiSchema<T extends keyof components['schemas']> = components['schemas'][T];
|
|
3
5
|
export type ApiQuery<T extends keyof operations> = NonNullable<operations[T]['parameters']['query']>;
|
|
4
6
|
export type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;
|
|
5
7
|
export type ApiFilters<T extends keyof operations> = NonNullable<ApiFilter<T>>;
|
|
6
8
|
export type CtxPortals = 'customer-portal' | 'system-portal' | 'reseller-portal' | 'admin-portal';
|
|
7
9
|
/** Resource Name should ALWAYS be in singular form */
|
|
8
|
-
export declare const RESOURCE_NAMES: readonly ["access-token", "account", "activation", "activation-log", "admin-role", "audit-log", "automated-email", "automated-email-event-log", "card", "entitlement-set", "feature-flag", "feature", "invoice", "license", "license-template", "maintenance-policy", "organization", "plan", "product", "product-version", "profile", "release", "release-channel", "release-file", "release-platform", "
|
|
10
|
+
export declare const RESOURCE_NAMES: readonly ["access-token", "account", "activation", "activation-log", "admin-role", "audit-log", "automated-email", "automated-email-event-log", "card", "entitlement-set", "feature-flag", "feature", "invoice", "license", "license-template", "maintenance-policy", "organization", "plan", "product", "product-version", "profile", "release", "release-channel", "release-file", "release-platform", "role", "role-claim", "saml-configuration", "segment", "sending-domain", "tag", "trial", "trial-policy", "user", "user-group", "webhook", "webhook-event-log", "webhook-event", "reseller", "oidc-configuration", "tenant-database-cluster"];
|
|
9
11
|
export type CtxResourceName = (typeof RESOURCE_NAMES)[number];
|
|
10
12
|
export declare function ProjectProvider({ projectName, children }: {
|
|
11
13
|
projectName: CtxPortals;
|
|
12
14
|
children: React.ReactNode;
|
|
13
15
|
}): import("react/jsx-runtime").JSX.Element;
|
|
14
16
|
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<typeof ctxClient, 'get'>>;
|
|
15
22
|
export declare function useResourceFormatter(): (resourceName: string) => string;
|
|
16
23
|
/**
|
|
17
24
|
* Format multiple license parameters (expired, suspended, revoked) into a single status
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{createContext as i,use as r}from"react";import{toTitleCase as l}from"./string.js";import"lodash-es";const t={"product.displayName":"Product",product_displayName:"Product"},g=["access-token","account","activation","activation-log","admin-role","audit-log","automated-email","automated-email-event-log","card","entitlement-set","feature-flag","feature","invoice","license","license-template","maintenance-policy","organization","plan","product","product-version","profile","release","release-channel","release-file","release-platform","role","role-claim","saml-configuration","segment","sending-domain","tag","trial","trial-policy","user","user-group","webhook","webhook-event-log","webhook-event","reseller","oidc-configuration","tenant-database-cluster"],a={id:"ID",createdAt:"Creation Date",scopes:"Permissions",updatedAt:"Last Updated",expiresAt:"Expiration Date",lastSeenAt:"Last Seen",os:"OS",osVersion:"OS Version",key:"License Key",vmName:"VM Name",container:"Container",allowedIpRange:"Allowed IP Range",allowedIpRanges:"Allowed IP Ranges",allowedIpAddresses:"Allowed IP Addresses",disallowedIpAddresses:"Disallowed IP Addresses",allowVmActivation:"Allow VM Activation",disableGeoLocation:"Disable Geolocation","user.id":"User ID",userId:"User",productId:"Product",downloads:"Total Downloads",claims:"Permissions",googleSsoEnabled:"Google Login Enabled",lastAttemptedAt:"Last Attempt Date",url:"URL","trialPolicy.name":"Trial Policy Name","licensePolicy.name":"License Template Name",licensePolicy:"License Template",eventLog:"Audit Log",cc:"CC Recepients",bcc:"BCC Recepients",ipAddress:"IP Address",resellerId:"Reseller",productVersionId:"Product Version",releaseId:"Release",maintenancePolicyId:"Maintenance Policy",webhookId:"Webhook",automatedEmailId:"Automated Email","location.countryName":"Country","location.ipAddress":"IP Address","location.countryCode":"Country",organizationId:"Organization","address.country":"Country","address.addressLine1":"Address Line 1","address.addressLine2":"Address Line 2",responseStatusCode:"HTTP Status Code",resourceId:"Resource ID",Sso:"SAML SSO 2.0","reseller.name":"Reseller",sendingDomain:"Email Sending Domain"};function d(e,o){return o!=="admin-portal"&&e in t?t[e]:e in a?a[e]:l(e)}const n=i("admin-portal");function A({projectName:e,children:o}){return s(n.Provider,{value:e,children:o})}function c(){return r(n)}const f={"access-token":"/v3/personal-access-tokens",account:"/v3/admin/accounts",activation:"/v3/activations","activation-log":"/v3/activation-logs","admin-role":"/v3/roles","audit-log":"/v3/event-logs","automated-email":"/v3/automated-emails","automated-email-event-log":"/v3/automated-email-event-logs","entitlement-set":"/v3/entitlement-sets","feature-flag":"/v3/feature-flags",feature:"/v3/features",license:"/v3/licenses","license-template":"/v3/license-templates","maintenance-policy":"/v3/maintenance-policies",organization:"/v3/organizations",plan:"/v3/plans",product:"/v3/products","product-version":"/v3/product-versions",release:"/v3/releases","release-channel":"/v3/release-channels","release-file":"/v3/release-files","release-platform":"/v3/release-platforms",reseller:"/v3/resellers",role:"/v3/roles",segment:"/v3/segments","sending-domain":"/v3/sending-domains",tag:"/v3/tags",trial:"/v3/trial-activations","trial-policy":"/v3/trial-policies",user:"/v3/users","user-group":"/v3/organizations/{organizationId}/user-groups",webhook:"/v3/webhooks","webhook-event-log":"/v3/webhook-event-logs",card:"/v3/billing/payment-methods/cards",invoice:"/v3/billing/invoices",profile:"/v3/me","role-claim":"/v3/roles/claims","saml-configuration":"/v3/accounts/{id}/saml-configuration","webhook-event":"/v3/webhooks/events","oidc-configuration":"/v3/accounts/{id}/oidc-configuration","tenant-database-cluster":"/v3/admin/tenant-database-clusters"};function P(){const e=c();return o=>d(o,e)}function w(e){const o=e.expiresAt&&new Date(e.expiresAt)<new Date;switch(!0){case(e.revoked&&e.suspended&&o):return"Revoked, Suspended, Expired";case(e.revoked&&e.suspended):return"Revoked, Suspended";case(e.revoked&&o):return"Revoked, Expired";case(e.suspended&&o):return"Suspended, Expired";case e.suspended:return"Suspended";case e.revoked:return"Revoked";case o:return"Expired";default:return"Active"}}const S={windows:"Windows",macos:"macOS",linux:"Linux",ios:"iOS",android:"Android"};export{S as ALL_OS,A as ProjectProvider,f as RESOURCE_ENDPOINT_MAP,g as RESOURCE_NAMES,w as getLicenseStatus,c as useProjectName,P as useResourceFormatter};
|
|
2
2
|
//# sourceMappingURL=resources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sources":["../../lib/utilities/resources.tsx"],"sourcesContent":["import type { components, operations } from '@cryptlex/web-api-types/develop';\nimport { createContext, use } from 'react';\nimport { toTitleCase } from './string';\n\nexport type ApiSchema<T extends keyof components['schemas']> = components['schemas'][T];\nexport type ApiQuery<T extends keyof operations> = NonNullable<operations[T]['parameters']['query']>;\nexport type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;\nexport type ApiFilters<T extends keyof operations> = NonNullable<ApiFilter<T>>;\nexport type CtxPortals = 'customer-portal' | 'system-portal' | 'reseller-portal' | 'admin-portal';\n// Display names specific to customer and reseller portal\nconst OTHER_PORTALS_DISPLAY_NAME: Record<string, string> = {\n 'product.displayName': 'Product',\n // TanStack Table converts . -> _ TODO\n product_displayName: 'Product',\n};\n\n// TODO, this drifts quite a lot from the API, should be updated\n/** Resource Name should ALWAYS be in singular form */\nexport const RESOURCE_NAMES = [\n 'access-token',\n 'account',\n 'activation',\n 'activation-log',\n 'admin-role',\n 'audit-log',\n 'automated-email',\n 'automated-email-event-log',\n 'card',\n 'entitlement-set',\n 'feature-flag',\n 'feature',\n 'invoice',\n 'license',\n 'license-template',\n 'maintenance-policy',\n 'organization',\n 'plan',\n 'product',\n 'product-version',\n 'profile',\n 'release',\n 'release-channel',\n 'release-file',\n 'release-platform',\n 'report',\n 'role',\n 'role-claim',\n 'saml-configuration',\n 'segment',\n 'sending-domain',\n 'setting',\n 'tag',\n 'team-member',\n 'trial',\n 'trial-policy',\n 'user',\n 'user-group',\n 'webhook',\n 'webhook-event-log',\n 'webhook-trigger',\n 'reseller',\n 'oidc-configuration',\n 'organization-claim',\n 'reseller-claim',\n 'tenant-database-cluster',\n 'customer',\n] as const;\nexport type CtxResourceName = (typeof RESOURCE_NAMES)[number];\n\n// TODO, use OpenAPI spec\n// export const RESOURCE_DEFINITIONS: Record<CtxResourceName, string> = {\n// account: 'Your organization account.',\n// product: 'Products are the software products you want to license',\n// license:\n// 'Licenses represent a purchase of your software. These can be linked to customers, and the license key is required to use the product.',\n// 'access-token': 'Access Tokens are used to authenticate your API requests.',\n// activation: 'Activations, also known as devices/machines/seats are the devices consuming licenses.',\n// 'activation-log': 'Activation Log is a log entry of activation/deactivation of a particular license.',\n// trial: 'Trial/Trial Activation is a device that has activated a trial of your product.',\n// 'audit-log': 'Audit logs contain all the changes made to your account.',\n// 'automated-email': 'Automated Email allow you to send marketing emails based on events on the linked product.',\n// 'automated-email-event-log':\n// 'Automated email event log is the log of all the automated email events for your product.',\n// card: 'The payment card for your account.',\n// 'feature-flag': 'Feature flags define features that make up tiers for your products.',\n// invoice: '',\n// 'license-template':\n// 'License templates are a blueprint for the licenses you create for your customers and prevent repetition when creating licenses.',\n// 'maintenance-policy': 'Maintenance policies represent support contracts and can be linked to licenses.',\n// plan: '',\n// 'product-version': 'Product Versions are sets of Feature Flags that define the tiers of your products.',\n// 'release-channel': 'Release channel is the release channel for your product.',\n// 'release-file': 'Release files are files within your created releases.',\n// 'release-platform':\n// 'Release Platforms differentiate the target platform for your release. Common platforms include \"Windows\", \"macOS\", and \"Linux\".',\n// release: 'Releases help you to manage different versions of your app, and secure distribute it to licensed users.',\n// report: 'Analytics data for your account',\n// 'role-claim': '',\n// role: 'Roles define permissions for your team.',\n// 'saml-configuration': '',\n// segment: 'Sets of filters that can be saved to filter resources.',\n// 'trial-policy': 'Trial policies are templates for creating trials for your products.',\n// 'webhook-event-log': 'Webhook Event Logs are logs of events that have occured on webhooks.',\n// 'webhook-trigger': '',\n// webhook: 'Webhooks are HTTP callbacks which are triggered by specific events.',\n// organization: '',\n// profile: '',\n// setting: '',\n// tag: 'Tags allow you to manage your licenses and customers on the dashboard.',\n// 'team-member': 'Team members can access the account based on their roles.',\n// user: 'A user refers to your customer whom you want to license your product.',\n// 'sending-domain': 'Allows Cryptlex to send emails on your behalf using your From Email address',\n// 'admin-role': 'Roles that have type admin',\n// 'user-group': 'Groups of users that you can assign licenses to.',\n// reseller: 'Resellers allow you to delegate user management to third parties or partners',\n// 'oidc-configuration': '',\n// 'organization-claim': '',\n// 'reseller-claim': '',\n// 'tenant-database-cluster': '',\n// customer: '',\n// };\n\nconst RESOURCE_DISPLAY_NAMES: Record<string, string> = {\n id: 'ID',\n createdAt: 'Creation Date',\n scopes: 'Permissions',\n updatedAt: 'Last Updated',\n expiresAt: 'Expiration Date',\n lastSeenAt: 'Last Seen',\n os: 'OS',\n osVersion: 'OS Version',\n key: 'License Key',\n vmName: 'VM Name',\n container: 'Container',\n allowedIpRange: 'Allowed IP Range',\n allowedIpRanges: 'Allowed IP Ranges',\n allowedIpAddresses: 'Allowed IP Addresses',\n disallowedIpAddresses: 'Disallowed IP Addresses',\n allowVmActivation: 'Allow VM Activation',\n disableGeoLocation: 'Disable Geolocation',\n 'user.id': 'User ID',\n userId: 'User',\n productId: 'Product',\n downloads: 'Total Downloads',\n claims: 'Permissions',\n googleSsoEnabled: 'Google Login Enabled',\n lastAttemptedAt: 'Last Attempt Date',\n url: 'URL',\n 'trialPolicy.name': 'Trial Policy Name',\n 'licensePolicy.name': 'License Template Name',\n licensePolicy: 'License Template',\n eventLog: 'Audit Log',\n cc: 'CC Recepients',\n bcc: 'BCC Recepients',\n ipAddress: 'IP Address',\n resellerId: 'Reseller',\n productVersionId: 'Product Version',\n releaseId: 'Release',\n maintenancePolicyId: 'Maintenance Policy',\n webhookId: 'Webhook',\n automatedEmailId: 'Automated Email',\n 'location.countryName': 'Country',\n 'location.ipAddress': 'IP Address',\n 'location.countryCode': 'Country',\n organizationId: 'Organization',\n 'address.country': 'Country',\n 'address.addressLine1': 'Address Line 1',\n 'address.addressLine2': 'Address Line 2',\n responseStatusCode: 'HTTP Status Code',\n resourceId: 'Resource ID',\n Sso: 'SAML SSO 2.0',\n 'reseller.name': 'Reseller',\n sendingDomain: 'Email Sending Domain',\n};\n\nfunction getResourceDisplayName(resourceName: string, portal: CtxPortals) {\n if (portal !== 'admin-portal' && resourceName in OTHER_PORTALS_DISPLAY_NAME) {\n return OTHER_PORTALS_DISPLAY_NAME[resourceName];\n } else if (resourceName in RESOURCE_DISPLAY_NAMES) {\n return RESOURCE_DISPLAY_NAMES[resourceName];\n } else {\n return toTitleCase(resourceName);\n }\n}\n\nconst ProjectContext = createContext<CtxPortals>('admin-portal');\n\nexport function ProjectProvider({ projectName, children }: { projectName: CtxPortals; children: React.ReactNode }) {\n return <ProjectContext.Provider value={projectName}>{children}</ProjectContext.Provider>;\n}\n\nexport function useProjectName(): CtxPortals {\n const projectName = use(ProjectContext);\n return projectName;\n}\n\nexport function useResourceFormatter(): (resourceName: string) => string {\n const portal = useProjectName();\n return (resourceName: string) => getResourceDisplayName(resourceName, portal);\n}\n\n/**\n * Format multiple license parameters (expired, suspended, revoked) into a single status\n */\nexport function getLicenseStatus(license: any): string {\n const licenseExpired = license.expiresAt && new Date(license.expiresAt) < new Date();\n // Status Column\n switch (true) {\n case license.revoked && license.suspended && licenseExpired:\n return 'Revoked, Suspended, Expired';\n case license.revoked && license.suspended:\n return 'Revoked, Suspended';\n case license.revoked && licenseExpired:\n return 'Revoked, Expired';\n case license.suspended && licenseExpired:\n return 'Suspended, Expired';\n case license.suspended:\n return 'Suspended';\n case license.revoked:\n return 'Revoked';\n case licenseExpired:\n return 'Expired';\n default:\n return 'Active';\n }\n}\ntype OsType = ApiSchema<'ActivationCreateRequestModel'>['os'];\nexport const ALL_OS: Record<OsType, string> = {\n windows: 'Windows',\n macos: 'macOS',\n linux: 'Linux',\n ios: 'iOS',\n android: 'Android',\n};\n"],"names":["OTHER_PORTALS_DISPLAY_NAME","RESOURCE_NAMES","RESOURCE_DISPLAY_NAMES","getResourceDisplayName","resourceName","portal","toTitleCase","ProjectContext","createContext","ProjectProvider","projectName","children","useProjectName","use","useResourceFormatter","getLicenseStatus","license","licenseExpired","ALL_OS"],"mappings":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YAAAC,EAAa,SAAAC,GAAoE,CAC/G,SAAQJ,EAAe,SAAf,CAAwB,MAAOG,EAAc,SAAAC,EAAS,CAClE,CAEO,SAASC,GAA6B,CAEzC,OADoBC,EAAIN,CAAc,CAE1C,CAEO,SAASO,GAAyD,CACrE,MAAMT,EAASO,EAAA,EACf,OAAQR,GAAyBD,EAAuBC,EAAcC,CAAM,CAChF,CAKO,SAASU,EAAiBC,EAAsB,CACnD,MAAMC,EAAiBD,EAAQ,WAAa,IAAI,KAAKA,EAAQ,SAAS,EAAI,IAAI,KAE9E,OAAQ,GAAA,CACJ,KAAKA,EAAQ,SAAWA,EAAQ,WAAaC,GACzC,MAAO,8BACX,KAAKD,EAAQ,SAAWA,EAAQ,WAC5B,MAAO,qBACX,KAAKA,EAAQ,SAAWC,GACpB,MAAO,mBACX,KAAKD,EAAQ,WAAaC,GACtB,MAAO,qBACX,KAAKD,EAAQ,UACT,MAAO,YACX,KAAKA,EAAQ,QACT,MAAO,UACX,KAAKC,EACD,MAAO,UACX,QACI,MAAO,QAAA,CAEnB,CAEO,MAAMC,EAAiC,CAC1C,QAAS,UACT,MAAO,QACP,MAAO,QACP,IAAK,MACL,QAAS,SACb"}
|
|
1
|
+
{"version":3,"file":"resources.js","sources":["../../lib/utilities/resources.tsx"],"sourcesContent":["import type { components, operations } from '@cryptlex/web-api-types/develop';\nimport type { ClientPathsWithMethod } from 'openapi-fetch';\nimport { createContext, use } from 'react';\nimport type { ctxClient } from '../../stories/story-commons';\nimport { toTitleCase } from './string';\n\nexport type ApiSchema<T extends keyof components['schemas']> = components['schemas'][T];\nexport type ApiQuery<T extends keyof operations> = NonNullable<operations[T]['parameters']['query']>;\nexport type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;\nexport type ApiFilters<T extends keyof operations> = NonNullable<ApiFilter<T>>;\nexport type CtxPortals = 'customer-portal' | 'system-portal' | 'reseller-portal' | 'admin-portal';\n// Display names specific to customer and reseller portal\nconst OTHER_PORTALS_DISPLAY_NAME: Record<string, string> = {\n 'product.displayName': 'Product',\n // TanStack Table converts . -> _ TODO\n product_displayName: 'Product',\n};\n\n// TODO, this drifts quite a lot from the API, should be updated\n/** Resource Name should ALWAYS be in singular form */\nexport const RESOURCE_NAMES = [\n 'access-token',\n 'account',\n 'activation',\n 'activation-log',\n 'admin-role',\n 'audit-log',\n 'automated-email',\n 'automated-email-event-log',\n 'card',\n 'entitlement-set',\n 'feature-flag',\n 'feature',\n 'invoice',\n 'license',\n 'license-template',\n 'maintenance-policy',\n 'organization',\n 'plan',\n 'product',\n 'product-version',\n 'profile',\n 'release',\n 'release-channel',\n 'release-file',\n 'release-platform',\n 'role',\n 'role-claim',\n 'saml-configuration',\n 'segment',\n 'sending-domain',\n 'tag',\n 'trial',\n 'trial-policy',\n 'user',\n 'user-group',\n 'webhook',\n 'webhook-event-log',\n 'webhook-event',\n 'reseller',\n 'oidc-configuration',\n 'tenant-database-cluster',\n] as const;\nexport type CtxResourceName = (typeof RESOURCE_NAMES)[number];\n\n// TODO, use OpenAPI spec for resource definitions\n\nconst RESOURCE_DISPLAY_NAMES: Record<string, string> = {\n id: 'ID',\n createdAt: 'Creation Date',\n scopes: 'Permissions',\n updatedAt: 'Last Updated',\n expiresAt: 'Expiration Date',\n lastSeenAt: 'Last Seen',\n os: 'OS',\n osVersion: 'OS Version',\n key: 'License Key',\n vmName: 'VM Name',\n container: 'Container',\n allowedIpRange: 'Allowed IP Range',\n allowedIpRanges: 'Allowed IP Ranges',\n allowedIpAddresses: 'Allowed IP Addresses',\n disallowedIpAddresses: 'Disallowed IP Addresses',\n allowVmActivation: 'Allow VM Activation',\n disableGeoLocation: 'Disable Geolocation',\n 'user.id': 'User ID',\n userId: 'User',\n productId: 'Product',\n downloads: 'Total Downloads',\n claims: 'Permissions',\n googleSsoEnabled: 'Google Login Enabled',\n lastAttemptedAt: 'Last Attempt Date',\n url: 'URL',\n 'trialPolicy.name': 'Trial Policy Name',\n 'licensePolicy.name': 'License Template Name',\n licensePolicy: 'License Template',\n eventLog: 'Audit Log',\n cc: 'CC Recepients',\n bcc: 'BCC Recepients',\n ipAddress: 'IP Address',\n resellerId: 'Reseller',\n productVersionId: 'Product Version',\n releaseId: 'Release',\n maintenancePolicyId: 'Maintenance Policy',\n webhookId: 'Webhook',\n automatedEmailId: 'Automated Email',\n 'location.countryName': 'Country',\n 'location.ipAddress': 'IP Address',\n 'location.countryCode': 'Country',\n organizationId: 'Organization',\n 'address.country': 'Country',\n 'address.addressLine1': 'Address Line 1',\n 'address.addressLine2': 'Address Line 2',\n responseStatusCode: 'HTTP Status Code',\n resourceId: 'Resource ID',\n Sso: 'SAML SSO 2.0',\n 'reseller.name': 'Reseller',\n sendingDomain: 'Email Sending Domain',\n};\n\nfunction getResourceDisplayName(resourceName: string, portal: CtxPortals) {\n if (portal !== 'admin-portal' && resourceName in OTHER_PORTALS_DISPLAY_NAME) {\n return OTHER_PORTALS_DISPLAY_NAME[resourceName];\n } else if (resourceName in RESOURCE_DISPLAY_NAMES) {\n return RESOURCE_DISPLAY_NAMES[resourceName];\n } else {\n return toTitleCase(resourceName);\n }\n}\n\nconst ProjectContext = createContext<CtxPortals>('admin-portal');\n\nexport function ProjectProvider({ projectName, children }: { projectName: CtxPortals; children: React.ReactNode }) {\n return <ProjectContext.Provider value={projectName}>{children}</ProjectContext.Provider>;\n}\n\nexport function useProjectName(): CtxPortals {\n const projectName = use(ProjectContext);\n return projectName;\n}\n\n/**\n * Mapping from resource names to their API endpoint paths.\n * Based on the OpenAPI spec paths.\n */\nexport const RESOURCE_ENDPOINT_MAP: Record<CtxResourceName, ClientPathsWithMethod<typeof ctxClient, 'get'>> = {\n 'access-token': '/v3/personal-access-tokens',\n account: '/v3/admin/accounts',\n activation: '/v3/activations',\n 'activation-log': '/v3/activation-logs',\n 'admin-role': '/v3/roles',\n 'audit-log': '/v3/event-logs',\n 'automated-email': '/v3/automated-emails',\n 'automated-email-event-log': '/v3/automated-email-event-logs',\n 'entitlement-set': '/v3/entitlement-sets',\n 'feature-flag': '/v3/feature-flags',\n feature: '/v3/features',\n license: '/v3/licenses',\n 'license-template': '/v3/license-templates',\n 'maintenance-policy': '/v3/maintenance-policies',\n organization: '/v3/organizations',\n plan: '/v3/plans',\n product: '/v3/products',\n 'product-version': '/v3/product-versions',\n release: '/v3/releases',\n 'release-channel': '/v3/release-channels',\n 'release-file': '/v3/release-files',\n 'release-platform': '/v3/release-platforms',\n reseller: '/v3/resellers',\n role: '/v3/roles',\n segment: '/v3/segments',\n 'sending-domain': '/v3/sending-domains',\n tag: '/v3/tags',\n trial: '/v3/trial-activations',\n 'trial-policy': '/v3/trial-policies',\n user: '/v3/users',\n 'user-group': '/v3/organizations/{organizationId}/user-groups',\n webhook: '/v3/webhooks',\n 'webhook-event-log': '/v3/webhook-event-logs',\n card: '/v3/billing/payment-methods/cards',\n invoice: '/v3/billing/invoices',\n /** This one is an exception, it does not return an array. DO NOT USE WITH IdSearch. */\n profile: '/v3/me',\n 'role-claim': '/v3/roles/claims',\n 'saml-configuration': '/v3/accounts/{id}/saml-configuration',\n 'webhook-event': '/v3/webhooks/events',\n 'oidc-configuration': '/v3/accounts/{id}/oidc-configuration',\n 'tenant-database-cluster': '/v3/admin/tenant-database-clusters',\n};\n\nexport function useResourceFormatter(): (resourceName: string) => string {\n const portal = useProjectName();\n return (resourceName: string) => getResourceDisplayName(resourceName, portal);\n}\n\n/**\n * Format multiple license parameters (expired, suspended, revoked) into a single status\n */\nexport function getLicenseStatus(license: any): string {\n const licenseExpired = license.expiresAt && new Date(license.expiresAt) < new Date();\n // Status Column\n switch (true) {\n case license.revoked && license.suspended && licenseExpired:\n return 'Revoked, Suspended, Expired';\n case license.revoked && license.suspended:\n return 'Revoked, Suspended';\n case license.revoked && licenseExpired:\n return 'Revoked, Expired';\n case license.suspended && licenseExpired:\n return 'Suspended, Expired';\n case license.suspended:\n return 'Suspended';\n case license.revoked:\n return 'Revoked';\n case licenseExpired:\n return 'Expired';\n default:\n return 'Active';\n }\n}\ntype OsType = ApiSchema<'ActivationCreateRequestModel'>['os'];\nexport const ALL_OS: Record<OsType, string> = {\n windows: 'Windows',\n macos: 'macOS',\n linux: 'Linux',\n ios: 'iOS',\n android: 'Android',\n};\n"],"names":["OTHER_PORTALS_DISPLAY_NAME","RESOURCE_NAMES","RESOURCE_DISPLAY_NAMES","getResourceDisplayName","resourceName","portal","toTitleCase","ProjectContext","createContext","ProjectProvider","projectName","children","useProjectName","use","RESOURCE_ENDPOINT_MAP","useResourceFormatter","getLicenseStatus","license","licenseExpired","ALL_OS"],"mappings":"mJAYA,MAAMA,EAAqD,CACvD,sBAAuB,UAEvB,oBAAqB,SACzB,EAIaC,EAAiB,CAC1B,eACA,UACA,aACA,iBACA,aACA,YACA,kBACA,4BACA,OACA,kBACA,eACA,UACA,UACA,UACA,mBACA,qBACA,eACA,OACA,UACA,kBACA,UACA,UACA,kBACA,eACA,mBACA,OACA,aACA,qBACA,UACA,iBACA,MACA,QACA,eACA,OACA,aACA,UACA,oBACA,gBACA,WACA,qBACA,yBACJ,EAKMC,EAAiD,CACnD,GAAI,KACJ,UAAW,gBACX,OAAQ,cACR,UAAW,eACX,UAAW,kBACX,WAAY,YACZ,GAAI,KACJ,UAAW,aACX,IAAK,cACL,OAAQ,UACR,UAAW,YACX,eAAgB,mBAChB,gBAAiB,oBACjB,mBAAoB,uBACpB,sBAAuB,0BACvB,kBAAmB,sBACnB,mBAAoB,sBACpB,UAAW,UACX,OAAQ,OACR,UAAW,UACX,UAAW,kBACX,OAAQ,cACR,iBAAkB,uBAClB,gBAAiB,oBACjB,IAAK,MACL,mBAAoB,oBACpB,qBAAsB,wBACtB,cAAe,mBACf,SAAU,YACV,GAAI,gBACJ,IAAK,iBACL,UAAW,aACX,WAAY,WACZ,iBAAkB,kBAClB,UAAW,UACX,oBAAqB,qBACrB,UAAW,UACX,iBAAkB,kBAClB,uBAAwB,UACxB,qBAAsB,aACtB,uBAAwB,UACxB,eAA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KA,EAAQ,SAAS,EAAI,IAAI,KAE9E,OAAQ,GAAA,CACJ,KAAKA,EAAQ,SAAWA,EAAQ,WAAaC,GACzC,MAAO,8BACX,KAAKD,EAAQ,SAAWA,EAAQ,WAC5B,MAAO,qBACX,KAAKA,EAAQ,SAAWC,GACpB,MAAO,mBACX,KAAKD,EAAQ,WAAaC,GACtB,MAAO,qBACX,KAAKD,EAAQ,UACT,MAAO,YACX,KAAKA,EAAQ,QACT,MAAO,UACX,KAAKC,EACD,MAAO,UACX,QACI,MAAO,QAAA,CAEnB,CAEO,MAAMC,EAAiC,CAC1C,QAAS,UACT,MAAO,QACP,MAAO,QACP,IAAK,MACL,QAAS,SACb"}
|
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare function toTitleCase(input?: string): string;
|
|
5
5
|
export declare function pluralizeTimes(resourceName: string, count: number): string;
|
|
6
|
+
/**
|
|
7
|
+
* Normalizes a label string by trimming, lowercasing, and replacing whitespace with hyphens.
|
|
8
|
+
* Used for generating consistent IDs from user-facing labels.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeLabel(label: string): string;
|
package/dist/utilities/string.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{startCase as
|
|
1
|
+
import{startCase as r}from"lodash-es";function e(t){return r(t)}function a(t,n){return n>1?/y$/.test(t)?t==="Day"?"Days":t.replace(/y$/,"ies"):t.concat("s"):t}function f(t){return t.trim().toLowerCase().replace(/\s+/g,"-")}export{f as normalizeLabel,a as pluralizeTimes,e as toTitleCase};
|
|
2
2
|
//# sourceMappingURL=string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sources":["../../lib/utilities/string.ts"],"sourcesContent":["import { startCase } from 'lodash-es';\n\n/**\n *\n */\nexport function toTitleCase(input?: string): string {\n return startCase(input);\n}\n\nexport function pluralizeTimes(resourceName: string, count: number) {\n if (count > 1) {\n if (/y$/.test(resourceName)) {\n if (resourceName === 'Day') return 'Days';\n return resourceName.replace(/y$/, 'ies');\n }\n return resourceName.concat('s');\n }\n return resourceName;\n}\n"],"names":["toTitleCase","input","startCase","pluralizeTimes","resourceName","count"],"mappings":"sCAKO,SAASA,EAAYC,EAAwB,CAChD,OAAOC,EAAUD,CAAK,CAC1B,CAEO,SAASE,EAAeC,EAAsBC,EAAe,CAChE,OAAIA,EAAQ,EACJ,KAAK,KAAKD,CAAY,EAClBA,IAAiB,MAAc,OAC5BA,EAAa,QAAQ,KAAM,KAAK,EAEpCA,EAAa,OAAO,GAAG,EAE3BA,CACX"}
|
|
1
|
+
{"version":3,"file":"string.js","sources":["../../lib/utilities/string.ts"],"sourcesContent":["import { startCase } from 'lodash-es';\n\n/**\n *\n */\nexport function toTitleCase(input?: string): string {\n return startCase(input);\n}\n\nexport function pluralizeTimes(resourceName: string, count: number) {\n if (count > 1) {\n if (/y$/.test(resourceName)) {\n if (resourceName === 'Day') return 'Days';\n return resourceName.replace(/y$/, 'ies');\n }\n return resourceName.concat('s');\n }\n return resourceName;\n}\n\n/**\n * Normalizes a label string by trimming, lowercasing, and replacing whitespace with hyphens.\n * Used for generating consistent IDs from user-facing labels.\n */\nexport function normalizeLabel(label: string): string {\n return label.trim().toLowerCase().replace(/\\s+/g, '-');\n}\n"],"names":["toTitleCase","input","startCase","pluralizeTimes","resourceName","count","normalizeLabel","label"],"mappings":"sCAKO,SAASA,EAAYC,EAAwB,CAChD,OAAOC,EAAUD,CAAK,CAC1B,CAEO,SAASE,EAAeC,EAAsBC,EAAe,CAChE,OAAIA,EAAQ,EACJ,KAAK,KAAKD,CAAY,EAClBA,IAAiB,MAAc,OAC5BA,EAAa,QAAQ,KAAM,KAAK,EAEpCA,EAAa,OAAO,GAAG,EAE3BA,CACX,CAMO,SAASE,EAAeC,EAAuB,CAClD,OAAOA,EAAM,OAAO,cAAc,QAAQ,OAAQ,GAAG,CACzD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FieldApi as FieldApiType } from '@tanstack/react-form';
|
|
2
|
+
type FieldApi = FieldApiType<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Validates that the value of an array item is unique.
|
|
5
|
+
* @param arrayFieldName - The field name of the array.
|
|
6
|
+
* @param currentIndex - The current index of the array item.
|
|
7
|
+
* @param key - The property name of the item.
|
|
8
|
+
* @returns A validator function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getUniqueArrayItemValidator(arrayFieldName: string, currentIndex: number, key: string): ({ value, fieldApi }: {
|
|
11
|
+
value: any;
|
|
12
|
+
fieldApi: FieldApi;
|
|
13
|
+
}) => {
|
|
14
|
+
message: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{z as m}from"zod";function I(a,o,f){return({value:t,fieldApi:l})=>{const r=l.form.state.values[a],c=s=>{if(!Array.isArray(r))return!0;const g=s.toLowerCase();let i=null;for(let e=0;e<r.length;e++){const u=r[e]?.[f];if(typeof u=="string"&&u.toLowerCase()===g){if(i===null)i=e;else if(e===o)return!1}}return!0},n=m.string().min(1).refine(s=>c(s),{message:`'${t}' already exists. Enter a unique value.`}).safeParse(t);return n.success?void 0:{message:n.error.issues[0]?.message}}}export{I as getUniqueArrayItemValidator};
|
|
2
|
+
//# sourceMappingURL=validators.js.map
|