@wirecore/wirelayer-blocks-react 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +24 -2
- package/dist/AuthForm/AuthForm.d.ts +45 -0
- package/dist/AuthForm/AuthForm.d.ts.map +1 -0
- package/dist/AuthLayout/AuthLayout.d.ts +19 -0
- package/dist/AuthLayout/AuthLayout.d.ts.map +1 -0
- package/dist/ConditionBuilder/ConditionBuilder.d.ts +25 -0
- package/dist/ConditionBuilder/ConditionBuilder.d.ts.map +1 -0
- package/dist/CtaSection/CtaSection.d.ts +15 -0
- package/dist/CtaSection/CtaSection.d.ts.map +1 -0
- package/dist/ModeToggle/ModeToggle.d.ts +13 -0
- package/dist/ModeToggle/ModeToggle.d.ts.map +1 -0
- package/dist/SiteHeader/SiteHeader.d.ts +28 -0
- package/dist/SiteHeader/SiteHeader.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +604 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +51 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WireCore GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
<img src="https://raw.githubusercontent.com/WireCore/WireLayer/main/assets/wirelayer.svg" alt="" width="56" height="56" />
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @wirecore/wirelayer-blocks-react
|
|
4
|
+
|
|
5
|
+
Page blocks for React built on `@wirecore/wirelayer-react`: SiteHeader, CtaSection, ModeToggle, AuthForm, AuthLayout and the ConditionBuilder (nested AND/OR rules, also the editor of the DataTable's advanced filter).
|
|
6
|
+
|
|
7
|
+
[Storybook](https://wirecore.github.io/WireLayer/) · [GitHub](https://github.com/WireCore/WireLayer) · [Changelog](./CHANGELOG.md)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @wirecore/wirelayer-blocks-react @wirecore/wirelayer-react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { ConditionBuilder } from '@wirecore/wirelayer-blocks-react';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Part of [WireLayer](https://github.com/WireCore/WireLayer) – one look and one API for Vue, React, React Native and HTML, accessible according to WCAG 2.2 AA.
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
[MIT](./LICENSE) – Copyright (c) 2026 WireCore GmbH
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { authForm as authFormRecipe, type AuthField, type AuthMode, type AuthValues, type RecipeClasses } from '@wirecore/wirelayer-recipes';
|
|
2
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
3
|
+
export interface AuthFormProps extends Omit<ComponentProps<'div'>, 'children' | 'title' | 'onSubmit'> {
|
|
4
|
+
/** signIn, signUp, reset (password forgotten) or code (one-time code) (controlled) */
|
|
5
|
+
mode?: AuthMode;
|
|
6
|
+
defaultMode?: AuthMode;
|
|
7
|
+
onModeChange?: (mode: AuthMode) => void;
|
|
8
|
+
/** Modes the links switch between (default sign in, sign up and reset) */
|
|
9
|
+
modes?: AuthMode[];
|
|
10
|
+
/** Heading (default by mode) */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Text below the heading (default by mode) */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Heading level that fits the page (default h1) */
|
|
15
|
+
titleTag?: 'h1' | 'h2' | 'h3';
|
|
16
|
+
/** "Keep me signed in" when signing in (default true) */
|
|
17
|
+
remember?: boolean;
|
|
18
|
+
/** Minimum length of a new password (default 8) */
|
|
19
|
+
passwordMinLength?: number;
|
|
20
|
+
/** Digits of the one-time code (default 6) */
|
|
21
|
+
codeLength?: number;
|
|
22
|
+
/** Own checks per field, e.g. the validators of @wirecore/wirelayer-react/form – after the built-in ones */
|
|
23
|
+
validators?: Partial<Record<AuthField, (value: string) => string | undefined>>;
|
|
24
|
+
/** An error of the server (wrong password …), shown in the summary */
|
|
25
|
+
error?: string;
|
|
26
|
+
/** Submitting: the button shows a spinner */
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
/** Reset: the link was sent (a status message replaces the form) */
|
|
29
|
+
sent?: boolean;
|
|
30
|
+
/** Start values, e.g. a known e-mail address */
|
|
31
|
+
defaultValues?: Partial<AuthValues>;
|
|
32
|
+
/** The fields are valid: the mode and the values (handle the request, then set `error` or move on) */
|
|
33
|
+
onSubmit?: (payload: {
|
|
34
|
+
mode: AuthMode;
|
|
35
|
+
} & AuthValues) => void;
|
|
36
|
+
/** Buttons of sign-in providers (neutral buttons with text, no brand logos) */
|
|
37
|
+
providers?: ReactNode;
|
|
38
|
+
/** Below the form, e.g. terms or a help link */
|
|
39
|
+
footer?: ReactNode;
|
|
40
|
+
/** Extra classes per part of the component, e.g. { base: "…" } (see the recipe) */
|
|
41
|
+
classes?: RecipeClasses<typeof authFormRecipe>;
|
|
42
|
+
}
|
|
43
|
+
/** One form for sign in, sign up, password reset and one-time code; errors in a summary that takes the focus */
|
|
44
|
+
export declare function AuthForm({ mode, defaultMode, onModeChange, modes, title, description, titleTag: Title, remember, passwordMinLength, codeLength, validators, error, loading, sent, defaultValues, onSubmit, providers, footer, classes, className, ...props }: AuthFormProps): import("react").JSX.Element;
|
|
45
|
+
//# sourceMappingURL=AuthForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthForm.d.ts","sourceRoot":"","sources":["../../src/AuthForm/AuthForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,cAAc,EAE1B,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,aAAa,EACrB,MAAM,6BAA6B,CAAC;AAYrC,OAAO,EAAsC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhG,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;IACjG,sFAAsF;IACtF,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4GAA4G;IAC5G,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/E,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gDAAgD;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,sGAAsG;IACtG,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,GAAG,UAAU,KAAK,IAAI,CAAC;IAC9D,+EAA+E;IAC/E,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gDAAgD;IAChD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,mFAAmF;IACnF,OAAO,CAAC,EAAE,aAAa,CAAC,OAAO,cAAc,CAAC,CAAC;CAClD;AAED,gHAAgH;AAChH,wBAAgB,QAAQ,CAAC,EACrB,IAAI,EACJ,WAAsB,EACtB,YAAY,EACZ,KAAqC,EACrC,KAAK,EACL,WAAW,EACX,QAAQ,EAAE,KAAY,EACtB,QAAe,EACf,iBAAqB,EACrB,UAAc,EACd,UAAU,EACV,KAAK,EACL,OAAO,EACP,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,SAAS,EACT,GAAG,KAAK,EACX,EAAE,aAAa,+BA8Kf"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { authLayout as authLayoutRecipe, type RecipeClasses } from '@wirecore/wirelayer-recipes';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
export interface AuthLayoutProps extends ComponentProps<'div'> {
|
|
4
|
+
/** Decorative image on the other side (hidden on small screens) */
|
|
5
|
+
image?: string;
|
|
6
|
+
/** Form on the start (default) or end side */
|
|
7
|
+
side?: 'start' | 'end';
|
|
8
|
+
/** Logo or product name above the form */
|
|
9
|
+
brand?: ReactNode;
|
|
10
|
+
/** Text over the image: quote, product promise … */
|
|
11
|
+
teaser?: ReactNode;
|
|
12
|
+
/** Below the form: imprint, privacy */
|
|
13
|
+
footer?: ReactNode;
|
|
14
|
+
/** Extra classes per part of the component, e.g. { base: "…" } (see the recipe) */
|
|
15
|
+
classes?: RecipeClasses<typeof authLayoutRecipe>;
|
|
16
|
+
}
|
|
17
|
+
/** Two columns: the form in <main>, the image with a teaser as a complementary area (stacked on small screens) */
|
|
18
|
+
export declare function AuthLayout({ image, side, brand, teaser, footer, classes, className, children, ...props }: AuthLayoutProps): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=AuthLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthLayout.d.ts","sourceRoot":"","sources":["../../src/AuthLayout/AuthLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjG,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC1D,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACvB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,uCAAuC;IACvC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,mFAAmF;IACnF,OAAO,CAAC,EAAE,aAAa,CAAC,OAAO,gBAAgB,CAAC,CAAC;CACpD;AAED,kHAAkH;AAClH,wBAAgB,UAAU,CAAC,EACvB,KAAK,EACL,IAAc,EACd,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,eAAe,+BAuBjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { conditionBuilder as conditionBuilderRecipe, type ConditionField, type ConditionGroup, type RecipeClasses } from '@wirecore/wirelayer-recipes';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
|
+
export interface ConditionBuilderProps extends Omit<ComponentProps<'div'>, 'defaultValue'> {
|
|
4
|
+
/** Fields the rules can test: id, label, type (text, number, date, select, boolean), options of a select */
|
|
5
|
+
fields: ConditionField[];
|
|
6
|
+
/** The condition tree (JSON: groups with combinator and children, rules with field, operator, value) – controlled */
|
|
7
|
+
value?: ConditionGroup;
|
|
8
|
+
defaultValue?: ConditionGroup;
|
|
9
|
+
onValueChange?: (value: ConditionGroup) => void;
|
|
10
|
+
/** Name of the whole tree (default "Conditions") */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** How deep groups can be nested (default 3) */
|
|
13
|
+
maxDepth?: number;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** A "Not" checkbox per group negates it (`not` in the JSON); groups that are negated already always show it */
|
|
16
|
+
negatable?: boolean;
|
|
17
|
+
/** Extra classes per part of the component, e.g. { base: "…" } (see the recipe) */
|
|
18
|
+
classes?: RecipeClasses<typeof conditionBuilderRecipe>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Nested and/or groups of rules: field, operator and a value editor matching the field type. Every control is a native
|
|
22
|
+
* or WireLayer form control (Tab, arrow keys); adding focuses the new rule, removing the group's add button.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ConditionBuilder({ classes, fields, value, defaultValue, onValueChange, label, maxDepth, disabled, negatable, className, ...props }: ConditionBuilderProps): import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=ConditionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../src/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,gBAAgB,IAAI,sBAAsB,EAU1C,KAAK,cAAc,EACnB,KAAK,cAAc,EAInB,KAAK,aAAa,EACrB,MAAM,6BAA6B,CAAC;AAcrC,OAAO,EAA0D,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AA2SpG,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IACtF,4GAA4G;IAC5G,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,qHAAqH;IACrH,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAChD,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gHAAgH;IAChH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mFAAmF;IACnF,OAAO,CAAC,EAAE,aAAa,CAAC,OAAO,sBAAsB,CAAC,CAAC;CAC1D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC7B,OAAO,EACP,MAAM,EACN,KAAK,EACL,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAY,EACZ,QAAgB,EAChB,SAAiB,EACjB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,qBAAqB,+BA+CvB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ctaSection as ctaSectionRecipe, type RecipeClasses } from '@wirecore/wirelayer-recipes';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
|
+
export interface CtaSectionProps extends Omit<ComponentProps<'section'>, 'title'> {
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
/** Decorative background image (e.g. the logo), shown faintly on the right */
|
|
7
|
+
image?: string;
|
|
8
|
+
/** Heading level that fits the page outline */
|
|
9
|
+
titleTag?: 'h2' | 'h3' | 'h4';
|
|
10
|
+
/** Extra classes per part of the component, e.g. { base: "…" } (see the recipe) */
|
|
11
|
+
classes?: RecipeClasses<typeof ctaSectionRecipe>;
|
|
12
|
+
}
|
|
13
|
+
/** A named region: the title labels it. Children are the actions. */
|
|
14
|
+
export declare function CtaSection({ classes, title, description, image, titleTag: Title, className, children, ...props }: CtaSectionProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=CtaSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CtaSection.d.ts","sourceRoot":"","sources":["../../src/CtaSection/CtaSection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAS,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAGnD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9B,mFAAmF;IACnF,OAAO,CAAC,EAAE,aAAa,CAAC,OAAO,gBAAgB,CAAC,CAAC;CACpD;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,EACvB,OAAO,EACP,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EAAE,KAAY,EACtB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,eAAe,+BAejB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type IconButtonVariant, type Size } from '@wirecore/wirelayer-recipes';
|
|
2
|
+
export interface ModeToggleProps {
|
|
3
|
+
/** localStorage key for the choice */
|
|
4
|
+
storageKey?: string;
|
|
5
|
+
/** Accessible name while dark is active */
|
|
6
|
+
lightLabel?: string;
|
|
7
|
+
/** Accessible name while light is active */
|
|
8
|
+
darkLabel?: string;
|
|
9
|
+
variant?: IconButtonVariant;
|
|
10
|
+
size?: Size;
|
|
11
|
+
}
|
|
12
|
+
export declare function ModeToggle({ storageKey, lightLabel, darkLabel, variant, size, }: ModeToggleProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=ModeToggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModeToggle.d.ts","sourceRoot":"","sources":["../../src/ModeToggle/ModeToggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACZ,MAAM,6BAA6B,CAAC;AAKrC,MAAM,WAAW,eAAe;IAC5B,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAC;CACf;AAWD,wBAAgB,UAAU,CAAC,EACvB,UAA4B,EAC5B,UAAU,EACV,SAAS,EACT,OAAgB,EAChB,IAAI,GACP,EAAE,eAAe,+BAsBjB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { siteHeader as siteHeaderRecipe, type RecipeClasses } from '@wirecore/wirelayer-recipes';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { NavItem } from '../types.js';
|
|
4
|
+
export interface NavLinkAttributes {
|
|
5
|
+
className: string;
|
|
6
|
+
'aria-current'?: 'page';
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface SiteHeaderProps {
|
|
10
|
+
/** Name next to the logo, links to the home page */
|
|
11
|
+
brand: string;
|
|
12
|
+
homeHref?: string;
|
|
13
|
+
items?: NavItem[];
|
|
14
|
+
/** Logo before the brand name (decorative – the name is the link text) */
|
|
15
|
+
logo?: ReactNode;
|
|
16
|
+
/** Actions on the right, e.g. a CTA button and the ModeToggle – repeated in the mobile menu */
|
|
17
|
+
actions?: ReactNode;
|
|
18
|
+
/** Accessible name of the navigation landmark */
|
|
19
|
+
navLabel?: string;
|
|
20
|
+
/** Accessible name of the mobile menu button */
|
|
21
|
+
menuLabel?: string;
|
|
22
|
+
/** Custom link, e.g. Next.js Link: spread `attributes` onto it */
|
|
23
|
+
renderLink?: (item: NavItem, attributes: NavLinkAttributes) => ReactNode;
|
|
24
|
+
/** Extra classes per part of the component, e.g. { base: "…" } (see the recipe) */
|
|
25
|
+
classes?: RecipeClasses<typeof siteHeaderRecipe>;
|
|
26
|
+
}
|
|
27
|
+
export declare function SiteHeader({ classes, brand, homeHref, items, logo, actions, navLabel: navLabelProp, menuLabel: menuLabelProp, renderLink, }: SiteHeaderProps): import("react").JSX.Element;
|
|
28
|
+
//# sourceMappingURL=SiteHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteHeader.d.ts","sourceRoot":"","sources":["../../src/SiteHeader/SiteHeader.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjG,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC5B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+FAA+F;IAC/F,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,KAAK,SAAS,CAAC;IACzE,mFAAmF;IACnF,OAAO,CAAC,EAAE,aAAa,CAAC,OAAO,gBAAgB,CAAC,CAAC;CACpD;AAQD,wBAAgB,UAAU,CAAC,EACvB,OAAO,EACP,KAAK,EACL,QAAc,EACd,KAAU,EACV,IAAI,EACJ,OAAO,EACP,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,aAAa,EACxB,UAA8B,GACjC,EAAE,eAAe,+BAuDjB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { CtaSection, type CtaSectionProps } from './CtaSection/CtaSection.js';
|
|
2
|
+
export { ModeToggle, type ModeToggleProps } from './ModeToggle/ModeToggle.js';
|
|
3
|
+
export { SiteHeader, type NavLinkAttributes, type SiteHeaderProps } from './SiteHeader/SiteHeader.js';
|
|
4
|
+
export type { NavItem } from './types.js';
|
|
5
|
+
export { AuthForm, type AuthFormProps } from './AuthForm/AuthForm.js';
|
|
6
|
+
export { AuthLayout, type AuthLayoutProps } from './AuthLayout/AuthLayout.js';
|
|
7
|
+
export type { AuthField, AuthMode, AuthValues } from '@wirecore/wirelayer-recipes';
|
|
8
|
+
export { ConditionBuilder, type ConditionBuilderProps } from './ConditionBuilder/ConditionBuilder.js';
|
|
9
|
+
export type { ConditionField, ConditionFieldType, ConditionGroup, ConditionNode, ConditionOperator, ConditionRule, } from '@wirecore/wirelayer-recipes';
|
|
10
|
+
export { emptyConditionGroup, matchesCondition } from '@wirecore/wirelayer-recipes';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACtG,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACtG,YAAY,EACR,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,aAAa,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { addConditionNode as e, announce as t, authForm as n, authLayout as r, conditionBuilder as i, ctaSection as a, emptyConditionGroup as o, emptyConditionGroup as s, getPreferredMode as c, isValuelessOperator as l, matchesCondition as u, negateConditionGroup as d, newConditionRule as f, operatorsFor as p, removeConditionNode as m, setConditionField as h, setConditionOperator as g, setMode as _, siteHeader as v, updateConditionNode as ee, validateAuth as y } from "@wirecore/wirelayer-recipes";
|
|
3
|
+
import { createContext as b, useContext as x, useEffect as S, useId as C, useRef as w, useState as T, useSyncExternalStore as E } from "react";
|
|
4
|
+
import { Button as D, Checkbox as O, DatePicker as k, Field as A, FormErrorSummary as te, IconButton as j, Input as M, MultiSelect as N, NativeSelect as P, NumberInput as F, PasswordInput as ne, PinInput as re, useLocale as ie, useRecipe as I, useTranslations as L } from "@wirecore/wirelayer-react";
|
|
5
|
+
import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
|
|
6
|
+
import { Menu as V, Moon as H, Plus as U, Sun as ae, Trash2 as W, X as G } from "lucide-react";
|
|
7
|
+
import { Collapsible as K } from "@ark-ui/react/collapsible";
|
|
8
|
+
//#region src/CtaSection/CtaSection.tsx
|
|
9
|
+
function q({ classes: e, title: t, description: n, image: r, titleTag: i = "h2", className: o, children: s, ...c }) {
|
|
10
|
+
let l = I("ctaSection", a, e)(), u = C();
|
|
11
|
+
return /* @__PURE__ */ B("section", {
|
|
12
|
+
...c,
|
|
13
|
+
className: l.base({ class: o }),
|
|
14
|
+
"aria-labelledby": u,
|
|
15
|
+
children: [
|
|
16
|
+
r && /* @__PURE__ */ z("img", {
|
|
17
|
+
src: r,
|
|
18
|
+
alt: "",
|
|
19
|
+
className: l.image()
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ z(i, {
|
|
22
|
+
id: u,
|
|
23
|
+
className: l.title(),
|
|
24
|
+
children: t
|
|
25
|
+
}),
|
|
26
|
+
n && /* @__PURE__ */ z("p", {
|
|
27
|
+
className: l.description(),
|
|
28
|
+
children: n
|
|
29
|
+
}),
|
|
30
|
+
s && /* @__PURE__ */ z("div", {
|
|
31
|
+
className: l.actions(),
|
|
32
|
+
children: s
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/ModeToggle/ModeToggle.tsx
|
|
39
|
+
var J = (e) => {
|
|
40
|
+
let t = new MutationObserver(e);
|
|
41
|
+
return t.observe(document.documentElement, {
|
|
42
|
+
attributes: !0,
|
|
43
|
+
attributeFilter: ["data-mode"]
|
|
44
|
+
}), () => t.disconnect();
|
|
45
|
+
}, Y = () => document.documentElement.dataset.mode === "dark" ? "dark" : "light", X = () => "light";
|
|
46
|
+
function Z({ storageKey: e = "wirecore-mode", lightLabel: t, darkLabel: n, variant: r = "text", size: i }) {
|
|
47
|
+
let a = L(), o = E(J, Y, X);
|
|
48
|
+
return S(() => {
|
|
49
|
+
document.documentElement.dataset.mode || _(c(e), e);
|
|
50
|
+
}, [e]), /* @__PURE__ */ z(j, {
|
|
51
|
+
icon: o === "dark" ? ae : H,
|
|
52
|
+
label: o === "dark" ? t ?? a.modeToggle.light : n ?? a.modeToggle.dark,
|
|
53
|
+
variant: r,
|
|
54
|
+
size: i,
|
|
55
|
+
onClick: () => _(o === "dark" ? "light" : "dark", e)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/SiteHeader/SiteHeader.tsx
|
|
60
|
+
var oe = (e, t) => /* @__PURE__ */ z("a", {
|
|
61
|
+
href: e.href,
|
|
62
|
+
...t,
|
|
63
|
+
children: e.label
|
|
64
|
+
}, e.href);
|
|
65
|
+
function Q({ classes: e, brand: t, homeHref: n = "/", items: r = [], logo: i, actions: a, navLabel: o, menuLabel: s, renderLink: c = oe }) {
|
|
66
|
+
let l = I("siteHeader", v, e)(), u = L(), d = o ?? u.siteHeader.navigation, f = s ?? u.siteHeader.menu, [p, m] = T(!1), h = (e, t) => ({
|
|
67
|
+
className: t ? l.panelLink() : l.link(),
|
|
68
|
+
"aria-current": e.current ? "page" : void 0,
|
|
69
|
+
onClick: t ? () => m(!1) : void 0
|
|
70
|
+
});
|
|
71
|
+
return /* @__PURE__ */ z(K.Root, {
|
|
72
|
+
open: p,
|
|
73
|
+
onOpenChange: (e) => m(e.open),
|
|
74
|
+
asChild: !0,
|
|
75
|
+
lazyMount: !0,
|
|
76
|
+
unmountOnExit: !0,
|
|
77
|
+
children: /* @__PURE__ */ B("header", {
|
|
78
|
+
className: l.base(),
|
|
79
|
+
children: [/* @__PURE__ */ B("div", {
|
|
80
|
+
className: l.bar(),
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ B("a", {
|
|
83
|
+
href: n,
|
|
84
|
+
className: l.brand(),
|
|
85
|
+
children: [i && /* @__PURE__ */ z("span", {
|
|
86
|
+
className: l.logo(),
|
|
87
|
+
"aria-hidden": "true",
|
|
88
|
+
children: i
|
|
89
|
+
}), t]
|
|
90
|
+
}),
|
|
91
|
+
r.length > 0 && /* @__PURE__ */ z("nav", {
|
|
92
|
+
"aria-label": d,
|
|
93
|
+
className: l.nav(),
|
|
94
|
+
children: r.map((e) => c(e, h(e, !1)))
|
|
95
|
+
}),
|
|
96
|
+
a && /* @__PURE__ */ z("div", {
|
|
97
|
+
className: l.actions(),
|
|
98
|
+
children: a
|
|
99
|
+
}),
|
|
100
|
+
(r.length > 0 || a) && /* @__PURE__ */ z(K.Trigger, {
|
|
101
|
+
asChild: !0,
|
|
102
|
+
children: /* @__PURE__ */ z(j, {
|
|
103
|
+
icon: p ? G : V,
|
|
104
|
+
label: f,
|
|
105
|
+
variant: "text",
|
|
106
|
+
className: l.toggle()
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
}), /* @__PURE__ */ B(K.Content, {
|
|
111
|
+
className: l.panel(),
|
|
112
|
+
children: [r.length > 0 && /* @__PURE__ */ z("nav", {
|
|
113
|
+
"aria-label": d,
|
|
114
|
+
className: l.panelNav(),
|
|
115
|
+
children: r.map((e) => c(e, h(e, !0)))
|
|
116
|
+
}), a && /* @__PURE__ */ z("div", {
|
|
117
|
+
className: l.panelActions(),
|
|
118
|
+
children: a
|
|
119
|
+
})]
|
|
120
|
+
})]
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/AuthForm/AuthForm.tsx
|
|
126
|
+
function $({ mode: e, defaultMode: t = "signIn", onModeChange: r, modes: i = [
|
|
127
|
+
"signIn",
|
|
128
|
+
"signUp",
|
|
129
|
+
"reset"
|
|
130
|
+
], title: a, description: o, titleTag: s = "h1", remember: c = !0, passwordMinLength: l = 8, codeLength: u = 6, validators: d, error: f, loading: p, sent: m, defaultValues: h, onSubmit: g, providers: _, footer: v, classes: ee, className: b, ...x }) {
|
|
131
|
+
let E = I("authForm", n, ee), k = ie(), j = k.translations.authForm, N = E(), P = C(), F = w(null), [L, V] = T(t), H = e ?? L, [U, ae] = T({
|
|
132
|
+
name: "",
|
|
133
|
+
email: "",
|
|
134
|
+
password: "",
|
|
135
|
+
code: "",
|
|
136
|
+
remember: !1,
|
|
137
|
+
...h
|
|
138
|
+
}), W = (e, t) => ae((n) => ({
|
|
139
|
+
...n,
|
|
140
|
+
[e]: t
|
|
141
|
+
})), [G, K] = T(0), q = {
|
|
142
|
+
texts: k.translations.validation,
|
|
143
|
+
passwordMinLength: l,
|
|
144
|
+
codeLength: u,
|
|
145
|
+
validators: d
|
|
146
|
+
}, J = G ? y(H, U, q) : {}, Y = (e) => `${P}${e}`, X = [...f ? [{ message: f }] : [], ...Object.entries(J).map(([e, t]) => ({
|
|
147
|
+
message: t,
|
|
148
|
+
id: Y(e)
|
|
149
|
+
}))], [Z, oe] = T(0);
|
|
150
|
+
S(() => {
|
|
151
|
+
Z && F.current?.focus();
|
|
152
|
+
}, [Z]);
|
|
153
|
+
let Q = (e) => {
|
|
154
|
+
K(0), V(e), r?.(e), oe((e) => e + 1);
|
|
155
|
+
}, $ = () => {
|
|
156
|
+
K((e) => e + 1), !Object.keys(y(H, U, q)).length && g?.({
|
|
157
|
+
mode: H,
|
|
158
|
+
...U
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
return /* @__PURE__ */ B("div", {
|
|
162
|
+
...x,
|
|
163
|
+
className: N.base({ class: b }),
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ B("div", {
|
|
166
|
+
className: N.header(),
|
|
167
|
+
children: [/* @__PURE__ */ z(s, {
|
|
168
|
+
ref: F,
|
|
169
|
+
tabIndex: -1,
|
|
170
|
+
className: N.title(),
|
|
171
|
+
children: a ?? j.titles[H]
|
|
172
|
+
}), /* @__PURE__ */ z("p", {
|
|
173
|
+
className: N.description(),
|
|
174
|
+
children: o ?? j.descriptions[H]
|
|
175
|
+
})]
|
|
176
|
+
}),
|
|
177
|
+
_ && (H === "signIn" || H === "signUp") && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
178
|
+
role: "group",
|
|
179
|
+
"aria-label": j.providers,
|
|
180
|
+
className: N.providers(),
|
|
181
|
+
children: _
|
|
182
|
+
}), /* @__PURE__ */ z("div", {
|
|
183
|
+
className: N.divider(),
|
|
184
|
+
children: j.or
|
|
185
|
+
})] }),
|
|
186
|
+
/* @__PURE__ */ z(te, {
|
|
187
|
+
errors: X,
|
|
188
|
+
titleTag: "h2",
|
|
189
|
+
focusKey: G
|
|
190
|
+
}),
|
|
191
|
+
H === "reset" && m ? /* @__PURE__ */ z("p", {
|
|
192
|
+
role: "status",
|
|
193
|
+
className: N.status(),
|
|
194
|
+
children: j.resetSent
|
|
195
|
+
}) : /* @__PURE__ */ B("form", {
|
|
196
|
+
className: N.form(),
|
|
197
|
+
noValidate: !0,
|
|
198
|
+
onSubmit: (e) => {
|
|
199
|
+
e.preventDefault(), $();
|
|
200
|
+
},
|
|
201
|
+
children: [
|
|
202
|
+
H === "signUp" && /* @__PURE__ */ z(A, {
|
|
203
|
+
id: Y("name"),
|
|
204
|
+
label: j.name,
|
|
205
|
+
required: !0,
|
|
206
|
+
error: J.name,
|
|
207
|
+
children: /* @__PURE__ */ z(M, {
|
|
208
|
+
value: U.name,
|
|
209
|
+
onChange: (e) => W("name", e.target.value),
|
|
210
|
+
name: "name",
|
|
211
|
+
autoComplete: "name"
|
|
212
|
+
})
|
|
213
|
+
}),
|
|
214
|
+
H !== "code" && /* @__PURE__ */ z(A, {
|
|
215
|
+
id: Y("email"),
|
|
216
|
+
label: j.email,
|
|
217
|
+
required: !0,
|
|
218
|
+
error: J.email,
|
|
219
|
+
children: /* @__PURE__ */ z(M, {
|
|
220
|
+
value: U.email,
|
|
221
|
+
onChange: (e) => W("email", e.target.value),
|
|
222
|
+
type: "email",
|
|
223
|
+
name: "email",
|
|
224
|
+
autoComplete: "email"
|
|
225
|
+
})
|
|
226
|
+
}),
|
|
227
|
+
(H === "signIn" || H === "signUp") && /* @__PURE__ */ z(A, {
|
|
228
|
+
id: Y("password"),
|
|
229
|
+
label: j.password,
|
|
230
|
+
required: !0,
|
|
231
|
+
helperText: H === "signUp" ? j.passwordHint(l) : void 0,
|
|
232
|
+
error: J.password,
|
|
233
|
+
children: /* @__PURE__ */ z(ne, {
|
|
234
|
+
value: U.password,
|
|
235
|
+
onChange: (e) => W("password", e.target.value),
|
|
236
|
+
name: "password",
|
|
237
|
+
autoComplete: H === "signUp" ? "new-password" : "current-password"
|
|
238
|
+
})
|
|
239
|
+
}),
|
|
240
|
+
H === "code" && /* @__PURE__ */ z(A, {
|
|
241
|
+
id: Y("code"),
|
|
242
|
+
label: j.code,
|
|
243
|
+
required: !0,
|
|
244
|
+
error: J.code,
|
|
245
|
+
children: /* @__PURE__ */ z(re, {
|
|
246
|
+
value: U.code,
|
|
247
|
+
onValueChange: (e) => W("code", e),
|
|
248
|
+
length: u,
|
|
249
|
+
otp: !0,
|
|
250
|
+
name: "code"
|
|
251
|
+
})
|
|
252
|
+
}),
|
|
253
|
+
H === "signIn" && (c || i.includes("reset")) && /* @__PURE__ */ B("div", {
|
|
254
|
+
className: N.row(),
|
|
255
|
+
children: [c && /* @__PURE__ */ z(O, {
|
|
256
|
+
checked: U.remember,
|
|
257
|
+
onCheckedChange: (e) => W("remember", e === !0),
|
|
258
|
+
name: "remember",
|
|
259
|
+
children: j.remember
|
|
260
|
+
}), i.includes("reset") && /* @__PURE__ */ z("button", {
|
|
261
|
+
type: "button",
|
|
262
|
+
className: N.link(),
|
|
263
|
+
onClick: () => Q("reset"),
|
|
264
|
+
children: j.forgot
|
|
265
|
+
})]
|
|
266
|
+
}),
|
|
267
|
+
/* @__PURE__ */ z(D, {
|
|
268
|
+
type: "submit",
|
|
269
|
+
loading: p,
|
|
270
|
+
block: !0,
|
|
271
|
+
children: j.submit[H]
|
|
272
|
+
})
|
|
273
|
+
]
|
|
274
|
+
}),
|
|
275
|
+
H === "signIn" && i.includes("signUp") ? /* @__PURE__ */ B("p", {
|
|
276
|
+
className: N.footer(),
|
|
277
|
+
children: [
|
|
278
|
+
j.noAccount,
|
|
279
|
+
" ",
|
|
280
|
+
/* @__PURE__ */ z("button", {
|
|
281
|
+
type: "button",
|
|
282
|
+
className: N.link(),
|
|
283
|
+
onClick: () => Q("signUp"),
|
|
284
|
+
children: j.signUpLink
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
}) : H === "signUp" && i.includes("signIn") ? /* @__PURE__ */ B("p", {
|
|
288
|
+
className: N.footer(),
|
|
289
|
+
children: [
|
|
290
|
+
j.hasAccount,
|
|
291
|
+
" ",
|
|
292
|
+
/* @__PURE__ */ z("button", {
|
|
293
|
+
type: "button",
|
|
294
|
+
className: N.link(),
|
|
295
|
+
onClick: () => Q("signIn"),
|
|
296
|
+
children: j.signInLink
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
}) : (H === "reset" || H === "code") && i.includes("signIn") ? /* @__PURE__ */ z("p", {
|
|
300
|
+
className: N.footer(),
|
|
301
|
+
children: /* @__PURE__ */ z("button", {
|
|
302
|
+
type: "button",
|
|
303
|
+
className: N.link(),
|
|
304
|
+
onClick: () => Q("signIn"),
|
|
305
|
+
children: j.back
|
|
306
|
+
})
|
|
307
|
+
}) : null,
|
|
308
|
+
v
|
|
309
|
+
]
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/AuthLayout/AuthLayout.tsx
|
|
314
|
+
function se({ image: e, side: t = "start", brand: n, teaser: i, footer: a, classes: o, className: s, children: c, ...l }) {
|
|
315
|
+
let u = I("authLayout", r, o)({ side: t });
|
|
316
|
+
return /* @__PURE__ */ B("div", {
|
|
317
|
+
...l,
|
|
318
|
+
className: u.base({ class: s }),
|
|
319
|
+
children: [/* @__PURE__ */ B("main", {
|
|
320
|
+
className: u.main(),
|
|
321
|
+
children: [
|
|
322
|
+
n && /* @__PURE__ */ z("div", {
|
|
323
|
+
className: u.brand(),
|
|
324
|
+
children: n
|
|
325
|
+
}),
|
|
326
|
+
/* @__PURE__ */ z("div", {
|
|
327
|
+
className: u.content(),
|
|
328
|
+
children: c
|
|
329
|
+
}),
|
|
330
|
+
a && /* @__PURE__ */ z("div", {
|
|
331
|
+
className: u.footer(),
|
|
332
|
+
children: a
|
|
333
|
+
})
|
|
334
|
+
]
|
|
335
|
+
}), (e || i) && /* @__PURE__ */ B("aside", {
|
|
336
|
+
className: u.aside(),
|
|
337
|
+
children: [e && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("img", {
|
|
338
|
+
src: e,
|
|
339
|
+
alt: "",
|
|
340
|
+
className: u.image()
|
|
341
|
+
}), /* @__PURE__ */ z("div", {
|
|
342
|
+
className: u.scrim(),
|
|
343
|
+
"aria-hidden": "true"
|
|
344
|
+
})] }), i && /* @__PURE__ */ z("div", {
|
|
345
|
+
className: u.teaser(),
|
|
346
|
+
children: i
|
|
347
|
+
})]
|
|
348
|
+
})]
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/ConditionBuilder/ConditionBuilder.tsx
|
|
353
|
+
var ce = b(null);
|
|
354
|
+
function le({ field: e, rule: t, value: n, label: r, disabled: i, onChange: a }) {
|
|
355
|
+
let o = L(), s = o.conditionBuilder, c = e?.type ?? "text", l = e?.options ?? [];
|
|
356
|
+
return c === "number" ? /* @__PURE__ */ z(F, {
|
|
357
|
+
value: n ?? null,
|
|
358
|
+
"aria-label": r,
|
|
359
|
+
disabled: i,
|
|
360
|
+
size: "sm",
|
|
361
|
+
onValueChange: a
|
|
362
|
+
}) : c === "date" ? /* @__PURE__ */ z(k, {
|
|
363
|
+
value: n ?? null,
|
|
364
|
+
"aria-label": r,
|
|
365
|
+
disabled: i,
|
|
366
|
+
size: "sm",
|
|
367
|
+
onValueChange: a
|
|
368
|
+
}) : c === "select" && t.operator === "in" ? /* @__PURE__ */ z(N, {
|
|
369
|
+
items: l,
|
|
370
|
+
value: n ?? [],
|
|
371
|
+
"aria-label": r,
|
|
372
|
+
disabled: i,
|
|
373
|
+
onValueChange: a
|
|
374
|
+
}) : c === "select" ? /* @__PURE__ */ z(P, {
|
|
375
|
+
items: l,
|
|
376
|
+
value: n ?? "",
|
|
377
|
+
placeholder: o.common.placeholder,
|
|
378
|
+
"aria-label": r,
|
|
379
|
+
disabled: i,
|
|
380
|
+
size: "sm",
|
|
381
|
+
onValueChange: a
|
|
382
|
+
}) : c === "boolean" ? /* @__PURE__ */ z(P, {
|
|
383
|
+
items: [{
|
|
384
|
+
value: "true",
|
|
385
|
+
label: s.yes
|
|
386
|
+
}, {
|
|
387
|
+
value: "false",
|
|
388
|
+
label: s.no
|
|
389
|
+
}],
|
|
390
|
+
value: String(n ?? !0),
|
|
391
|
+
"aria-label": r,
|
|
392
|
+
disabled: i,
|
|
393
|
+
size: "sm",
|
|
394
|
+
onValueChange: (e) => a(e === "true")
|
|
395
|
+
}) : /* @__PURE__ */ z(M, {
|
|
396
|
+
value: n ?? "",
|
|
397
|
+
"aria-label": r,
|
|
398
|
+
disabled: i,
|
|
399
|
+
size: "sm",
|
|
400
|
+
onChange: (e) => a(e.currentTarget.value)
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
function ue({ group: e, path: t, depth: n, label: r, parentId: a }) {
|
|
404
|
+
let o = x(ce), s = I("conditionBuilder", i, o.classes)({ nested: n > 0 }), c = L().conditionBuilder, u = (e) => t ? `${t}.${e + 1}` : String(e + 1), f = o.fields.map((e) => ({
|
|
405
|
+
value: e.id,
|
|
406
|
+
label: e.label
|
|
407
|
+
})), m = (e) => o.fields.find((t) => t.id === e.field), _ = (e, t) => o.update(e.id, (e) => t(e));
|
|
408
|
+
return /* @__PURE__ */ B("fieldset", {
|
|
409
|
+
className: s.group(),
|
|
410
|
+
"data-node": e.id,
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ z("legend", {
|
|
413
|
+
className: s.legend(),
|
|
414
|
+
children: t ? c.group(t) : r ?? c.label
|
|
415
|
+
}),
|
|
416
|
+
/* @__PURE__ */ B("div", {
|
|
417
|
+
className: s.groupHeader(),
|
|
418
|
+
children: [
|
|
419
|
+
(o.negatable || e.not) && /* @__PURE__ */ z(O, {
|
|
420
|
+
checked: e.not === !0,
|
|
421
|
+
disabled: o.disabled,
|
|
422
|
+
onCheckedChange: (t) => o.update(e.id, (e) => d(e, t === !0)),
|
|
423
|
+
children: c.not
|
|
424
|
+
}),
|
|
425
|
+
/* @__PURE__ */ z(P, {
|
|
426
|
+
items: [{
|
|
427
|
+
value: "and",
|
|
428
|
+
label: c.all
|
|
429
|
+
}, {
|
|
430
|
+
value: "or",
|
|
431
|
+
label: c.any
|
|
432
|
+
}],
|
|
433
|
+
value: e.combinator,
|
|
434
|
+
"aria-label": c.combinator,
|
|
435
|
+
disabled: o.disabled,
|
|
436
|
+
size: "sm",
|
|
437
|
+
className: s.combinatorSelect(),
|
|
438
|
+
onValueChange: (t) => o.update(e.id, (e) => ({
|
|
439
|
+
...e,
|
|
440
|
+
combinator: t
|
|
441
|
+
}))
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ B("div", {
|
|
444
|
+
className: s.groupActions(),
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ z(D, {
|
|
447
|
+
variant: "outline",
|
|
448
|
+
size: "sm",
|
|
449
|
+
leadingIcon: U,
|
|
450
|
+
disabled: o.disabled,
|
|
451
|
+
"data-action": "add-rule",
|
|
452
|
+
onClick: () => o.add(e.id, "rule"),
|
|
453
|
+
children: c.addRule
|
|
454
|
+
}),
|
|
455
|
+
n < o.maxDepth && /* @__PURE__ */ z(D, {
|
|
456
|
+
variant: "text",
|
|
457
|
+
size: "sm",
|
|
458
|
+
leadingIcon: U,
|
|
459
|
+
disabled: o.disabled,
|
|
460
|
+
onClick: () => o.add(e.id, "group"),
|
|
461
|
+
children: c.addGroup
|
|
462
|
+
}),
|
|
463
|
+
a && /* @__PURE__ */ z(j, {
|
|
464
|
+
icon: W,
|
|
465
|
+
label: c.removeGroup(t),
|
|
466
|
+
variant: "text",
|
|
467
|
+
size: "sm",
|
|
468
|
+
disabled: o.disabled,
|
|
469
|
+
onClick: () => o.remove(e.id, a)
|
|
470
|
+
})
|
|
471
|
+
]
|
|
472
|
+
})
|
|
473
|
+
]
|
|
474
|
+
}),
|
|
475
|
+
e.children.length ? /* @__PURE__ */ z("ol", {
|
|
476
|
+
className: s.list(),
|
|
477
|
+
children: e.children.map((t, r) => /* @__PURE__ */ B("li", {
|
|
478
|
+
"data-node": t.id,
|
|
479
|
+
children: [r > 0 && /* @__PURE__ */ z("span", {
|
|
480
|
+
className: s.combinator(),
|
|
481
|
+
"aria-hidden": "true",
|
|
482
|
+
children: e.combinator === "or" ? c.or : c.and
|
|
483
|
+
}), t.type === "group" ? /* @__PURE__ */ z(ue, {
|
|
484
|
+
group: t,
|
|
485
|
+
path: u(r),
|
|
486
|
+
depth: n + 1,
|
|
487
|
+
parentId: e.id
|
|
488
|
+
}) : /* @__PURE__ */ B("div", {
|
|
489
|
+
role: "group",
|
|
490
|
+
"aria-label": c.rule(u(r)),
|
|
491
|
+
className: s.rule(),
|
|
492
|
+
children: [
|
|
493
|
+
/* @__PURE__ */ z(P, {
|
|
494
|
+
items: f,
|
|
495
|
+
value: t.field,
|
|
496
|
+
"aria-label": c.field,
|
|
497
|
+
disabled: o.disabled,
|
|
498
|
+
size: "sm",
|
|
499
|
+
className: s.field(),
|
|
500
|
+
onValueChange: (e) => _(t, (t) => h(t, o.fields, e))
|
|
501
|
+
}),
|
|
502
|
+
/* @__PURE__ */ z(P, {
|
|
503
|
+
items: p(m(t)).map((e) => ({
|
|
504
|
+
value: e,
|
|
505
|
+
label: o.operatorLabel(e)
|
|
506
|
+
})),
|
|
507
|
+
value: t.operator,
|
|
508
|
+
"aria-label": c.operator,
|
|
509
|
+
disabled: o.disabled,
|
|
510
|
+
size: "sm",
|
|
511
|
+
className: s.operator(),
|
|
512
|
+
onValueChange: (e) => _(t, (t) => g(t, o.fields, e))
|
|
513
|
+
}),
|
|
514
|
+
t.operator === "between" ? /* @__PURE__ */ z("div", {
|
|
515
|
+
className: s.range(),
|
|
516
|
+
children: [0, 1].map((e) => /* @__PURE__ */ z(le, {
|
|
517
|
+
field: m(t),
|
|
518
|
+
rule: t,
|
|
519
|
+
value: t.value?.[e],
|
|
520
|
+
label: `${c.value}: ${e === 0 ? c.from : c.to}`,
|
|
521
|
+
disabled: o.disabled,
|
|
522
|
+
onChange: (n) => _(t, (t) => {
|
|
523
|
+
let r = Array.isArray(t.value) ? [...t.value] : [null, null];
|
|
524
|
+
return r[e] = n, {
|
|
525
|
+
...t,
|
|
526
|
+
value: r
|
|
527
|
+
};
|
|
528
|
+
})
|
|
529
|
+
}, e))
|
|
530
|
+
}) : !l(t.operator) && /* @__PURE__ */ z("div", {
|
|
531
|
+
className: s.value(),
|
|
532
|
+
children: /* @__PURE__ */ z(le, {
|
|
533
|
+
field: m(t),
|
|
534
|
+
rule: t,
|
|
535
|
+
value: t.value,
|
|
536
|
+
label: c.value,
|
|
537
|
+
disabled: o.disabled,
|
|
538
|
+
onChange: (e) => _(t, (t) => ({
|
|
539
|
+
...t,
|
|
540
|
+
value: e
|
|
541
|
+
}))
|
|
542
|
+
})
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ z(j, {
|
|
545
|
+
icon: W,
|
|
546
|
+
label: c.removeRule(u(r)),
|
|
547
|
+
variant: "text",
|
|
548
|
+
size: "sm",
|
|
549
|
+
disabled: o.disabled,
|
|
550
|
+
onClick: () => o.remove(t.id, e.id)
|
|
551
|
+
})
|
|
552
|
+
]
|
|
553
|
+
})]
|
|
554
|
+
}, t.id))
|
|
555
|
+
}) : /* @__PURE__ */ z("p", {
|
|
556
|
+
className: s.empty(),
|
|
557
|
+
children: c.empty
|
|
558
|
+
})
|
|
559
|
+
]
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
function de({ classes: n, fields: r, value: a, defaultValue: o, onValueChange: c, label: l, maxDepth: u = 3, disabled: d = !1, negatable: p = !1, className: h, ...g }) {
|
|
563
|
+
let _ = I("conditionBuilder", i, n), v = L(), y = v.conditionBuilder, b = _(), [x, C] = T(() => o ?? s("and", "root")), E = a ?? x, D = w(null), O = w(null);
|
|
564
|
+
S(() => {
|
|
565
|
+
O.current &&= (D.current?.querySelector(O.current)?.focus(), null);
|
|
566
|
+
});
|
|
567
|
+
let k = (e) => {
|
|
568
|
+
C(e), c?.(e);
|
|
569
|
+
};
|
|
570
|
+
return /* @__PURE__ */ z(ce, {
|
|
571
|
+
value: {
|
|
572
|
+
fields: r,
|
|
573
|
+
maxDepth: u,
|
|
574
|
+
disabled: d,
|
|
575
|
+
negatable: p,
|
|
576
|
+
classes: n,
|
|
577
|
+
update: (e, t) => k(ee(E, e, t)),
|
|
578
|
+
add: (n, i) => {
|
|
579
|
+
let a = f(r), o = i === "rule" ? a : {
|
|
580
|
+
...s(),
|
|
581
|
+
children: [a]
|
|
582
|
+
};
|
|
583
|
+
k(e(E, n, o)), t(i === "rule" ? y.added : y.groupAdded), O.current = `[data-node="${a.id}"] select`;
|
|
584
|
+
},
|
|
585
|
+
remove: (e, n) => {
|
|
586
|
+
k(m(E, e)), t(y.removed), O.current = `[data-node="${n}"] [data-action="add-rule"]`;
|
|
587
|
+
},
|
|
588
|
+
operatorLabel: (e) => y.operators[e] ?? v.dataTable.matchModes[e] ?? e
|
|
589
|
+
},
|
|
590
|
+
children: /* @__PURE__ */ z("div", {
|
|
591
|
+
...g,
|
|
592
|
+
ref: D,
|
|
593
|
+
className: b.base({ class: h }),
|
|
594
|
+
children: /* @__PURE__ */ z(ue, {
|
|
595
|
+
group: E,
|
|
596
|
+
path: "",
|
|
597
|
+
depth: 0,
|
|
598
|
+
label: l
|
|
599
|
+
})
|
|
600
|
+
})
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
//#endregion
|
|
604
|
+
export { $ as AuthForm, se as AuthLayout, de as ConditionBuilder, q as CtaSection, Z as ModeToggle, Q as SiteHeader, o as emptyConditionGroup, u as matchesCondition };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecore/wirelayer-blocks-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Page blocks for React (site header, CTA section, mode toggle, sign-in form and layout) and the condition builder, built on @wirecore/wirelayer-react",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/WireCore/WireLayer.git",
|
|
9
|
+
"directory": "packages/blocks-react"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/WireCore/WireLayer#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/WireCore/WireLayer/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@wirecore/wirelayer-react": "^0.1.1",
|
|
28
|
+
"react": "^19.0.0",
|
|
29
|
+
"react-dom": "^19.0.0",
|
|
30
|
+
"tailwindcss": "^4.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@ark-ui/react": "^5.39.3",
|
|
34
|
+
"@wirecore/wirelayer-recipes": "^0.1.1",
|
|
35
|
+
"lucide-react": "^1.59.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@storybook/react-vite": "^10.6.2",
|
|
39
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
40
|
+
"@types/react": "^19.3.0",
|
|
41
|
+
"@types/react-dom": "^19.3.0",
|
|
42
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
43
|
+
"@wirecore/wirelayer-react": "0.1.1",
|
|
44
|
+
"react": "^19.3.1",
|
|
45
|
+
"react-dom": "^19.3.1",
|
|
46
|
+
"tailwindcss": "^4.3.3",
|
|
47
|
+
"typescript": "~6.0.3",
|
|
48
|
+
"vite": "^8.3.4"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
52
|
+
"typecheck": "tsc --noEmit"
|
|
53
|
+
}
|
|
6
54
|
}
|