@dinofront/design_system 1.1.0 → 1.2.1
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/DatePicker/DatePicker.types.d.ts +12 -0
- package/dist/components/FormField/FormField.types.d.ts +8 -1
- package/dist/components/Radio/Radio.types.d.ts +1 -0
- package/dist/components/Select/Select.types.d.ts +17 -0
- package/dist/components/Upload/Upload.types.d.ts +5 -1
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useEscapeKey.d.ts +4 -0
- package/dist/hooks/useFormContext.d.ts +6 -0
- package/dist/hooks/useFormProps.d.ts +9 -0
- package/dist/hooks/useHideBodyScroll.d.ts +6 -0
- package/dist/hooks/useIsMobile.d.ts +9 -0
- package/dist/hooks/useOnOutsideClick.d.ts +6 -0
- package/dist/index.js +2138 -1774
- package/dist/index.js.map +1 -1
- package/dist/styles.css +20 -0
- package/package.json +1 -5
- package/dist/FormField-CwRAOtTN.js +0 -170
- package/dist/FormField-CwRAOtTN.js.map +0 -1
- package/dist/form/index.d.ts +0 -2
- package/dist/form.d.ts +0 -2
- package/dist/form.js +0 -2
|
@@ -18,6 +18,18 @@ export interface DatePickerProps extends BaseProps {
|
|
|
18
18
|
/** Fill the parent's width (like Input/Select) instead of the intrinsic
|
|
19
19
|
* min-width. Use inside form grids so dates line up with other fields. */
|
|
20
20
|
fullWidth?: boolean;
|
|
21
|
+
/** Disable the trigger entirely — blocks both mouse and keyboard activation. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Earliest selectable day, inclusive. Earlier days render disabled. Time-of-day is ignored. */
|
|
24
|
+
minDate?: Date;
|
|
25
|
+
/** Latest selectable day, inclusive. Later days render disabled. Time-of-day is ignored. */
|
|
26
|
+
maxDate?: Date;
|
|
27
|
+
/** Individual days that can't be picked. Matched by calendar day; time-of-day is ignored. */
|
|
28
|
+
excludeDates?: Date[];
|
|
29
|
+
/** Switch the trigger to the danger border/ring styles. */
|
|
30
|
+
error?: boolean;
|
|
31
|
+
/** Message rendered below the control; also switches the trigger to the danger styles. */
|
|
32
|
+
errorText?: ReactNode;
|
|
21
33
|
id?: string;
|
|
22
34
|
className?: string;
|
|
23
35
|
wrapperClassName?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
-
import { RefCallBack } from 'react-hook-form';
|
|
2
|
+
import { RefCallBack, SetValueConfig } from 'react-hook-form';
|
|
3
3
|
import { BaseProps } from '../../types';
|
|
4
4
|
/** Deliberately untyped `value`/`onChange`: this render prop feeds whichever
|
|
5
5
|
* input the consumer wires up (native `value`, Select's `string`, Checkbox's
|
|
@@ -13,6 +13,13 @@ export interface FormFieldRenderProps {
|
|
|
13
13
|
error: boolean;
|
|
14
14
|
errorText?: string;
|
|
15
15
|
dataTestId?: string;
|
|
16
|
+
/** Imperatively set this field's value, pre-bound to this FormField's
|
|
17
|
+
* `name` — for a component whose own change contract doesn't fit RHF's
|
|
18
|
+
* field bindings. Defaults `shouldValidate`/`shouldDirty`/`shouldTouch`
|
|
19
|
+
* to `true`, overridable via `options`. */
|
|
20
|
+
setFieldValue: (value: unknown, options?: SetValueConfig) => void;
|
|
21
|
+
/** True once the field has been touched, changed from its default value, and currently passes validation. */
|
|
22
|
+
isValid: boolean;
|
|
16
23
|
}
|
|
17
24
|
export interface FormFieldProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue'>, BaseProps {
|
|
18
25
|
name: string;
|
|
@@ -5,6 +5,13 @@ export interface SelectOption {
|
|
|
5
5
|
value: string;
|
|
6
6
|
label: ReactNode;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
/** Group heading this option belongs under. Options sharing a group MUST be
|
|
9
|
+
* contiguous in the `options` array — the heading is emitted whenever this
|
|
10
|
+
* value changes between consecutive options, so a non-contiguous group
|
|
11
|
+
* renders its heading more than once. */
|
|
12
|
+
group?: string;
|
|
13
|
+
/** Text used for `searchable` matching when `label` isn't a plain string. */
|
|
14
|
+
searchText?: string;
|
|
8
15
|
}
|
|
9
16
|
export interface SelectProps extends BaseProps {
|
|
10
17
|
options: SelectOption[];
|
|
@@ -20,6 +27,16 @@ export interface SelectProps extends BaseProps {
|
|
|
20
27
|
error?: boolean;
|
|
21
28
|
size?: SelectSize;
|
|
22
29
|
disabled?: boolean;
|
|
30
|
+
/** Renders a red asterisk next to the label and sets `aria-required` on the trigger. */
|
|
31
|
+
required?: boolean;
|
|
32
|
+
/** Shows a spinner in place of the chevron and blocks opening the list. Does not set the native `disabled` attribute. */
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
/** Renders a text filter pinned above the open list. */
|
|
35
|
+
searchable?: boolean;
|
|
36
|
+
/** Placeholder for the `searchable` filter input. Defaults to `'Search…'`. */
|
|
37
|
+
searchPlaceholder?: string;
|
|
38
|
+
/** Shown in place of the list when the filter matches nothing. Defaults to `'No results'`. */
|
|
39
|
+
emptyText?: string;
|
|
23
40
|
id?: string;
|
|
24
41
|
className?: string;
|
|
25
42
|
wrapperClassName?: string;
|
|
@@ -6,7 +6,7 @@ export interface UploadRejection {
|
|
|
6
6
|
file: File;
|
|
7
7
|
reason: UploadRejectionReason;
|
|
8
8
|
}
|
|
9
|
-
export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDrop' | 'onDragEnter' | 'onDragOver' | 'onDragLeave' | 'onKeyDown' | 'role' | 'tabIndex' | 'aria-disabled'>, BaseProps {
|
|
9
|
+
export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDrop' | 'onDragEnter' | 'onDragOver' | 'onDragLeave' | 'onKeyDown' | 'role' | 'tabIndex' | 'aria-disabled' | 'aria-invalid'>, BaseProps {
|
|
10
10
|
/** Forwarded to the hidden native `<input type="file">`, e.g. `"image/png,image/jpeg"`. */
|
|
11
11
|
accept?: string;
|
|
12
12
|
multiple?: boolean;
|
|
@@ -35,6 +35,10 @@ export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onCli
|
|
|
35
35
|
triggerIcon?: ReactNode;
|
|
36
36
|
label?: ReactNode;
|
|
37
37
|
required?: boolean;
|
|
38
|
+
/** Switches the dropzone (or, in `button`/`icon` mode, just the message below) to the danger styles. */
|
|
39
|
+
error?: boolean;
|
|
40
|
+
/** Message rendered below the control; also switches dropzone mode to the danger styles. */
|
|
41
|
+
errorText?: ReactNode;
|
|
38
42
|
/** Content rendered on the label row, right of the label text and required marker — e.g. an info tooltip trigger. */
|
|
39
43
|
labelAddons?: ReactNode;
|
|
40
44
|
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export { useStepper } from './useStepper';
|
|
2
2
|
export type { UseStepperOptions, UseStepperResult } from './useStepper';
|
|
3
|
+
export { useOnOutsideClick } from './useOnOutsideClick';
|
|
4
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
5
|
+
export { useHideBodyScroll } from './useHideBodyScroll';
|
|
6
|
+
export { useIsMobile } from './useIsMobile';
|
|
7
|
+
export { useFormContext } from './useFormContext';
|
|
8
|
+
export { useFormProps } from './useFormProps';
|
|
9
|
+
export type { FormContextValue } from '../lib/FormContext';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Fires `onEscape` when the user presses `Escape`, anywhere in the
|
|
2
|
+
* document — not scoped to a container, matching how dismissible
|
|
3
|
+
* overlays (menus, drawers, popovers) listen for it today. */
|
|
4
|
+
export declare function useEscapeKey(onEscape: () => void, enabled?: boolean): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormContextValue } from '../lib/FormContext';
|
|
2
|
+
/** Reads the ambient form state provided by the nearest `FormContainer`.
|
|
3
|
+
* Throws outside one, matching `FormField`'s existing null-check — the
|
|
4
|
+
* same failure whether a consumer uses `FormField` or this hook
|
|
5
|
+
* directly. */
|
|
6
|
+
export declare function useFormContext(): FormContextValue;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormContextValue } from '../lib/FormContext';
|
|
2
|
+
/** Reads the ambient form state provided by the nearest `FormContainer` —
|
|
3
|
+
* the same context `useFormContext` reads — but never throws outside
|
|
4
|
+
* one. Returns an inert default context instead, so call sites migrated
|
|
5
|
+
* from an existing `useFormProps()` (e.g. an app's own hrm_ui_lib-shaped
|
|
6
|
+
* shim) keep working without adding a null check. Prefer
|
|
7
|
+
* `useFormContext` in new code, where a missing `FormContainer` is
|
|
8
|
+
* usually a programmer error you want to surface immediately. */
|
|
9
|
+
export declare function useFormProps(): FormContextValue;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Locks `document.body` scrolling while `active`, restoring whatever
|
|
2
|
+
* `overflow` value was set before the first lock once the last active
|
|
3
|
+
* caller deactivates. Reference-counted across concurrent callers (e.g.
|
|
4
|
+
* a drawer opened from within a modal) so one overlay closing early
|
|
5
|
+
* never clobbers another's lock. */
|
|
6
|
+
export declare function useHideBodyScroll(active: boolean): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** True when the viewport is at or below `breakpoint` (default 768px).
|
|
2
|
+
* Returns `false` during SSR and during the very first client render —
|
|
3
|
+
* the effect computes and syncs the real value right after mount, so
|
|
4
|
+
* the server-rendered markup and the client's first render always
|
|
5
|
+
* agree (no hydration mismatch), at the cost of one extra render after
|
|
6
|
+
* mount when the viewport actually is narrow. Subscribes to the media
|
|
7
|
+
* query's `change` event rather than `window.resize`, so it only
|
|
8
|
+
* re-renders when the mobile/desktop boundary is actually crossed. */
|
|
9
|
+
export declare function useIsMobile(breakpoint?: number): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/** Fires `handler` on any `mousedown`/`touchstart` outside `ref.current`.
|
|
3
|
+
* No effect while `ref.current` is null or `enabled` is false — callers
|
|
4
|
+
* don't need to guard call sites where the ref isn't attached yet (e.g.
|
|
5
|
+
* before a portal mounts). */
|
|
6
|
+
export declare function useOnOutsideClick(ref: RefObject<HTMLElement | null> | null | undefined, handler: (event: MouseEvent | TouchEvent) => void, enabled?: boolean): void;
|