@sps-woodland/modal 8.0.0-rc1

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.
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifest } from "@sps-woodland/core";
2
+ export declare const MANIFEST: ComponentManifest;
@@ -0,0 +1,19 @@
1
+ import { Tokens } from "@sps-woodland/tokens";
2
+ import type { VariantDefinitions, RecipeVariant, BooleanRecipeVariant } from "@sps-woodland/core";
3
+ export declare type ModalKind = keyof typeof Tokens.component["modal"]["kind"];
4
+ export declare type ModalSize = keyof typeof Tokens.component["modal"]["size"];
5
+ interface ModalVariantDefinitions extends VariantDefinitions {
6
+ kind: RecipeVariant<ModalKind>;
7
+ size: RecipeVariant<ModalSize>;
8
+ fullHeight: BooleanRecipeVariant;
9
+ }
10
+ export declare const modal: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<ModalVariantDefinitions>;
11
+ export declare const title: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<Pick<ModalVariantDefinitions, "kind">>;
12
+ export declare const titleContent: string;
13
+ export declare const modalIcon: string;
14
+ export declare const body: string;
15
+ export declare const footer: string;
16
+ export declare const closeButtonBox: string;
17
+ export declare const closeButtonIcon: string;
18
+ export declare const underlay: string;
19
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ComponentProps, ChildrenFn } from "@sps-woodland/core";
2
+ import type { IconName } from "@sps-woodland/tokens";
3
+ import type { AriaModalOverlayProps, AriaDialogProps, OverlayTriggerAria } from "react-aria";
4
+ import type { OverlayTriggerState } from "react-stately";
5
+ import * as React from "react";
6
+ import type { ModalKind, ModalSize } from "./Modal.css";
7
+ interface ModalPropsFromHook {
8
+ state: OverlayTriggerState;
9
+ overlayProps: OverlayTriggerAria["overlayProps"];
10
+ }
11
+ declare type ModalContentRenderFn = (close: OverlayTriggerState["close"]) => React.ReactNode;
12
+ declare type ModalProps = ModalPropsFromHook & AriaModalOverlayProps & AriaDialogProps & {
13
+ kind?: ModalKind;
14
+ size?: ModalSize;
15
+ title: React.ReactNode | ModalContentRenderFn;
16
+ footer?: React.ReactNode | ModalContentRenderFn;
17
+ dismissable?: boolean;
18
+ onClose?: () => void;
19
+ focusElementOnOpen?: React.MutableRefObject<HTMLElement>;
20
+ fullHeight?: boolean;
21
+ };
22
+ export declare const ModalIcons: Record<ModalKind, IconName>;
23
+ declare function ModalInternal({ children, className, "data-testid": dataTestId, kind, onBlur, onFocus, overlayProps, size, state, title, dismissable, onClose, fullHeight, ...rest }: ComponentProps<ModalProps, HTMLDivElement> & ChildrenFn<ModalContentRenderFn>): React.ReactElement;
24
+ export declare function Modal(props: Parameters<typeof ModalInternal>[0]): React.ReactElement;
25
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { AriaButtonProps, OverlayTriggerAria } from "react-aria";
2
+ import type { OverlayTriggerState, OverlayTriggerProps } from "react-stately";
3
+ import type { RefObject } from "react";
4
+ interface ModalPropsAndState {
5
+ triggerProps: Omit<AriaButtonProps, "onPress"> & {
6
+ onClick: AriaButtonProps["onPress"];
7
+ ref: RefObject<HTMLElement | null>;
8
+ };
9
+ modalState: OverlayTriggerProps;
10
+ modalProps: {
11
+ state: OverlayTriggerState;
12
+ overlayProps: OverlayTriggerAria["overlayProps"];
13
+ };
14
+ }
15
+ export declare function useModal(config?: OverlayTriggerProps): ModalPropsAndState;
16
+ export {};
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import type { ComponentProps } from "@sps-woodland/core";
3
+ export declare function ModalFooter({ children, className, ...rest }: ComponentProps<unknown, HTMLDivElement>): React.ReactElement;
package/lib/style.css ADDED
@@ -0,0 +1 @@
1
+ ._3moto20{background-color:#fff;border-style:solid;border-width:.0625rem;border-radius:.25rem;display:flex;flex-direction:column;overflow:hidden;max-height:100%}._3moto21{border-color:#007db8}._3moto22,._3moto23{border-color:#de002e}._3moto24{border-color:#0b8940}._3moto25,._3moto26{border-color:#e7760b}._3moto27{border-color:#4b5356}._3moto28{width:23.75rem}._3moto29{width:36.25rem}._3moto2a{width:48.75rem}._3moto2b{width:73.75rem}._3moto2c{height:100%}._3moto2e{align-items:center;color:#fff;display:flex;padding:1rem}._3moto2f{background-color:#4b5356}._3moto2g,._3moto2h{background-color:#de002e}._3moto2i{background-color:#007db8}._3moto2j{background-color:#0b8940}._3moto2k,._3moto2l{background-color:#e7760b}._3moto2m{flex-grow:1;font-size:.875rem;font-weight:600;line-height:1.25rem}._3moto2n{font-weight:600;line-height:.875rem;font-size:.875rem;padding-right:.5rem}._3moto2o{overflow-y:auto;padding:1rem;flex:1}._3moto2p{align-items:center;background-color:#f3f4f4;display:flex;justify-content:flex-end;padding:.5rem}._3moto2q{color:#fff;border-width:0}._3moto2r{padding:0 .25rem}._3moto2s{position:fixed;z-index:1000;top:0;left:0;bottom:0;right:0;background:#f3f4f4;display:flex;align-items:center;justify-content:center;padding:1rem}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@sps-woodland/modal",
3
+ "description": "SPS Woodland Design System modal component",
4
+ "version": "8.0.0-rc1",
5
+ "author": "SPS Commerce",
6
+ "license": "UNLICENSED",
7
+ "repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/modal",
8
+ "homepage": "https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/modal#readme",
9
+ "main": "./lib/index.es.js",
10
+ "module": "./lib/index.es.js",
11
+ "types": "./lib/index.d.ts",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "peerDependencies": {
16
+ "@spscommerce/utils": "^6.12.1",
17
+ "react": "^16.9.0",
18
+ "react-dom": "^16.9.0",
19
+ "@sps-woodland/core": "8.0.0-rc1",
20
+ "@sps-woodland/tokens": "8.0.0-rc1",
21
+ "@sps-woodland/buttons": "8.0.0-rc1"
22
+ },
23
+ "devDependencies": {
24
+ "@spscommerce/utils": "^6.12.1",
25
+ "@types/react": "^16.9.0",
26
+ "@vanilla-extract/css": "^1.9.3",
27
+ "@vanilla-extract/recipes": "^0.2.5",
28
+ "@vanilla-extract/sprinkles": "^1.5.0",
29
+ "@vanilla-extract/vite-plugin": "^3.6.0",
30
+ "react": "^16.9.0",
31
+ "react-dom": "^16.9.0",
32
+ "vite": "^3.1.4",
33
+ "@sps-woodland/core": "8.0.0-rc1",
34
+ "@sps-woodland/tokens": "8.0.0-rc1",
35
+ "@sps-woodland/buttons": "8.0.0-rc1"
36
+ },
37
+ "dependencies": {
38
+ "react-aria": "^3.21.0",
39
+ "react-stately": "^3.19.0"
40
+ },
41
+ "scripts": {
42
+ "build": "pnpm run build:js && pnpm run build:types",
43
+ "build:js": "vite build",
44
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
45
+ "watch": "vite build --watch",
46
+ "clean": "git clean -fdX",
47
+ "pub": "node ../../scripts/publish-package.js"
48
+ }
49
+ }
package/vite.config.js ADDED
@@ -0,0 +1,21 @@
1
+ import path from "path";
2
+ import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
3
+ import { defineConfig } from "vite";
4
+
5
+ import pkg from "./package.json";
6
+
7
+ export default defineConfig({
8
+ plugins: [vanillaExtractPlugin()],
9
+ build: {
10
+ lib: {
11
+ entry: path.resolve(__dirname, "src/index.ts"),
12
+ formats: ["es", "cjs"],
13
+ fileName: (format) => `index.${format}.js`,
14
+ },
15
+ outDir: path.resolve(__dirname, "./lib"),
16
+ emptyOutDir: false,
17
+ rollupOptions: {
18
+ external: pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [],
19
+ },
20
+ },
21
+ });