@digitalpromise/design 4.2.0 → 4.5.0

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.
@@ -1,4 +1,4 @@
1
- import { ButtonHTMLAttributes } from 'react';
1
+ import type { ButtonHTMLAttributes } from "react";
2
2
  declare const variants: readonly ["primary", "secondary", "tertiary"];
3
3
  declare const states: readonly ["default", "danger", "inverse", "decolor"];
4
4
  type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
@@ -1,4 +1,4 @@
1
- import { FormInputProps, InputPropsWithoutType } from './types';
1
+ import type { FormInputProps, InputPropsWithoutType } from "./types";
2
2
  type CheckboxProps = InputPropsWithoutType & FormInputProps & {
3
3
  label: string;
4
4
  };
@@ -1,10 +1,10 @@
1
- import { ReactElement, ComponentPropsWithRef } from 'react';
2
- import { FormInputProps } from './types';
1
+ import { ReactElement, type ComponentPropsWithRef } from "react";
2
+ import type { FormInputProps } from "./types";
3
3
  interface DropzoneProps extends Omit<ComponentPropsWithRef<"input">, "type">, FormInputProps {
4
4
  instructions?: string;
5
5
  remover?: ReactElement;
6
6
  }
7
- export declare const Dropzone: ({ children, error, instructions, className, onChange: userOnChange, remover, ...props }: DropzoneProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const Dropzone: ({ children, error, instructions, className, ref: userRef, onChange: userOnChange, remover, ...props }: DropzoneProps) => import("react/jsx-runtime").JSX.Element;
8
8
  type SingleImageDropzoneProps = Omit<DropzoneProps, "multiple" | "accept" | "children">;
9
9
  export declare const SingleImageDropzone: (props: SingleImageDropzoneProps) => import("react/jsx-runtime").JSX.Element;
10
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"dropzone.d.ts","sourceRoot":"","sources":["../../../src/components/forms/dropzone.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,YAAY,EAGZ,KAAK,qBAAqB,EAC3B,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,UAAU,aACR,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAClD,cAAc;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,eAAO,MAAM,QAAQ,GAAI,yFAQtB,aAAa,4CAiHf,CAAC;AAEF,KAAK,wBAAwB,GAAG,IAAI,CAClC,aAAa,EACb,UAAU,GAAG,QAAQ,GAAG,UAAU,CACnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,4CAelE,CAAC"}
1
+ {"version":3,"file":"dropzone.d.ts","sourceRoot":"","sources":["../../../src/components/forms/dropzone.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,YAAY,EAGZ,KAAK,qBAAqB,EAC3B,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,UAAU,aACR,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAClD,cAAc;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,eAAO,MAAM,QAAQ,GAAI,uGAStB,aAAa,4CA2Hf,CAAC;AAEF,KAAK,wBAAwB,GAAG,IAAI,CAClC,aAAa,EACb,UAAU,GAAG,QAAQ,GAAG,UAAU,CACnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,4CAelE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormInputProps } from './types';
1
+ import { FormInputProps } from "./types";
2
2
  interface FormFieldProps<C extends FormInputProps> {
3
3
  Input: React.ComponentType<C>;
4
4
  inputProps: C;
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithRef } from 'react';
1
+ import { ComponentPropsWithRef } from "react";
2
2
  type FormProps = ComponentPropsWithRef<"form">;
3
3
  export declare const Form: ({ noValidate, className, ...props }: FormProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export {};
@@ -1,9 +1,10 @@
1
- import { Checkbox } from './checkbox';
2
- import { Dropzone, SingleImageDropzone } from './dropzone';
3
- import { Form } from './form';
4
- import { FormField } from './form-field';
5
- import { Select } from './select';
6
- import { TextInput } from './text-input';
7
- import { Textarea } from './textarea';
8
- export { Checkbox, Dropzone, SingleImageDropzone, Form, FormField, Select, Textarea, TextInput, };
1
+ import { Checkbox } from "./checkbox";
2
+ import { Dropzone, SingleImageDropzone } from "./dropzone";
3
+ import { Form } from "./form";
4
+ import { FormField } from "./form-field";
5
+ import { Select } from "./select";
6
+ import { TextInput } from "./text-input";
7
+ import { Textarea } from "./textarea";
8
+ import { Label } from "./label";
9
+ export { Checkbox, Dropzone, SingleImageDropzone, Form, FormField, Label, Select, Textarea, TextInput, };
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,GACV,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,GACV,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithRef } from 'react';
1
+ import { type ComponentPropsWithRef } from "react";
2
2
  export interface LabelProps extends ComponentPropsWithRef<"label"> {
3
3
  label: string;
4
4
  error?: boolean;
@@ -1,4 +1,4 @@
1
- import { FormInputProps } from './types';
1
+ import type { FormInputProps } from "./types";
2
2
  type ListInputProps = FormInputProps & {
3
3
  onChange?: (list: string[]) => void;
4
4
  defaultValue?: string[];
@@ -1,5 +1,5 @@
1
- import { ComponentPropsWithRef } from 'react';
2
- import { FormInputProps } from './types';
1
+ import { ComponentPropsWithRef } from "react";
2
+ import { FormInputProps } from "./types";
3
3
  export interface SelectProps extends ComponentPropsWithRef<"select">, FormInputProps {
4
4
  options: {
5
5
  value: string;
@@ -1,5 +1,5 @@
1
- import { ComponentPropsWithRef } from 'react';
2
- import { FormInputProps } from './types';
1
+ import type { ComponentPropsWithRef } from "react";
2
+ import type { FormInputProps } from "./types";
3
3
  interface TextInputProps extends ComponentPropsWithRef<"input">, FormInputProps {
4
4
  }
5
5
  export declare const TextInput: ({ error, className, ...props }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- import { ComponentPropsWithRef } from 'react';
2
- import { FormInputProps } from './types';
1
+ import type { ComponentPropsWithRef } from "react";
2
+ import type { FormInputProps } from "./types";
3
3
  interface TextareaProps extends ComponentPropsWithRef<"textarea">, FormInputProps {
4
4
  }
5
5
  export declare const Textarea: ({ className, error, ...props }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithRef } from 'react';
1
+ import type { ComponentPropsWithRef } from "react";
2
2
  export interface FormInputProps {
3
3
  id?: string;
4
4
  name?: string;
@@ -1,5 +1,5 @@
1
- import { DPGIconName } from '@digitalpromise/icons';
2
- import { ComponentPropsWithRef } from 'react';
1
+ import { type DPGIconName } from "@digitalpromise/icons";
2
+ import { type ComponentPropsWithRef } from "react";
3
3
  interface IconProps extends ComponentPropsWithRef<"svg"> {
4
4
  name: DPGIconName;
5
5
  }
@@ -1,8 +1,8 @@
1
- import { default as Button } from './button';
2
- import { default as Logo } from './logo';
3
- import { default as Pagination } from './pagination';
4
- import { default as Search } from './search';
5
- import { default as Table } from './table';
6
- export type { TableColumn } from './table';
1
+ import { default as Button } from "./button";
2
+ import { default as Logo } from "./logo";
3
+ import { default as Pagination } from "./pagination";
4
+ import { default as Search } from "./search";
5
+ import { default as Table } from "./table";
6
+ export type { TableColumn } from "./table";
7
7
  export { Button, Logo, Pagination, Search, Table };
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from "react";
2
2
  export interface TabProps {
3
3
  id: string;
4
4
  label: ReactNode;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactNode } from "react";
2
2
  export type TableColumn<TRow> = {
3
3
  key: string;
4
4
  header: string;
package/dist/forms.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),g=require("./icon-DjGt_3uE.cjs"),I=({error:a,className:r,label:t,...l})=>{const n=l.id||l.name;return e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("input",{type:"checkbox",className:`transition-colors appearance-none cursor-pointer bg-neutral-1 border-2 border-gray-5 rounded-sm w-5 h-5 grid place-content-center hover:bg-gray-1 hover:border-neutral-5 before:hidden before:content-['\\2713'] before:text-neutral-1 before:font-bold checked:bg-blue-3 checked:border-blue-4 checked:hover:bg-blue-4 checked:hover:border-blue-5 checked:before:inline-block ${r??""}`.trim(),...l,id:n}),e.jsx("label",{"data-error":a||null,htmlFor:n,className:"data-error:text-red-4",children:t})]})},p=({children:a,error:r,instructions:t,className:l,onChange:n,remover:d,...i})=>{const s=u.useRef(null),[v,m]=u.useState(!1),[b,j]=u.useState([]),h=b.length>0,w=o=>{o.preventDefault(),m(!1),s.current&&o.dataTransfer.files.length>0&&(s.current.files=o.dataTransfer.files,o.dataTransfer.clearData(),s.current.dispatchEvent(new Event("change",{bubbles:!0})))},y=o=>{n&&n(o);const k=Array.from(o.currentTarget.files??[]).map(c=>{if(c.type.includes("image")){const F=URL.createObjectURL(c);return e.jsx("img",{alt:"",src:F,className:"max-h-full max-w-full object-contain"},c.name)}else return e.jsx("p",{children:c.name},c.name)});j(k)},N=()=>{s.current&&(s.current.value="",s.current.files=null,s.current.dispatchEvent(new Event("change",{bubbles:!0})))},x={onClick:o=>{o.preventDefault(),N()}},D=d?u.cloneElement(d,x):e.jsx(g.Button,{type:"button",variant:"tertiary",state:"decolor",...x,children:"Remove Files"}),f=o=>{o.preventDefault(),m(!0)};return e.jsxs("div",{children:[e.jsxs("label",{"data-showing-preview":h||null,"data-is-dragging":v||null,onDragLeave:()=>m(!1),onDragEnter:f,onDragOver:f,onDrop:w,htmlFor:i.id,"data-error":r||null,className:`flex items-center justify-center rounded-lg border border-dashed border-blue-3 px-7 py-8 font-medium text-blue-3 data-showing-preview:w-max data-showing-preview:border-gray-3 data-showing-preview:text-gray-3 data-is-dragging:border-blue-5 data-is-dragging:bg-blue-1 data-showing-preview:py-5 data-is-dragging:text-blue-4 ${l??""} cursor-default`.trim(),children:[e.jsx("input",{...i,ref:s,onChange:y,className:"sr-only",type:"file"}),h?e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"grid grid-cols-2 grid-rows-2 w-11 h-11",children:b}),D]}):a??e.jsxs("p",{className:"pointer-events-none select-none",children:[e.jsx(g.Icon,{name:"Upload"})," Click or drop to upload"]})]}),t&&e.jsx("p",{className:"font-light leading-6",children:t})]})},T=a=>{const r=e.jsx(g.Button,{type:"button",variant:"tertiary",state:"decolor",children:"Remove Image"});return e.jsx(p,{...a,multiple:!1,remover:r,accept:"image/png image/svg+xml"})},q=({noValidate:a,className:r,...t})=>e.jsx("form",{className:`container flex flex-col gap-7 max-w-[45rem] ${r??""}`.trim(),...t,noValidate:a??!0}),C=({className:a,label:r,required:t,error:l,...n})=>e.jsx("label",{"data-required":t||null,"data-error":l||null,...n,className:`text-base font-medium leading-5 data-error:text-red-4 data-required:after:content-['*'] data-required:after:text-red-4 data-required:after:ml-1 ${a??""}`.trim(),children:r}),S=({Input:a,inputProps:r,errorMessage:t,label:l,labelClassname:n})=>{const d=!!t,i=r?.id||r?.name;return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:l,className:n,htmlFor:i,required:r?.required,error:d}),e.jsx(a,{error:d,...r,id:i}),t&&e.jsx("p",{className:"text-red-4",children:t})]})},E=({options:a,error:r,className:t,...l})=>e.jsx("select",{...l,"data-error":r||null,className:`border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${t??""}`.trim(),children:a.map(n=>e.jsx("option",{className:"hover:bg-gray-3",value:n.value,children:n.label},[l.name,n.label].join()))}),R=({error:a,className:r,...t})=>e.jsx("input",{"data-error":a||null,className:`border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${r??""}`.trim(),...t,type:"text"}),$=({className:a,error:r,...t})=>e.jsx("textarea",{"data-error":r||null,className:`border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${a??""}`.trim(),...t});exports.Checkbox=I;exports.Dropzone=p;exports.Form=q;exports.FormField=S;exports.Select=E;exports.SingleImageDropzone=T;exports.TextInput=R;exports.Textarea=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),g=require("./icon-DjGt_3uE.cjs"),q=({error:a,className:r,label:t,...o})=>{const n=o.id||o.name;return e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("input",{type:"checkbox",className:`transition-colors appearance-none cursor-pointer bg-neutral-1 border-2 border-gray-5 rounded-sm w-5 h-5 grid place-content-center hover:bg-gray-1 hover:border-neutral-5 before:hidden before:content-['\\2713'] before:text-neutral-1 before:font-bold checked:bg-blue-3 checked:border-blue-4 checked:hover:bg-blue-4 checked:hover:border-blue-5 checked:before:inline-block ${r??""}`.trim(),...o,id:n}),e.jsx("label",{"data-error":a||null,htmlFor:n,className:"data-error:text-red-4",children:t})]})},v=({children:a,error:r,instructions:t,className:o,ref:n,onChange:i,remover:d,...b})=>{const s=u.useRef(null),[w,m]=u.useState(!1),[h,y]=u.useState([]),x=h.length>0,N=l=>{l.preventDefault(),m(!1),s.current&&l.dataTransfer.files.length>0&&(s.current.files=l.dataTransfer.files,l.dataTransfer.clearData(),s.current.dispatchEvent(new Event("change",{bubbles:!0})))},D=l=>{i&&i(l);const I=Array.from(l.currentTarget.files??[]).map(c=>{if(c.type.includes("image")){const T=URL.createObjectURL(c);return e.jsx("img",{alt:"",src:T,className:"max-h-full max-w-full object-contain"},c.name)}else return e.jsx("p",{children:c.name},c.name)});y(I)},F=()=>{s.current&&(s.current.value="",s.current.files=null,s.current.dispatchEvent(new Event("change",{bubbles:!0})))},f={onClick:l=>{l.preventDefault(),F()}},k=d?u.cloneElement(d,f):e.jsx(g.Button,{type:"button",variant:"tertiary",state:"decolor",...f,children:"Remove Files"}),p=l=>{l.preventDefault(),m(!0)};return e.jsxs("div",{children:[e.jsxs("label",{"data-showing-preview":x||null,"data-is-dragging":w||null,onDragLeave:()=>m(!1),onDragEnter:p,onDragOver:p,onDrop:N,htmlFor:b.id,"data-error":r||null,className:`flex items-center justify-center rounded-lg border border-dashed border-blue-3 px-7 py-8 font-medium text-blue-3 data-showing-preview:w-max data-showing-preview:border-gray-3 data-showing-preview:text-gray-3 data-is-dragging:border-blue-5 data-is-dragging:bg-blue-1 data-showing-preview:py-5 data-is-dragging:text-blue-4 ${o??""} cursor-default`.trim(),children:[e.jsx("input",{...b,ref:l=>{n&&(n instanceof Function?n(l):n.current=l),s.current=l},onChange:D,className:"sr-only",type:"file"}),x?e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"grid grid-cols-2 grid-rows-2 w-11 h-11",children:h}),k]}):a??e.jsxs("p",{className:"pointer-events-none select-none",children:[e.jsx(g.Icon,{name:"Upload"})," Click or drop to upload"]})]}),t&&e.jsx("p",{className:"font-light leading-6",children:t})]})},C=a=>{const r=e.jsx(g.Button,{type:"button",variant:"tertiary",state:"decolor",children:"Remove Image"});return e.jsx(v,{...a,multiple:!1,remover:r,accept:"image/png image/svg+xml"})},S=({noValidate:a,className:r,...t})=>e.jsx("form",{className:`container flex flex-col gap-7 max-w-[45rem] ${r??""}`.trim(),...t,noValidate:a??!0}),j=({className:a,label:r,required:t,error:o,...n})=>e.jsx("label",{"data-required":t||null,"data-error":o||null,...n,className:`text-base font-medium leading-5 data-error:text-red-4 data-required:after:content-['*'] data-required:after:text-red-4 data-required:after:ml-1 ${a??""}`.trim(),children:r}),E=({Input:a,inputProps:r,errorMessage:t,label:o,labelClassname:n})=>{const i=!!t,d=r?.id||r?.name;return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(j,{label:o,className:n,htmlFor:d,required:r?.required,error:i}),e.jsx(a,{error:i,...r,id:d}),t&&e.jsx("p",{className:"text-red-4",children:t})]})},$=({options:a,error:r,className:t,...o})=>e.jsx("select",{...o,"data-error":r||null,className:`border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${t??""}`.trim(),children:a.map(n=>e.jsx("option",{className:"hover:bg-gray-3",value:n.value,children:n.label},[o.name,n.label].join()))}),L=({error:a,className:r,...t})=>e.jsx("input",{"data-error":a||null,className:`border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${r??""}`.trim(),...t,type:"text"}),z=({className:a,error:r,...t})=>e.jsx("textarea",{"data-error":r||null,className:`border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${a??""}`.trim(),...t});exports.Checkbox=q;exports.Dropzone=v;exports.Form=S;exports.FormField=E;exports.Label=j;exports.Select=$;exports.SingleImageDropzone=C;exports.TextInput=L;exports.Textarea=z;
@@ -0,0 +1,72 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import { JSX } from 'react/jsx-runtime';
3
+ import { ReactElement } from 'react';
4
+
5
+ export declare const Checkbox: ({ error, className, label, ...props }: CheckboxProps) => JSX.Element;
6
+
7
+ declare type CheckboxProps = InputPropsWithoutType & FormInputProps & {
8
+ label: string;
9
+ };
10
+
11
+ export declare const Dropzone: ({ children, error, instructions, className, ref: userRef, onChange: userOnChange, remover, ...props }: DropzoneProps) => JSX.Element;
12
+
13
+ declare interface DropzoneProps extends Omit<ComponentPropsWithRef<"input">, "type">, FormInputProps {
14
+ instructions?: string;
15
+ remover?: ReactElement;
16
+ }
17
+
18
+ export declare const Form: ({ noValidate, className, ...props }: FormProps) => JSX.Element;
19
+
20
+ export declare const FormField: <P extends FormInputProps>({ Input, inputProps, errorMessage, label, labelClassname, }: FormFieldProps<P>) => JSX.Element;
21
+
22
+ declare interface FormFieldProps<C extends FormInputProps> {
23
+ Input: React.ComponentType<C>;
24
+ inputProps: C;
25
+ errorMessage?: string;
26
+ label: string;
27
+ labelClassname?: string;
28
+ }
29
+
30
+ declare interface FormInputProps {
31
+ id?: string;
32
+ name?: string;
33
+ error?: boolean;
34
+ required?: boolean;
35
+ }
36
+
37
+ declare type FormProps = ComponentPropsWithRef<"form">;
38
+
39
+ declare type InputPropsWithoutType = Omit<ComponentPropsWithRef<"input">, "type">;
40
+
41
+ export declare const Label: ({ className, label, required, error, ...props }: LabelProps) => JSX.Element;
42
+
43
+ declare interface LabelProps extends ComponentPropsWithRef<"label"> {
44
+ label: string;
45
+ error?: boolean;
46
+ required?: boolean;
47
+ }
48
+
49
+ export declare const Select: ({ options, error, className, ...props }: SelectProps) => JSX.Element;
50
+
51
+ declare interface SelectProps extends ComponentPropsWithRef<"select">, FormInputProps {
52
+ options: {
53
+ value: string;
54
+ label: string;
55
+ }[];
56
+ }
57
+
58
+ export declare const SingleImageDropzone: (props: SingleImageDropzoneProps) => JSX.Element;
59
+
60
+ declare type SingleImageDropzoneProps = Omit<DropzoneProps, "multiple" | "accept" | "children">;
61
+
62
+ export declare const Textarea: ({ className, error, ...props }: TextareaProps) => JSX.Element;
63
+
64
+ declare interface TextareaProps extends ComponentPropsWithRef<"textarea">, FormInputProps {
65
+ }
66
+
67
+ export declare const TextInput: ({ error, className, ...props }: TextInputProps) => JSX.Element;
68
+
69
+ declare interface TextInputProps extends ComponentPropsWithRef<"input">, FormInputProps {
70
+ }
71
+
72
+ export { }
package/dist/forms.js CHANGED
@@ -1,20 +1,20 @@
1
- import { jsxs as i, jsx as e, Fragment as C } from "react/jsx-runtime";
2
- import { useRef as E, useState as p, cloneElement as T } from "react";
3
- import { B as v, I as $ } from "./icon-BR2zaZo5.js";
4
- const S = ({
1
+ import { jsxs as i, jsx as e, Fragment as E } from "react/jsx-runtime";
2
+ import { useRef as T, useState as v, cloneElement as $ } from "react";
3
+ import { B as x, I as j } from "./icon-BR2zaZo5.js";
4
+ const U = ({
5
5
  error: a,
6
6
  className: r,
7
7
  label: t,
8
- ...l
8
+ ...o
9
9
  }) => {
10
- const n = l.id || l.name;
10
+ const n = o.id || o.name;
11
11
  return /* @__PURE__ */ i("div", { className: "flex gap-3 items-center", children: [
12
12
  /* @__PURE__ */ e(
13
13
  "input",
14
14
  {
15
15
  type: "checkbox",
16
16
  className: `transition-colors appearance-none cursor-pointer bg-neutral-1 border-2 border-gray-5 rounded-sm w-5 h-5 grid place-content-center hover:bg-gray-1 hover:border-neutral-5 before:hidden before:content-['\\2713'] before:text-neutral-1 before:font-bold checked:bg-blue-3 checked:border-blue-4 checked:hover:bg-blue-4 checked:hover:border-blue-5 checked:before:inline-block ${r ?? ""}`.trim(),
17
- ...l,
17
+ ...o,
18
18
  id: n
19
19
  }
20
20
  ),
@@ -28,29 +28,30 @@ const S = ({
28
28
  }
29
29
  )
30
30
  ] });
31
- }, j = ({
31
+ }, q = ({
32
32
  children: a,
33
33
  error: r,
34
34
  instructions: t,
35
- className: l,
36
- onChange: n,
35
+ className: o,
36
+ ref: n,
37
+ onChange: c,
37
38
  remover: s,
38
- ...c
39
+ ...g
39
40
  }) => {
40
- const d = E(null), [x, m] = p(!1), [g, w] = p([]), b = g.length > 0, y = (o) => {
41
- o.preventDefault(), m(!1), d.current && o.dataTransfer.files.length > 0 && (d.current.files = o.dataTransfer.files, o.dataTransfer.clearData(), d.current.dispatchEvent(
41
+ const d = T(null), [w, m] = v(!1), [b, y] = v([]), h = b.length > 0, N = (l) => {
42
+ l.preventDefault(), m(!1), d.current && l.dataTransfer.files.length > 0 && (d.current.files = l.dataTransfer.files, l.dataTransfer.clearData(), d.current.dispatchEvent(
42
43
  new Event("change", { bubbles: !0 })
43
44
  ));
44
- }, N = (o) => {
45
- n && n(o);
46
- const k = Array.from(o.currentTarget.files ?? []).map((u) => {
45
+ }, D = (l) => {
46
+ c && c(l);
47
+ const F = Array.from(l.currentTarget.files ?? []).map((u) => {
47
48
  if (u.type.includes("image")) {
48
- const F = URL.createObjectURL(u);
49
+ const C = URL.createObjectURL(u);
49
50
  return /* @__PURE__ */ e(
50
51
  "img",
51
52
  {
52
53
  alt: "",
53
- src: F,
54
+ src: C,
54
55
  className: "max-h-full max-w-full object-contain"
55
56
  },
56
57
  u.name
@@ -58,47 +59,49 @@ const S = ({
58
59
  } else
59
60
  return /* @__PURE__ */ e("p", { children: u.name }, u.name);
60
61
  });
61
- w(k);
62
- }, D = () => {
62
+ y(F);
63
+ }, I = () => {
63
64
  d.current && (d.current.value = "", d.current.files = null, d.current.dispatchEvent(
64
65
  new Event("change", { bubbles: !0 })
65
66
  ));
66
- }, h = {
67
- onClick: (o) => {
68
- o.preventDefault(), D();
67
+ }, f = {
68
+ onClick: (l) => {
69
+ l.preventDefault(), I();
69
70
  }
70
- }, I = s ? T(s, h) : /* @__PURE__ */ e(v, { type: "button", variant: "tertiary", state: "decolor", ...h, children: "Remove Files" }), f = (o) => {
71
- o.preventDefault(), m(!0);
71
+ }, k = s ? $(s, f) : /* @__PURE__ */ e(x, { type: "button", variant: "tertiary", state: "decolor", ...f, children: "Remove Files" }), p = (l) => {
72
+ l.preventDefault(), m(!0);
72
73
  };
73
74
  return /* @__PURE__ */ i("div", { children: [
74
75
  /* @__PURE__ */ i(
75
76
  "label",
76
77
  {
77
- "data-showing-preview": b || null,
78
- "data-is-dragging": x || null,
78
+ "data-showing-preview": h || null,
79
+ "data-is-dragging": w || null,
79
80
  onDragLeave: () => m(!1),
80
- onDragEnter: f,
81
- onDragOver: f,
82
- onDrop: y,
83
- htmlFor: c.id,
81
+ onDragEnter: p,
82
+ onDragOver: p,
83
+ onDrop: N,
84
+ htmlFor: g.id,
84
85
  "data-error": r || null,
85
- className: `flex items-center justify-center rounded-lg border border-dashed border-blue-3 px-7 py-8 font-medium text-blue-3 data-showing-preview:w-max data-showing-preview:border-gray-3 data-showing-preview:text-gray-3 data-is-dragging:border-blue-5 data-is-dragging:bg-blue-1 data-showing-preview:py-5 data-is-dragging:text-blue-4 ${l ?? ""} cursor-default`.trim(),
86
+ className: `flex items-center justify-center rounded-lg border border-dashed border-blue-3 px-7 py-8 font-medium text-blue-3 data-showing-preview:w-max data-showing-preview:border-gray-3 data-showing-preview:text-gray-3 data-is-dragging:border-blue-5 data-is-dragging:bg-blue-1 data-showing-preview:py-5 data-is-dragging:text-blue-4 ${o ?? ""} cursor-default`.trim(),
86
87
  children: [
87
88
  /* @__PURE__ */ e(
88
89
  "input",
89
90
  {
90
- ...c,
91
- ref: d,
92
- onChange: N,
91
+ ...g,
92
+ ref: (l) => {
93
+ n && (n instanceof Function ? n(l) : n.current = l), d.current = l;
94
+ },
95
+ onChange: D,
93
96
  className: "sr-only",
94
97
  type: "file"
95
98
  }
96
99
  ),
97
- b ? /* @__PURE__ */ i(C, { children: [
98
- /* @__PURE__ */ e("aside", { className: "grid grid-cols-2 grid-rows-2 w-11 h-11", children: g }),
99
- I
100
+ h ? /* @__PURE__ */ i(E, { children: [
101
+ /* @__PURE__ */ e("aside", { className: "grid grid-cols-2 grid-rows-2 w-11 h-11", children: b }),
102
+ k
100
103
  ] }) : a ?? /* @__PURE__ */ i("p", { className: "pointer-events-none select-none", children: [
101
- /* @__PURE__ */ e($, { name: "Upload" }),
104
+ /* @__PURE__ */ e(j, { name: "Upload" }),
102
105
  " Click or drop to upload"
103
106
  ] })
104
107
  ]
@@ -106,72 +109,72 @@ const S = ({
106
109
  ),
107
110
  t && /* @__PURE__ */ e("p", { className: "font-light leading-6", children: t })
108
111
  ] });
109
- }, U = (a) => /* @__PURE__ */ e(
110
- j,
112
+ }, z = (a) => /* @__PURE__ */ e(
113
+ q,
111
114
  {
112
115
  ...a,
113
116
  multiple: !1,
114
- remover: /* @__PURE__ */ e(v, { type: "button", variant: "tertiary", state: "decolor", children: "Remove Image" }),
117
+ remover: /* @__PURE__ */ e(x, { type: "button", variant: "tertiary", state: "decolor", children: "Remove Image" }),
115
118
  accept: "image/png image/svg+xml"
116
119
  }
117
- ), z = ({ noValidate: a, className: r, ...t }) => /* @__PURE__ */ e(
120
+ ), P = ({ noValidate: a, className: r, ...t }) => /* @__PURE__ */ e(
118
121
  "form",
119
122
  {
120
123
  className: `container flex flex-col gap-7 max-w-[45rem] ${r ?? ""}`.trim(),
121
124
  ...t,
122
125
  noValidate: a ?? !0
123
126
  }
124
- ), q = ({
127
+ ), L = ({
125
128
  className: a,
126
129
  label: r,
127
130
  required: t,
128
- error: l,
131
+ error: o,
129
132
  ...n
130
133
  }) => /* @__PURE__ */ e(
131
134
  "label",
132
135
  {
133
136
  "data-required": t || null,
134
- "data-error": l || null,
137
+ "data-error": o || null,
135
138
  ...n,
136
139
  className: `text-base font-medium leading-5 data-error:text-red-4 data-required:after:content-['*'] data-required:after:text-red-4 data-required:after:ml-1 ${a ?? ""}`.trim(),
137
140
  children: r
138
141
  }
139
- ), P = ({
142
+ ), A = ({
140
143
  Input: a,
141
144
  inputProps: r,
142
145
  errorMessage: t,
143
- label: l,
146
+ label: o,
144
147
  labelClassname: n
145
148
  }) => {
146
- const s = !!t, c = r?.id || r?.name;
149
+ const c = !!t, s = r?.id || r?.name;
147
150
  return /* @__PURE__ */ i("div", { className: "flex flex-col gap-3", children: [
148
151
  /* @__PURE__ */ e(
149
- q,
152
+ L,
150
153
  {
151
- label: l,
154
+ label: o,
152
155
  className: n,
153
- htmlFor: c,
156
+ htmlFor: s,
154
157
  required: r?.required,
155
- error: s
158
+ error: c
156
159
  }
157
160
  ),
158
- /* @__PURE__ */ e(a, { error: s, ...r, id: c }),
161
+ /* @__PURE__ */ e(a, { error: c, ...r, id: s }),
159
162
  t && /* @__PURE__ */ e("p", { className: "text-red-4", children: t })
160
163
  ] });
161
- }, A = ({
164
+ }, O = ({
162
165
  options: a,
163
166
  error: r,
164
167
  className: t,
165
- ...l
168
+ ...o
166
169
  }) => /* @__PURE__ */ e(
167
170
  "select",
168
171
  {
169
- ...l,
172
+ ...o,
170
173
  "data-error": r || null,
171
174
  className: `border border-gray-5 rounded-sm text-base leading-5 px-[0.94rem] py-[0.69rem] focus-within:border-transparent focus-within:outline-blue-4 data-error:border-red-4 data-error:outline-red-4 ${t ?? ""}`.trim(),
172
- children: a.map((n) => /* @__PURE__ */ e("option", { className: "hover:bg-gray-3", value: n.value, children: n.label }, [l.name, n.label].join()))
175
+ children: a.map((n) => /* @__PURE__ */ e("option", { className: "hover:bg-gray-3", value: n.value, children: n.label }, [o.name, n.label].join()))
173
176
  }
174
- ), O = ({ error: a, className: r, ...t }) => /* @__PURE__ */ e(
177
+ ), V = ({ error: a, className: r, ...t }) => /* @__PURE__ */ e(
175
178
  "input",
176
179
  {
177
180
  "data-error": a || null,
@@ -179,7 +182,7 @@ const S = ({
179
182
  ...t,
180
183
  type: "text"
181
184
  }
182
- ), V = ({ className: a, error: r, ...t }) => /* @__PURE__ */ e(
185
+ ), G = ({ className: a, error: r, ...t }) => /* @__PURE__ */ e(
183
186
  "textarea",
184
187
  {
185
188
  "data-error": r || null,
@@ -188,12 +191,13 @@ const S = ({
188
191
  }
189
192
  );
190
193
  export {
191
- S as Checkbox,
192
- j as Dropzone,
193
- z as Form,
194
- P as FormField,
195
- A as Select,
196
- U as SingleImageDropzone,
197
- O as TextInput,
198
- V as Textarea
194
+ U as Checkbox,
195
+ q as Dropzone,
196
+ P as Form,
197
+ A as FormField,
198
+ L as Label,
199
+ O as Select,
200
+ z as SingleImageDropzone,
201
+ V as TextInput,
202
+ G as Textarea
199
203
  };
@@ -0,0 +1,60 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ import { JSX } from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ export declare function Button({ className, variant, state, ...props }: ButtonProps): JSX.Element;
6
+
7
+ declare type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
8
+ variant?: (typeof variants)[number];
9
+ state?: (typeof states)[number];
10
+ };
11
+
12
+ export declare function Logo({ variant, className, }: {
13
+ variant?: LogoVariant;
14
+ className?: string;
15
+ }): JSX.Element | null;
16
+
17
+ declare type LogoVariant = "black" | "white" | "color";
18
+
19
+ export declare function Pagination({ count, limit, pageParamKey, }: PaginationProps): JSX.Element;
20
+
21
+ declare type PaginationProps = {
22
+ count: number;
23
+ limit: number;
24
+ pageParamKey?: string;
25
+ };
26
+
27
+ export declare function Search({ placeholder, className, inputWidth, value, onChange, syncToUrl, id, paramKey, }: SearchProps): JSX.Element;
28
+
29
+ declare type SearchProps = {
30
+ placeholder: string;
31
+ className?: string;
32
+ inputWidth?: number | string;
33
+ value?: string;
34
+ onChange?: (value: string) => void;
35
+ syncToUrl?: boolean;
36
+ id?: string;
37
+ paramKey?: string;
38
+ };
39
+
40
+ declare const states: readonly ["default", "danger", "inverse", "decolor"];
41
+
42
+ export declare function Table<TRow>({ columns, rows, rowKey }: TableProps<TRow>): JSX.Element;
43
+
44
+ export declare type TableColumn<TRow> = {
45
+ key: string;
46
+ header: string;
47
+ headerClassName?: string;
48
+ cellClassName?: string;
49
+ render: (row: TRow) => ReactNode;
50
+ };
51
+
52
+ declare type TableProps<TRow> = {
53
+ columns: TableColumn<TRow>[];
54
+ rows: TRow[];
55
+ rowKey: (row: TRow, index: number) => string;
56
+ };
57
+
58
+ declare const variants: readonly ["primary", "secondary", "tertiary"];
59
+
60
+ export { }
@@ -0,0 +1 @@
1
+ export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@digitalpromise/design",
3
3
  "private": false,
4
- "version": "4.2.0",
4
+ "version": "4.5.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
@@ -9,7 +9,7 @@
9
9
  "./forms": "./dist/forms.js",
10
10
  "./theme": "./dist/theme.css"
11
11
  },
12
- "types": "./dist/components/index.d.ts",
12
+ "types": "./dist/index.d.ts",
13
13
  "files": [
14
14
  "dist"
15
15
  ],
@@ -17,6 +17,7 @@
17
17
  "@chromatic-com/storybook": "^5.0.1",
18
18
  "@digitalpromise/icons": "^2.6.1",
19
19
  "@eslint/js": "^10.0.1",
20
+ "@microsoft/api-extractor": "^7.57.6",
20
21
  "@storybook/addon-docs": "^10.2.13",
21
22
  "@storybook/addon-links": "^10.2.13",
22
23
  "@storybook/react-vite": "^10.2.13",
@@ -29,7 +30,7 @@
29
30
  "@typescript-eslint/eslint-plugin": "^8.56.1",
30
31
  "@typescript-eslint/parser": "^8.56.1",
31
32
  "@vitejs/plugin-react-swc": "^4.2.3",
32
- "eslint": "^10.0.2",
33
+ "eslint": "^9.39.3",
33
34
  "eslint-plugin-react-hooks": "^7.0.1",
34
35
  "eslint-plugin-storybook": "^10.2.13",
35
36
  "jsdom": "^28.1.0",
@@ -40,8 +41,8 @@
40
41
  "tailwindcss": "^4.2.1",
41
42
  "typescript": "^5.9.3",
42
43
  "typescript-eslint": "^8.56.1",
44
+ "unplugin-dts": "1.0.0-beta.6",
43
45
  "vite": "^7.3.1",
44
- "vite-plugin-dts": "^4.5.4",
45
46
  "vitest": "^4.0.18"
46
47
  },
47
48
  "peerDependencies": {
@@ -61,7 +62,7 @@
61
62
  "prestorybook": "style-dictionary build",
62
63
  "prebuild-storybook": "style-dictionary build",
63
64
  "prebuild": "style-dictionary build",
64
- "build": "tsc && vite build",
65
+ "build": "vite build && tsc",
65
66
  "lint": "eslint ./src --ext ts,tsx",
66
67
  "preview": "vite preview",
67
68
  "storybook": "storybook dev -p 6006",