@hirobius/design-system 0.8.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/LICENSE/main.tsx +21 -0
- package/README.md +124 -0
- package/dist/chunks/TokenDisplayContext-B3gxyQN7.js +95 -0
- package/dist/chunks/form-DnGRy27o.js +63 -0
- package/dist/cn.js +8 -0
- package/dist/contexts.js +133 -0
- package/dist/form.js +62 -0
- package/dist/hirobius-ui.js +5611 -0
- package/dist/manifest.js +28 -0
- package/dist/tokens.css +1 -0
- package/dist/tokens.js +693 -0
- package/dist/types/src/app/components/activity-feed.d.ts +43 -0
- package/dist/types/src/app/components/alert.d.ts +18 -0
- package/dist/types/src/app/components/asset-img.d.ts +54 -0
- package/dist/types/src/app/components/avatar.d.ts +23 -0
- package/dist/types/src/app/components/badge.d.ts +20 -0
- package/dist/types/src/app/components/breadcrumb.d.ts +26 -0
- package/dist/types/src/app/components/button.d.ts +37 -0
- package/dist/types/src/app/components/callout.d.ts +23 -0
- package/dist/types/src/app/components/card.d.ts +119 -0
- package/dist/types/src/app/components/checkbox.d.ts +20 -0
- package/dist/types/src/app/components/cinematic-link.d.ts +13 -0
- package/dist/types/src/app/components/code-block.d.ts +29 -0
- package/dist/types/src/app/components/combobox.d.ts +46 -0
- package/dist/types/src/app/components/component-instance-matrix.d.ts +21 -0
- package/dist/types/src/app/components/container.d.ts +31 -0
- package/dist/types/src/app/components/dialog.d.ts +73 -0
- package/dist/types/src/app/components/disclosure.d.ts +32 -0
- package/dist/types/src/app/components/divider.d.ts +21 -0
- package/dist/types/src/app/components/doc-link-card.d.ts +26 -0
- package/dist/types/src/app/components/empty-state.d.ts +24 -0
- package/dist/types/src/app/components/error-boundary.d.ts +25 -0
- package/dist/types/src/app/components/error-pattern.d.ts +9 -0
- package/dist/types/src/app/components/field.d.ts +25 -0
- package/dist/types/src/app/components/form.d.ts +106 -0
- package/dist/types/src/app/components/foundation-swatch.d.ts +39 -0
- package/dist/types/src/app/components/grid.d.ts +65 -0
- package/dist/types/src/app/components/heading-stack.d.ts +42 -0
- package/dist/types/src/app/components/history-card.d.ts +12 -0
- package/dist/types/src/app/components/icon-button.d.ts +23 -0
- package/dist/types/src/app/components/icon.d.ts +30 -0
- package/dist/types/src/app/components/info-page.d.ts +10 -0
- package/dist/types/src/app/components/inline-code.d.ts +12 -0
- package/dist/types/src/app/components/inline-link.d.ts +17 -0
- package/dist/types/src/app/components/input.d.ts +46 -0
- package/dist/types/src/app/components/lab/tokenUtils.d.ts +38 -0
- package/dist/types/src/app/components/menu.d.ts +56 -0
- package/dist/types/src/app/components/nav-group.d.ts +24 -0
- package/dist/types/src/app/components/nav-item.d.ts +21 -0
- package/dist/types/src/app/components/not-found-pattern.d.ts +1 -0
- package/dist/types/src/app/components/page.d.ts +43 -0
- package/dist/types/src/app/components/pagination.d.ts +24 -0
- package/dist/types/src/app/components/popover.d.ts +44 -0
- package/dist/types/src/app/components/progress.d.ts +25 -0
- package/dist/types/src/app/components/radio.d.ts +18 -0
- package/dist/types/src/app/components/segmented-control.d.ts +33 -0
- package/dist/types/src/app/components/skeleton.d.ts +25 -0
- package/dist/types/src/app/components/sketch.d.ts +13 -0
- package/dist/types/src/app/components/slider.d.ts +22 -0
- package/dist/types/src/app/components/spinner.d.ts +20 -0
- package/dist/types/src/app/components/stack.d.ts +39 -0
- package/dist/types/src/app/components/stat.d.ts +24 -0
- package/dist/types/src/app/components/status-list-item.d.ts +25 -0
- package/dist/types/src/app/components/status-tile.d.ts +22 -0
- package/dist/types/src/app/components/stepper-field.d.ts +13 -0
- package/dist/types/src/app/components/surface-padding.d.ts +18 -0
- package/dist/types/src/app/components/surface.d.ts +30 -0
- package/dist/types/src/app/components/table.d.ts +40 -0
- package/dist/types/src/app/components/tabs.d.ts +27 -0
- package/dist/types/src/app/components/tag.d.ts +32 -0
- package/dist/types/src/app/components/text-lockup.d.ts +38 -0
- package/dist/types/src/app/components/text.d.ts +26 -0
- package/dist/types/src/app/components/tile-grid.d.ts +17 -0
- package/dist/types/src/app/components/toast.d.ts +56 -0
- package/dist/types/src/app/components/toggle.d.ts +18 -0
- package/dist/types/src/app/components/token.d.ts +59 -0
- package/dist/types/src/app/components/tooltip.d.ts +33 -0
- package/dist/types/src/app/context/DemoStateContext.d.ts +21 -0
- package/dist/types/src/app/context/FontContext.d.ts +4 -0
- package/dist/types/src/app/context/LanguageContext.d.ts +23 -0
- package/dist/types/src/app/context/RouterContext.d.ts +61 -0
- package/dist/types/src/app/context/TenantContext.d.ts +29 -0
- package/dist/types/src/app/context/ThemeContext.d.ts +18 -0
- package/dist/types/src/app/context/TokenDisplayContext.d.ts +11 -0
- package/dist/types/src/app/context/index.d.ts +19 -0
- package/dist/types/src/app/data/manifest-types.d.ts +128 -0
- package/dist/types/src/app/design-system/generated-token-refs.d.ts +586 -0
- package/dist/types/src/app/design-system/generated-token-values.d.ts +223 -0
- package/dist/types/src/app/design-system/theme.d.ts +32 -0
- package/dist/types/src/app/design-system/tokens.d.ts +333 -0
- package/dist/types/src/app/hooks/useFocusVisible.d.ts +9 -0
- package/dist/types/src/app/hooks/useInteractionState.d.ts +27 -0
- package/dist/types/src/app/layouts/CaseStudyLayout.d.ts +21 -0
- package/dist/types/src/app/layouts/DocLayout.d.ts +16 -0
- package/dist/types/src/app/layouts/EmbeddedDocLayoutContext.d.ts +6 -0
- package/dist/types/src/app/lib/nav-active.d.ts +16 -0
- package/dist/types/src/app/lib/navLevels.d.ts +4 -0
- package/dist/types/src/app/pages/hds/HdsSystemDocLayout.d.ts +7 -0
- package/dist/types/src/form/hds-form.d.ts +61 -0
- package/dist/types/src/form/index.d.ts +30 -0
- package/dist/types/src/form/use-hds-form.d.ts +23 -0
- package/dist/types/src/index.d.ts +2276 -0
- package/dist/types/src/lib/deprecation.d.ts +4 -0
- package/dist/types/src/lib/manifest-entry.d.ts +3 -0
- package/dist/types/src/lib/utils.d.ts +3 -0
- package/dist/variables.css +461 -0
- package/hirobius.tokens.json +2220 -0
- package/package.json +366 -0
- package/protocol/envelope.mjs +201 -0
- package/protocol/figma-snapshot.schema.json +190 -0
- package/public/hds-manifest.json +11230 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type NavLevel = 'root' | 'section' | 'nested' | 'deep';
|
|
2
|
+
export declare function getNavLevelInset(level: NavLevel): string;
|
|
3
|
+
export declare function getNavLevelLeadingPadding(level: NavLevel): string;
|
|
4
|
+
export declare function getNextNavLevel(level: NavLevel): NavLevel;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type DocLayoutContentMaxWidth } from '../../layouts/DocLayout';
|
|
3
|
+
/** @public */
|
|
4
|
+
export declare function HdsSystemDocLayout({ contentSlot, contentMaxWidth, }: {
|
|
5
|
+
contentSlot: ReactNode;
|
|
6
|
+
contentMaxWidth?: DocLayoutContentMaxWidth;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type UseFormReturn, type FieldValues, type FieldPath } from 'react-hook-form';
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface HdsFormProps<TFieldValues extends FieldValues> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {
|
|
5
|
+
/** The form object returned by `useHdsForm`. */
|
|
6
|
+
form: UseFormReturn<TFieldValues>;
|
|
7
|
+
/** Called with the parsed, validated values once the schema passes. */
|
|
8
|
+
onSubmit: (values: TFieldValues) => void | Promise<void>;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps the presentational `Form` in RHF's `FormProvider` and routes submission
|
|
13
|
+
* through `handleSubmit` so `onSubmit` only fires with schema-valid values.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare function HdsForm<TFieldValues extends FieldValues>({ form, onSubmit, children, ...formProps }: HdsFormProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Props handed to `HdsFormField`'s render function — spread them onto your
|
|
19
|
+
* control. They combine RHF's field binding (`name`/`value`/`onChange`/`onBlur`/
|
|
20
|
+
* `ref`) with HDS's a11y wiring (`id`/`aria-invalid`/`aria-describedby`).
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface HdsFieldRenderProps {
|
|
24
|
+
name: string;
|
|
25
|
+
value: unknown;
|
|
26
|
+
onChange: (...args: unknown[]) => void;
|
|
27
|
+
onBlur: (...args: unknown[]) => void;
|
|
28
|
+
ref: React.Ref<unknown>;
|
|
29
|
+
id: string;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
'aria-invalid'?: boolean;
|
|
32
|
+
'aria-describedby'?: string;
|
|
33
|
+
}
|
|
34
|
+
/** @public */
|
|
35
|
+
export interface HdsFormFieldProps<TFieldValues extends FieldValues = FieldValues> {
|
|
36
|
+
/** Field name — a typed path into the form's values. */
|
|
37
|
+
name: FieldPath<TFieldValues>;
|
|
38
|
+
/** Field label, associated to the control via htmlFor/id. */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Render the control, spreading the supplied props (binding + a11y) onto it. */
|
|
41
|
+
children: (props: HdsFieldRenderProps) => React.ReactElement;
|
|
42
|
+
/** Helper text below the control; linked via aria-describedby. */
|
|
43
|
+
description?: string;
|
|
44
|
+
/** Adds the required marker + sets `required` on the control. */
|
|
45
|
+
required?: boolean;
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Binds a control to RHF by `name` and renders it inside the presentational
|
|
50
|
+
* field markup. The control is supplied via a render function so RHF's callback
|
|
51
|
+
* ref attaches directly (no clone). The field's validation error (its `message`
|
|
52
|
+
* from the Zod schema) is shown through the same label/error/aria markup the
|
|
53
|
+
* core `FormField` uses.
|
|
54
|
+
*
|
|
55
|
+
* <HdsFormField name="email" label="Email">
|
|
56
|
+
* {(props) => <input type="email" className="…" {...props} />}
|
|
57
|
+
* </HdsFormField>
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare function HdsFormField<TFieldValues extends FieldValues = FieldValues>({ name, label, children, description, required, className, }: HdsFormFieldProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@hirobius/design-system/form`
|
|
3
|
+
*
|
|
4
|
+
* OPTIONAL React Hook Form + Zod adapter for HDS forms. Kept on its own subpath
|
|
5
|
+
* so the main barrel stays validation-agnostic and zero-dependency — only apps
|
|
6
|
+
* that import this entry pull in `react-hook-form`, `zod`, and
|
|
7
|
+
* `@hookform/resolvers` (all declared as optional peer dependencies).
|
|
8
|
+
*
|
|
9
|
+
* import { z } from 'zod';
|
|
10
|
+
* import { useHdsForm, HdsForm, HdsFormField } from '@hirobius/design-system/form';
|
|
11
|
+
*
|
|
12
|
+
* const schema = z.object({ email: z.string().email('Enter a valid email') });
|
|
13
|
+
*
|
|
14
|
+
* function SignUp() {
|
|
15
|
+
* const form = useHdsForm(schema, { defaultValues: { email: '' } });
|
|
16
|
+
* return (
|
|
17
|
+
* <HdsForm form={form} onSubmit={(values) => save(values)}>
|
|
18
|
+
* <HdsFormField name="email" label="Email">
|
|
19
|
+
* {(props) => <input type="email" className="…" {...props} />}
|
|
20
|
+
* </HdsFormField>
|
|
21
|
+
* <Button type="submit">Save</Button>
|
|
22
|
+
* </HdsForm>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @doc-ignore subpath barrel, not an HDS component
|
|
27
|
+
*/
|
|
28
|
+
export { useHdsForm } from './use-hds-form';
|
|
29
|
+
export { HdsForm, HdsFormField } from './hds-form';
|
|
30
|
+
export type { HdsFormProps, HdsFormFieldProps, HdsFieldRenderProps } from './hds-form';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useHdsForm — React Hook Form pre-wired with a Zod resolver.
|
|
3
|
+
*
|
|
4
|
+
* Part of the OPTIONAL `@hirobius/design-system/form` subpath. RHF + Zod are
|
|
5
|
+
* optional peer dependencies, so consumers that never import this subpath pay
|
|
6
|
+
* nothing for them (the main barrel stays validation-agnostic).
|
|
7
|
+
*
|
|
8
|
+
* const schema = z.object({ email: z.string().email() });
|
|
9
|
+
* const form = useHdsForm(schema, { defaultValues: { email: '' } });
|
|
10
|
+
*
|
|
11
|
+
* @doc-ignore adapter for the ./form subpath, not an HDS component
|
|
12
|
+
*/
|
|
13
|
+
import { type UseFormProps, type UseFormReturn, type FieldValues } from 'react-hook-form';
|
|
14
|
+
import type { ZodType } from 'zod';
|
|
15
|
+
/**
|
|
16
|
+
* Thin wrapper over RHF's `useForm` that pre-wires `zodResolver(schema)` and
|
|
17
|
+
* defaults validation to `onTouched` (errors surface after a field blurs, not on
|
|
18
|
+
* every keystroke). The schema's parsed output type drives the form's field
|
|
19
|
+
* types, so `form.handleSubmit` hands you a fully-typed, validated value object.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function useHdsForm<TFieldValues extends FieldValues>(schema: ZodType<TFieldValues>, options?: Omit<UseFormProps<TFieldValues>, 'resolver'>): UseFormReturn<TFieldValues>;
|