@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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text — polymorphic typography primitive spanning the full HDS type ramp.
|
|
3
|
+
*
|
|
4
|
+
* @category Typography
|
|
5
|
+
* @tier primitive
|
|
6
|
+
* @doc-exempt: typography primitive is documented through the Typography ramp page (TypographyPage), not as a standalone component card
|
|
7
|
+
*/
|
|
8
|
+
import { type CSSProperties, type ElementType, type HTMLAttributes, type ReactNode } from 'react';
|
|
9
|
+
type TextVariant = 'display' | 'heading1' | 'heading2' | 'heading3' | 'body' | 'ui' | 'eyebrow' | 'caption' | 'technical' | 'badge' | 'docLede' | 'docBody' | 'docSmall' | 'docCode';
|
|
10
|
+
type TextTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div';
|
|
11
|
+
/** @public */
|
|
12
|
+
export type TextProps = {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
variant: TextVariant;
|
|
15
|
+
as?: TextTag | ElementType;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
} & HTMLAttributes<HTMLElement>;
|
|
19
|
+
export declare const Text: import("react").ForwardRefExoticComponent<{
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
variant: TextVariant;
|
|
22
|
+
as?: TextTag | ElementType;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
} & HTMLAttributes<HTMLElement> & import("react").RefAttributes<HTMLElement>>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Layout
|
|
3
|
+
* @tier primitive
|
|
4
|
+
*/
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
/** @public */
|
|
7
|
+
export interface TileGridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
/** Minimum tile width before the grid wraps. Defaults to 260px. */
|
|
9
|
+
minTileWidth?: string;
|
|
10
|
+
/** Gap token between tiles. Defaults to 'sm' (12px). */
|
|
11
|
+
gap?: 'xs' | 'sm' | 'md';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Auto-fill responsive grid for status/micro tiles. Wraps tile children in a
|
|
15
|
+
* one-line grid declaration so pages don't repeat the auto-fill minmax recipe.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TileGrid: React.ForwardRefExoticComponent<TileGridProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toast — transient feedback notifications (Radix Toast).
|
|
3
|
+
* @category Feedback
|
|
4
|
+
* @tier pattern
|
|
5
|
+
* @doc-exempt: no Overlays/Feedback-overlay doc page yet — add demo when created
|
|
6
|
+
*
|
|
7
|
+
* Imperative API: wrap the app once in <ToastProvider>, then call
|
|
8
|
+
* `useToast().toast({ title, description, tone })` from anywhere. Radix Toast
|
|
9
|
+
* (@radix-ui/react-toast) owns the a11y live-region, auto-dismiss timing,
|
|
10
|
+
* swipe-to-dismiss, and viewport portal.
|
|
11
|
+
*
|
|
12
|
+
* function App() {
|
|
13
|
+
* return <ToastProvider><Page /></ToastProvider>;
|
|
14
|
+
* }
|
|
15
|
+
* function SaveButton() {
|
|
16
|
+
* const { toast } = useToast();
|
|
17
|
+
* return <Button onClick={() => toast({ title: 'Saved', tone: 'success' })}>Save</Button>;
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
import * as React from 'react';
|
|
21
|
+
import * as ToastPrimitive from '@radix-ui/react-toast';
|
|
22
|
+
/** @public */
|
|
23
|
+
export type ToastTone = 'neutral' | 'info' | 'success' | 'danger' | 'warning';
|
|
24
|
+
/** @public */
|
|
25
|
+
export interface ToastOptions {
|
|
26
|
+
/** Headline line — the primary message. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** Optional supporting line below the title. */
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Semantic tone — tints the leading icon. */
|
|
31
|
+
tone?: ToastTone;
|
|
32
|
+
/** Auto-dismiss in ms. Falls back to the provider default. */
|
|
33
|
+
duration?: number;
|
|
34
|
+
}
|
|
35
|
+
interface ToastContextValue {
|
|
36
|
+
/** Enqueue a toast; returns its id. */
|
|
37
|
+
toast: (options: ToastOptions) => string;
|
|
38
|
+
/** Dismiss a toast by id. */
|
|
39
|
+
dismiss: (id: string) => void;
|
|
40
|
+
}
|
|
41
|
+
/** Access the imperative toast API. Must be called under <ToastProvider>. */
|
|
42
|
+
export declare function useToast(): ToastContextValue;
|
|
43
|
+
/** @public */
|
|
44
|
+
export interface ToastProviderProps {
|
|
45
|
+
children?: React.ReactNode;
|
|
46
|
+
/** Default auto-dismiss in ms (Radix default is 5000). */
|
|
47
|
+
duration?: number;
|
|
48
|
+
/** Swipe-to-dismiss direction. */
|
|
49
|
+
swipeDirection?: React.ComponentProps<typeof ToastPrimitive.Provider>['swipeDirection'];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Provider + viewport for the toast system. Wrap the app root once.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare function ToastProvider({ children, duration, swipeDirection, }: ToastProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HdsToggle — boolean on/off toggle with animated thumb.
|
|
3
|
+
* @category Inputs
|
|
4
|
+
* @tier primitive
|
|
5
|
+
*/
|
|
6
|
+
import type { InputHTMLAttributes } from 'react';
|
|
7
|
+
/** HdsToggle — boolean on/off toggle with animated thumb. */
|
|
8
|
+
export type HdsToggleDemoState = 'rest' | 'hover' | 'focused' | 'pressed' | 'disabled';
|
|
9
|
+
interface ToggleProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'onChange'> {
|
|
10
|
+
/** Toggle label displayed next to the control. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Current checked state. */
|
|
13
|
+
checked: boolean;
|
|
14
|
+
/** Called when the toggle changes. */
|
|
15
|
+
onChange: (v: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const HdsToggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token - reflective token specimen for unified node-based token views.
|
|
3
|
+
* @category Display
|
|
4
|
+
* @tier primitive
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
type TokenBaseProps = {
|
|
8
|
+
className?: string;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
nowrap?: boolean;
|
|
11
|
+
isSourceNode?: boolean;
|
|
12
|
+
pathDisplayMode?: 'full' | 'compressed';
|
|
13
|
+
pathDisplayDepth?: number;
|
|
14
|
+
pathDisplayLeadingDot?: boolean;
|
|
15
|
+
nodeRef?: (el: HTMLElement | null) => void;
|
|
16
|
+
'aria-label'?: string;
|
|
17
|
+
/** When true, overflow ellipsis appears at the start (left) instead of the end. */
|
|
18
|
+
truncateFromStart?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type TokenNodeSurfaceProps = TokenBaseProps & {
|
|
21
|
+
variant?: 'node';
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
/** Optional explicit token path for deep-linking node instances. Falls back to children when omitted. */
|
|
24
|
+
tokenPath?: string;
|
|
25
|
+
isSelected?: boolean;
|
|
26
|
+
onClick?: () => void;
|
|
27
|
+
swatchVar?: string;
|
|
28
|
+
/** Optional left-side slot for compact node content, e.g. curve previews. */
|
|
29
|
+
leadingSlot?: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated `variant="diagram"` is a compatibility alias that resolves to the
|
|
33
|
+
* canonical `variant="node"` treatment; its diagram-only props (value,
|
|
34
|
+
* accentColor, description, rawValue) are no longer rendered. Migrate to
|
|
35
|
+
* `variant="node"`.
|
|
36
|
+
* @removeIn 1.0.0
|
|
37
|
+
*/
|
|
38
|
+
type TokenDiagramProps = TokenBaseProps & {
|
|
39
|
+
variant: 'diagram';
|
|
40
|
+
label: string;
|
|
41
|
+
value: string;
|
|
42
|
+
accentColor: string;
|
|
43
|
+
swatchVar?: string;
|
|
44
|
+
description?: React.ReactNode;
|
|
45
|
+
rawValue?: React.ReactNode;
|
|
46
|
+
onClick?: () => void;
|
|
47
|
+
};
|
|
48
|
+
type TokenProps = TokenNodeSurfaceProps | TokenDiagramProps;
|
|
49
|
+
/**
|
|
50
|
+
* Token - unified token component.
|
|
51
|
+
*
|
|
52
|
+
* variant="node" renders the canonical token surface.
|
|
53
|
+
* variant="diagram" is a DEPRECATED compatibility alias (see TokenDiagramProps;
|
|
54
|
+
* @removeIn 1.0.0) that now resolves to the same node treatment.
|
|
55
|
+
* Node content can use a left-side slot for swatches or other compact previews.
|
|
56
|
+
*/
|
|
57
|
+
/** @public */
|
|
58
|
+
export declare function Token(props: TokenProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @internal — utility-tier component; not part of @hirobius/design-system public API. */
|
|
2
|
+
/**
|
|
3
|
+
* @tier utility
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Tooltip — HDS image interaction tooltip
|
|
7
|
+
*
|
|
8
|
+
* A pill-shaped label (brand blue / white text) that indicates an image
|
|
9
|
+
* is expandable. Supports two render modes:
|
|
10
|
+
*
|
|
11
|
+
* 'cursor' — fixed-positioned portal tracking the mouse cursor.
|
|
12
|
+
* Appears offset from the cursor tip on hover.
|
|
13
|
+
* 'centered' — absolute overlay centered within the nearest positioned
|
|
14
|
+
* ancestor. Used for keyboard-focus state so keyboard
|
|
15
|
+
* users get an identical visual treatment.
|
|
16
|
+
*
|
|
17
|
+
* Rendered by AssetImg whenever `expandable` is true and an `onClick`
|
|
18
|
+
* handler is provided — no per-call configuration needed at the call site.
|
|
19
|
+
*/
|
|
20
|
+
interface TooltipProps {
|
|
21
|
+
/** Controls visibility and drives AnimatePresence enter/exit. */
|
|
22
|
+
visible: boolean;
|
|
23
|
+
/** Render strategy for cursor-following or centered placement. */
|
|
24
|
+
mode: 'cursor' | 'centered';
|
|
25
|
+
/** Pill label text. */
|
|
26
|
+
label?: string;
|
|
27
|
+
/** Cursor X position in client coordinates. */
|
|
28
|
+
x?: number;
|
|
29
|
+
/** Cursor Y position in client coordinates. */
|
|
30
|
+
y?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function Tooltip({ visible, mode, label, x, y }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DemoStateContext — React context for freezing HDS component demos into a fixed visual state.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the forceHover/forceFocus/forcePressed prop trio on Button and NavItem.
|
|
5
|
+
* Wrap any demo with <FreezeState state="hover"> and every HDS component inside will
|
|
6
|
+
* render that visual state without wiring individual force props.
|
|
7
|
+
*
|
|
8
|
+
* Components read via useFrozenState():
|
|
9
|
+
* frozenState ?? demoState prop → effectiveDemoState
|
|
10
|
+
*
|
|
11
|
+
* This means the matrix cells can still pass demoState as a prop and it will work,
|
|
12
|
+
* while FreezeState wrapping provides a cleaner compositional override.
|
|
13
|
+
*/
|
|
14
|
+
import { type ReactNode } from 'react';
|
|
15
|
+
/** Freeze all HDS demo components inside to the given visual state. */
|
|
16
|
+
export declare function FreezeState({ state, children }: {
|
|
17
|
+
state: string;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/** Read the nearest frozen demo state, or null if not inside a FreezeState. */
|
|
21
|
+
export declare function useFrozenState(): string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
type AppLanguage = 'en';
|
|
3
|
+
type AppDirection = 'ltr' | 'rtl';
|
|
4
|
+
interface LanguageOption {
|
|
5
|
+
language: AppLanguage;
|
|
6
|
+
dir: AppDirection;
|
|
7
|
+
label: string;
|
|
8
|
+
nativeLabel: string;
|
|
9
|
+
}
|
|
10
|
+
interface LanguageContextValue {
|
|
11
|
+
language: AppLanguage;
|
|
12
|
+
direction: AppDirection;
|
|
13
|
+
isRtl: boolean;
|
|
14
|
+
setLanguage: (language: AppLanguage) => void;
|
|
15
|
+
setDirection: (direction: AppDirection) => void;
|
|
16
|
+
toggleDirection: () => void;
|
|
17
|
+
options: Record<AppLanguage, LanguageOption>;
|
|
18
|
+
}
|
|
19
|
+
export declare function LanguageProvider({ children }: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function useLanguage(): LanguageContextValue;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RouterContext — router-adapter seam for @hirobius/design-system.
|
|
3
|
+
*
|
|
4
|
+
* HDS components never import a router. Navigation is sourced from an injected
|
|
5
|
+
* adapter so the library works in three modes:
|
|
6
|
+
*
|
|
7
|
+
* 1. Zero-router (default) — no provider; links are plain <a> and navigate
|
|
8
|
+
* falls back to window.location. Drop-in for apps with no router
|
|
9
|
+
* (e.g. job-hunt, a plain Vite/React app).
|
|
10
|
+
* 2. react-router consumers — wrap the app once in <HdsRouterProvider> with an
|
|
11
|
+
* adapter that bridges useNavigate()/useLocation()/<Link>. The docs site
|
|
12
|
+
* does this internally via ReactRouterBridge (NOT exported).
|
|
13
|
+
* 3. Next.js / other routers — same seam: provide an adapter mapping to that
|
|
14
|
+
* router's navigation + Link.
|
|
15
|
+
*
|
|
16
|
+
* IMPORTANT: this module MUST NOT import react-router (or any router). It is the
|
|
17
|
+
* router-free contract every consumer can satisfy.
|
|
18
|
+
*
|
|
19
|
+
* @doc-ignore — provider/hook seam (like ThemeProvider et al.), not a visual
|
|
20
|
+
* component; it carries no Figma specimen or docs page, so manifest discovery
|
|
21
|
+
* must skip it despite the Hds* name prefix.
|
|
22
|
+
*/
|
|
23
|
+
import { type AnchorHTMLAttributes, type ReactNode } from 'react';
|
|
24
|
+
/** Options forwarded to a router's navigate call (state preserved for SPA nav). */
|
|
25
|
+
export interface HdsNavigateOptions {
|
|
26
|
+
/** Replace the current history entry instead of pushing a new one. */
|
|
27
|
+
replace?: boolean;
|
|
28
|
+
/** Opaque router state (e.g. scroll restoration hints). Ignored by the anchor default. */
|
|
29
|
+
state?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** Props for the injectable link component. Mirrors react-router's `<Link to>`. */
|
|
32
|
+
export interface HdsLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
33
|
+
/** Destination route or URL. */
|
|
34
|
+
to: string;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/** A link component the host app supplies (or the anchor default below). */
|
|
38
|
+
export type HdsLinkComponent = React.ComponentType<HdsLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
39
|
+
/** The navigation surface HDS components consume. */
|
|
40
|
+
export interface HdsRouterAdapter {
|
|
41
|
+
/** Navigate to an href. The anchor default uses window.location.assign. */
|
|
42
|
+
navigate: (href: string, options?: HdsNavigateOptions) => void;
|
|
43
|
+
/** Current path (e.g. "/color"). Used for active-route detection. */
|
|
44
|
+
currentPath: string;
|
|
45
|
+
/** Link component for client-side nav. Defaults to a plain anchor. */
|
|
46
|
+
LinkComponent: HdsLinkComponent;
|
|
47
|
+
}
|
|
48
|
+
export interface HdsRouterProviderProps {
|
|
49
|
+
adapter: HdsRouterAdapter;
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Provide a router adapter to all HDS components below. Wrap your app root once.
|
|
54
|
+
*/
|
|
55
|
+
export declare function HdsRouterProvider({ adapter, children }: HdsRouterProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* Read the active router adapter. With no provider, returns a router-free
|
|
58
|
+
* fallback: navigate → window.location.assign (SSR-guarded), currentPath read
|
|
59
|
+
* fresh from window.location, LinkComponent → the anchor default.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useHdsRouter(): HdsRouterAdapter;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type TenantSlug = 'hirobius' | 'concrete-creations' | (string & {});
|
|
3
|
+
interface TenantCtx {
|
|
4
|
+
/** Active tenant slug, or null in single-tenant mode. */
|
|
5
|
+
tenantSlug: TenantSlug | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* TenantProvider
|
|
9
|
+
*
|
|
10
|
+
* Reads VITE_TENANT_SLUG from the Vite environment and, if set, writes
|
|
11
|
+
* `data-tenant="<slug>"` onto `<html>` so CSS tenant-scope selectors
|
|
12
|
+
* (e.g. `[data-tenant="acme"] .hds-button`) resolve correctly at runtime.
|
|
13
|
+
*
|
|
14
|
+
* Single-tenant deployments that never set VITE_TENANT_SLUG are unaffected:
|
|
15
|
+
* no attribute is written and no context value is populated.
|
|
16
|
+
*/
|
|
17
|
+
export declare function TenantProvider({ children }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/** Returns the active tenant slug (null in single-tenant mode). */
|
|
21
|
+
export declare function useTenant(): TenantCtx;
|
|
22
|
+
/**
|
|
23
|
+
* useTenantOnDocument
|
|
24
|
+
*
|
|
25
|
+
* Imperatively applies `data-tenant` to `<html>` — useful when the
|
|
26
|
+
* provider wraps only part of the tree but you need document-wide scope.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useTenantOnDocument(slug: TenantSlug): void;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
type Density = 'comfortable' | 'compact';
|
|
3
|
+
/** Three-way mode: follow OS, force light, or force dark. */
|
|
4
|
+
export type ThemeMode = 'system' | 'light' | 'dark';
|
|
5
|
+
interface ThemeCtx {
|
|
6
|
+
isDark: boolean;
|
|
7
|
+
toggleDark: () => void;
|
|
8
|
+
mode: ThemeMode;
|
|
9
|
+
setMode: (m: ThemeMode) => void;
|
|
10
|
+
density: Density;
|
|
11
|
+
toggleDensity: () => void;
|
|
12
|
+
setDensity: (d: Density) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function ThemeProvider({ children }: {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function useTheme(): ThemeCtx;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface TokenDisplayContextType {
|
|
3
|
+
showCss: boolean;
|
|
4
|
+
setShowCss: (val: boolean) => void;
|
|
5
|
+
toggleCss: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function TokenDisplayProvider({ children }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function useTokenDisplay(): TokenDisplayContextType;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hirobius/design-system/contexts
|
|
3
|
+
*
|
|
4
|
+
* App-shell providers + hooks shared by the design-system site and any
|
|
5
|
+
* consuming app (e.g. the ops dashboard). These wrap the document with the
|
|
6
|
+
* theme/density, reading-direction, tenant, and font state the tokens and
|
|
7
|
+
* components rely on. Wrap your app root in:
|
|
8
|
+
*
|
|
9
|
+
* <TenantProvider><LanguageProvider><ThemeProvider><FontProvider>
|
|
10
|
+
* {app}
|
|
11
|
+
* </FontProvider></ThemeProvider></LanguageProvider></TenantProvider>
|
|
12
|
+
*/
|
|
13
|
+
export * from './ThemeContext';
|
|
14
|
+
export * from './LanguageContext';
|
|
15
|
+
export * from './TenantContext';
|
|
16
|
+
export * from './FontContext';
|
|
17
|
+
export * from './DemoStateContext';
|
|
18
|
+
export * from './TokenDisplayContext';
|
|
19
|
+
export * from './RouterContext';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* manifest-types.ts — canonical TypeScript types for the HDS manifest contracts.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for:
|
|
5
|
+
* - SystemManifest / ManifestComponentSpec (virtual:hds-manifest)
|
|
6
|
+
* - ComponentApiManifest / ManifestApiComponent (component-api.json)
|
|
7
|
+
* - Supporting building-block types
|
|
8
|
+
*
|
|
9
|
+
* All fields are OPTIONAL (broad superset) — the generated manifest JSON is
|
|
10
|
+
* the runtime source of truth; consumers that need a field to be required
|
|
11
|
+
* should derive a local narrowed type via intersection, e.g.:
|
|
12
|
+
*
|
|
13
|
+
* type DocSpec = ManifestComponentSpec & { category: string; figmaUrl: string | null };
|
|
14
|
+
*
|
|
15
|
+
* IMPORTANT: `props` means two different things across the two manifests:
|
|
16
|
+
* - ManifestComponentSpec.props → Record<string, ManifestPropSpec> (shape metadata)
|
|
17
|
+
* - ManifestApiComponent.props → ManifestApiPropRow[] (documentation rows)
|
|
18
|
+
* Keep them as DISTINCT types — do not merge.
|
|
19
|
+
*/
|
|
20
|
+
/** Shape metadata for a single prop as stored in componentSpecs[name].props. */
|
|
21
|
+
export type ManifestPropSpec = {
|
|
22
|
+
type?: string;
|
|
23
|
+
values?: Array<string | number | boolean>;
|
|
24
|
+
default?: string | number | boolean;
|
|
25
|
+
optional?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** A named slot declared on a component spec. */
|
|
28
|
+
export type ManifestSlot = {
|
|
29
|
+
name?: string;
|
|
30
|
+
figmaSlotName?: string;
|
|
31
|
+
tokenBinding?: Record<string, string>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A documentation row for a single prop as stored in
|
|
35
|
+
* ComponentApiManifest.components[name].props (array, not Record).
|
|
36
|
+
*/
|
|
37
|
+
export type ManifestApiPropRow = {
|
|
38
|
+
name: string;
|
|
39
|
+
type?: string;
|
|
40
|
+
default?: string;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
description?: string;
|
|
43
|
+
};
|
|
44
|
+
/** A role token entry from manifest.tokens.role. */
|
|
45
|
+
export type RoleToken = {
|
|
46
|
+
path?: string;
|
|
47
|
+
cssVar?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
alias?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A single entry in SystemManifest.componentSpecs (or .utilities).
|
|
53
|
+
* Superset of every field any consumer declares — all fields are optional.
|
|
54
|
+
*/
|
|
55
|
+
export type ManifestComponentSpec = {
|
|
56
|
+
category?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
figmaUrl?: string | null;
|
|
59
|
+
figmaId?: string | null;
|
|
60
|
+
figmaLink?: string | null;
|
|
61
|
+
filePath?: string;
|
|
62
|
+
hidden?: boolean;
|
|
63
|
+
docExempt?: boolean;
|
|
64
|
+
tier?: string;
|
|
65
|
+
stability?: 'stable' | 'beta';
|
|
66
|
+
consumers?: string[];
|
|
67
|
+
tokenMapping?: Record<string, string>;
|
|
68
|
+
preview?: {
|
|
69
|
+
exportName?: string;
|
|
70
|
+
sizing?: 'compact' | 'panel' | 'full';
|
|
71
|
+
};
|
|
72
|
+
/** Shape metadata keyed by prop name. Distinct from API manifest prop rows. */
|
|
73
|
+
props?: Record<string, ManifestPropSpec>;
|
|
74
|
+
propConstraints?: Record<string, ManifestPropSpec | Record<string, unknown>>;
|
|
75
|
+
requiredProps?: string[];
|
|
76
|
+
slots?: ManifestSlot[];
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Alias of ManifestComponentSpec for hds-search.ts back-compat.
|
|
80
|
+
* @deprecated Use ManifestComponentSpec directly in new code.
|
|
81
|
+
*/
|
|
82
|
+
export type ManifestSpec = ManifestComponentSpec;
|
|
83
|
+
/** The root SystemManifest shape (virtual:hds-manifest). */
|
|
84
|
+
export type SystemManifest = {
|
|
85
|
+
name?: string;
|
|
86
|
+
version?: string;
|
|
87
|
+
systemSpecs?: {
|
|
88
|
+
engine?: string;
|
|
89
|
+
icons?: string;
|
|
90
|
+
tokens?: string;
|
|
91
|
+
styling?: string;
|
|
92
|
+
[key: string]: string | undefined;
|
|
93
|
+
};
|
|
94
|
+
componentInventory?: string[];
|
|
95
|
+
componentSpecs?: Record<string, ManifestComponentSpec>;
|
|
96
|
+
utilities?: Record<string, ManifestComponentSpec>;
|
|
97
|
+
tokens?: {
|
|
98
|
+
role?: Record<string, RoleToken> | RoleToken[];
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* A single entry in ComponentApiManifest.components.
|
|
104
|
+
* Uses ManifestApiPropRow[] (array) — distinct from ManifestComponentSpec.props (Record).
|
|
105
|
+
*/
|
|
106
|
+
export type ManifestApiComponent = {
|
|
107
|
+
filePath?: string;
|
|
108
|
+
category?: string;
|
|
109
|
+
hidden?: boolean;
|
|
110
|
+
figmaUrl?: string | null;
|
|
111
|
+
description?: string;
|
|
112
|
+
/** Documentation prop rows — array, not a Record. */
|
|
113
|
+
props?: ManifestApiPropRow[];
|
|
114
|
+
guides?: Array<{
|
|
115
|
+
label: string;
|
|
116
|
+
text: string;
|
|
117
|
+
}>;
|
|
118
|
+
observedTokens?: Array<{
|
|
119
|
+
raw: string;
|
|
120
|
+
tokenPath?: string;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
/** The root ComponentApiManifest shape (component-api.json). */
|
|
124
|
+
export type ComponentApiManifest = {
|
|
125
|
+
generatedAt?: string;
|
|
126
|
+
source?: string;
|
|
127
|
+
components?: Record<string, ManifestApiComponent>;
|
|
128
|
+
};
|