@smartyweb/ui 2.6.0-irina-button-review.gea26df8 → 3.0.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.
@@ -12,10 +12,6 @@ interface SharedProps {
12
12
  */
13
13
  type AsLink = SharedProps & {
14
14
  href: string;
15
- /** Still accepted, but the href decides — `as={Link}` is no longer needed. */
16
- as?: React.ElementType;
17
- /** External hrefs open in a new tab already; this forces it for an internal one. */
18
- openInNewTab?: boolean;
19
15
  /** Saves the file instead of opening it: always a plain <a download>, never a new tab. */
20
16
  download?: boolean;
21
17
  /** A link cannot be disabled, so a disabled link-button renders a disabled <button>. */
@@ -25,12 +21,10 @@ type AsLink = SharedProps & {
25
21
  /** No href — a <button>, type="button" so it never submits a form by accident. */
26
22
  type AsButton = SharedProps & {
27
23
  href?: never;
28
- as?: "button";
29
- openInNewTab?: never;
30
24
  download?: never;
31
25
  type?: "button" | "submit" | "reset";
32
26
  disabled?: boolean;
33
27
  };
34
28
  export type ButtonProps = AsLink | AsButton;
35
- export declare function Button({ as, variant, size, href, openInNewTab, download, disabled, type, onClick, children, }: ButtonProps): import("react/jsx-runtime").JSX.Element;
29
+ export declare function Button({ variant, size, href, download, disabled, type, onClick, children, }: ButtonProps): import("react/jsx-runtime").JSX.Element;
36
30
  export {};
@@ -1,9 +1,21 @@
1
+ import { default as React } from 'react';
1
2
  export type Destination = "external" | "download" | "plain" | "router";
2
3
  /**
3
- * Where an href leads, which decides what <Link> and <Button> render: http(s) opens in a
4
- * new tab, an internal route goes through the <LinkProvider> router, and anything else —
5
- * including a file such as a PDF, which opens in the browser — is a plain <a>.
4
+ * Where an href leads, which decides what <Anchor> renders: http(s) opens in a new tab,
5
+ * an internal route goes through the <LinkProvider> router, and anything else — including
6
+ * a file such as a PDF, which opens in the browser — is a plain <a>.
6
7
  */
7
8
  export declare function destinationOf(href: string, download: boolean): Destination;
8
- /** Tells screen readers a link opens in a new tab; takes no room on screen. */
9
- export declare function NewTabNote(): import("react/jsx-runtime").JSX.Element;
9
+ export interface AnchorProps {
10
+ className: string;
11
+ href: string;
12
+ /** Saves the file instead of opening it: always a plain <a download>, never a new tab. */
13
+ download?: boolean | undefined;
14
+ onClick?: React.MouseEventHandler | undefined;
15
+ children?: React.ReactNode;
16
+ }
17
+ /**
18
+ * The link half of <Link> and <Button>: renders the href where `destinationOf` says it
19
+ * leads, so both components share one routing rule.
20
+ */
21
+ export declare function Anchor({ className, href, download, onClick, children }: AnchorProps): import("react/jsx-runtime").JSX.Element;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),Y="_h1_1765w_1",ee={h1:Y};function R({children:e,className:n}){const s=[ee.h1,n].filter(Boolean).join(" ");return t.jsx("h1",{className:s,children:e})}const ne="_h2_1eque_1",te={h2:ne};function se({children:e}){return t.jsx("h2",{className:te.h2,children:e})}const ie="_paragraph_11t85_1",oe={paragraph:ie};function re({children:e}){return t.jsx("p",{className:oe.paragraph,children:e})}const F=typeof process<"u"&&process.env.NODE_ENV!=="production",B=new Set;function C(e){B.has(e)||(B.add(e),console.warn(`[@smartyweb/ui] ${e}`))}function ae(e){if(typeof e=="string")return`<${e}>`;if(typeof e=="function")return`<${e.name||"Component"}>`;if(typeof e=="object"&&e!==null&&"displayName"in e){const{displayName:n}=e;if(typeof n=="string")return`<${n}>`}return"an unknown element"}function A(e,n){for(const s of r.Children.toArray(e)){if(!r.isValidElement(s)){if(typeof s!="string"&&typeof s!="number")continue;const i=String(s).trim();if(i==="")continue;C(`<UnorderedList> received the text ${JSON.stringify(i.slice(0,40))} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`);continue}if(s.type===r.Fragment){const{children:i}=s.props;A(i,n);continue}n(s.type)||s.type==="li"||C(`<UnorderedList> received ${ae(s.type)} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`)}}function le(){C("<ListItem> was rendered outside of an <UnorderedList>. It renders an <li>, which browsers only style correctly inside a list.")}const ce="_list_1p627_1",ue="_item_1p627_14",W={list:ce,item:ue},H=r.createContext(!1);function T({children:e}){const n=r.useContext(H);return F&&!n&&le(),t.jsx("li",{className:W.item,children:e})}T.isSmartyListItem=!0;function de(e){return e===T?!0:typeof e=="function"&&e.isSmartyListItem===!0}function fe({children:e}){return F&&A(e,de),t.jsx(H,{value:!0,children:t.jsx("ul",{role:"list",className:W.list,children:e})})}const _e="_link_1m7hb_1",me="_accent_1m7hb_28",pe="_disabled_1m7hb_38",he="_newTabNote_1m7hb_48",g={link:_e,accent:me,disabled:pe,newTabNote:he},xe=/\.[a-z][a-z\d]{1,4}$/;function P(e,n){if(n)return"download";if(/^(https?:)?\/\//i.test(e))return"external";if(e.startsWith("#")||/^[a-z][a-z\d+.-]*:/i.test(e))return"plain";const s=(e.split(/[?#]/)[0]??"").toLowerCase();return xe.test(s)?"plain":"router"}function U(){return t.jsx("span",{className:g.newTabNote,children:" (opens in new tab)"})}const z=r.createContext(null);function ye({component:e,children:n}){return t.jsx(z,{value:e,children:n})}function V(){return r.useContext(z)}const ve="_button_1391k_1",je="_sm_1391k_26",be="_primary_1391k_33",Ne="_secondary_1391k_49",ge="_negative_1391k_68",$={button:ve,sm:je,primary:be,secondary:Ne,negative:ge};function Le({as:e,variant:n="primary",size:s="default",href:i,openInNewTab:c=!1,download:d=!1,disabled:o,type:f="button",onClick:_,children:u}){const m=V(),b=[$.button,$[n],s==="sm"&&$.sm].filter(Boolean).join(" ");if(i===void 0||o)return t.jsx("button",{className:b,type:f,disabled:o,onClick:_,children:u});const y=P(i,d),p=y==="external"||c&&y!=="download",w=e??(y==="router"&&m?m:"a");return t.jsxs(w,{className:b,href:i,target:p?"_blank":void 0,rel:p?"noopener noreferrer":void 0,download:y==="download"?"":void 0,onClick:_,children:[u,p&&t.jsx(U,{})]})}function q({variant:e="default",href:n,download:s=!1,disabled:i,onClick:c,children:d}){const o=V(),_=[g.link,e==="accent"&&g.accent,i&&g.disabled].filter(Boolean).join(" ");if(n===void 0)return t.jsx("button",{type:"button",className:_,disabled:i,onClick:i?void 0:c,"aria-disabled":i,children:d});const u=P(n,s);if(u==="external")return t.jsxs("a",{className:_,href:n,target:"_blank",rel:"noopener noreferrer",onClick:c,children:[d,t.jsx(U,{})]});const m=u==="router"&&o?o:"a";return t.jsx(m,{className:_,href:n,download:u==="download"?"":void 0,onClick:c,children:d})}const we=typeof process<"u"&&process.env.NODE_ENV!=="production",E=new Set;function $e(e){E.has(e)||(E.add(e),console.warn(`[@smartyweb/ui] ${e}`))}function ke(){$e("<SideNav> was rendered with no accessible name. Pass `label` so screen reader users can tell this nav apart from the other navigation landmarks on the page.")}const Ce="_nav_dxkjl_3",Oe="_list_dxkjl_7",Te="_item_dxkjl_16",Ie="_link_dxkjl_20",Se="_current_dxkjl_48",j={nav:Ce,list:Oe,item:Te,link:Ie,current:Se},J=r.createContext(null);function De({label:e,current:n,children:s}){return we&&!e?.trim()&&ke(),t.jsx("nav",{className:j.nav,"aria-label":e,children:t.jsx(J,{value:n??null,children:t.jsx("ul",{className:j.list,children:s})})})}function Be({as:e="a",href:n,current:s,openInNewTab:i,onClick:c,children:d}){const o=r.useContext(J),f=s??(o!==null&&o===n),_=[j.link,f&&j.current].filter(Boolean).join(" ");return t.jsx("li",{className:j.item,children:t.jsx(e,{className:_,href:n,target:i?"_blank":void 0,rel:i?"noopener noreferrer":void 0,onClick:c,"aria-current":f?"location":void 0,children:d})})}const K=typeof process<"u"&&process.env.NODE_ENV!=="production",M=new Set;function O(e){M.has(e)||(M.add(e),console.warn(`[@smartyweb/ui] ${e}`))}function Ee(e){if(typeof e=="string")return`<${e}>`;if(typeof e=="function")return`<${e.name||"Component"}>`;if(typeof e=="object"&&e!==null&&"displayName"in e){const{displayName:n}=e;if(typeof n=="string")return`<${n}>`}return"an unknown element"}function X(e,n){for(const s of r.Children.toArray(e)){if(!r.isValidElement(s)){if(typeof s!="string"&&typeof s!="number")continue;const i=String(s).trim();if(i==="")continue;O(`<TableOfContents> received the text ${JSON.stringify(i.slice(0,40))} as a direct child. Its list may only contain entries — wrap it in <TableOfContentsLink href="#…">.`);continue}if(s.type===r.Fragment){const{children:i}=s.props;X(i,n);continue}n(s.type)||s.type==="li"||O(`<TableOfContents> received ${Ee(s.type)} as a direct child. Its list may only contain entries — use <TableOfContentsLink href="#…"> instead.`)}}function Me(){O("<TableOfContentsLink> was rendered outside of a <TableOfContents>. It renders an <li>, which browsers only style correctly inside a list.")}const Re="_nav_1us0j_1",Fe="_heading_1us0j_8",Ae="_list_1us0j_19",We="_item_1us0j_28",L={nav:Re,heading:Fe,list:Ae,item:We},G=r.createContext(!1);function I({href:e,children:n}){const s=r.useContext(G);return K&&!s&&Me(),t.jsx("li",{className:L.item,children:t.jsx(q,{href:e,children:n})})}I.isSmartyTableOfContentsLink=!0;function He(e){return e===I?!0:typeof e=="function"&&e.isSmartyTableOfContentsLink===!0}function Pe({title:e="Table of contents",children:n}){const s=r.useId();return K&&X(n,He),t.jsxs("nav",{className:L.nav,"aria-labelledby":s,children:[t.jsx("h2",{id:s,className:L.heading,children:e}),t.jsx(G,{value:!0,children:t.jsx("ul",{role:"list",className:L.list,children:n})})]})}const Ue="_hero_93692_11",ze="_layout_93692_16",Ve="_content_93692_21",qe="_titleLine_93692_25",Je="_titleWord_93692_29",Ke="_description_93692_35",Xe="_media_93692_48",x={hero:Ue,layout:ze,content:Ve,titleLine:qe,titleWord:Je,description:Ke,media:Xe};function Ge(e){return e.replace(/([- ])/g,n=>`${n===" "?" ":n}|split|`).split("|split|")}const Ze=e=>({"--hero-index":e});function Qe({title:e,description:n,media:s}){const i=Array.isArray(e);let c=0;const d=(i?e:[e]).map(o=>Ge(o).map(f=>({word:f,index:c++})));return t.jsx("section",{className:x.hero,children:t.jsxs("div",{className:x.layout,children:[t.jsx("div",{className:x.media,children:s}),t.jsxs("div",{className:x.content,children:[t.jsx(R,{children:d.map((o,f)=>t.jsx("span",{className:i?x.titleLine:void 0,children:o.map(({word:_,index:u})=>t.jsx("span",{className:x.titleWord,style:Ze(u),children:_},u))},f))}),t.jsx("p",{className:x.description,children:n})]})]})})}function Ye(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.58586 8L1.29297 2.70711L2.70718 1.29289L8.00008 6.58579L13.293 1.29289L14.7072 2.70711L9.41429 8L14.7072 13.2929L13.293 14.7071L8.00008 9.41421L2.70718 14.7071L1.29297 13.2929L6.58586 8Z",fill:"currentColor"})})}const en="_field_14suf_1",nn="_error_14suf_17",tn="_message_14suf_21",sn="_content_14suf_36",on="_reveal_14suf_43",rn="_label_14suf_53",an="_tags_14suf_64",ln="_chips_14suf_71",cn="_input_14suf_78",un="_counter_14suf_95",dn="_empty_14suf_107",fn="_disabled_14suf_134",_n="_chip_14suf_71",mn="_chipText_14suf_160",pn="_remove_14suf_165",hn="_invalid_14suf_176",l={field:en,error:nn,message:tn,content:sn,reveal:on,label:rn,tags:an,chips:ln,input:cn,counter:un,empty:dn,disabled:fn,chip:_n,chipText:mn,remove:pn,invalid:hn};function xn({children:e,invalid:n,onRemove:s}){return t.jsxs("li",{className:[l.chip,n&&l.invalid].filter(Boolean).join(" "),children:[t.jsx("span",{className:l.chipText,children:e}),s&&t.jsx("button",{type:"button",className:l.remove,"aria-label":`Remove ${e}${n?" (invalid)":""}`,onClick:s,children:t.jsx(Ye,{})})]})}const k=100;function yn({label:e,value:n,onChange:s,disabled:i=!1,isTagInvalid:c,onInputChange:d,error:o}){const f=r.useId(),_=`${f}-message`,u=r.useRef(null),[m,S]=r.useState(""),b=n.length>=k,y=a=>{S(a),d?.(a)},p=a=>{const h=a.split(/[\s,]+/),D=h.pop()??"",N=h.filter(Boolean).slice(0,Math.max(0,k-n.length));N.length&&s([...n,...N]),y(D)},w=a=>{a.key==="Enter"&&m&&!a.nativeEvent.isComposing?(a.preventDefault(),p(`${m},`)):a.key==="Backspace"&&!m&&n.length&&s(n.slice(0,-1))},Z=a=>{i||a.target===u.current||a.target.closest("button")||(a.preventDefault(),u.current?.focus())},Q=[l.field,!n.length&&l.empty,i&&l.disabled,o&&l.error].filter(Boolean).join(" ");return t.jsxs("div",{children:[t.jsxs("div",{className:Q,onMouseDown:Z,children:[t.jsxs("div",{className:l.content,children:[t.jsx("label",{htmlFor:f,className:l.label,children:e}),t.jsx("div",{className:l.reveal,children:t.jsxs("div",{className:l.tags,children:[n.length>0&&t.jsx("ul",{role:"list",className:l.chips,children:n.map((a,h)=>t.jsx(xn,{invalid:c?.(a,h)??!1,onRemove:i?void 0:()=>{s(n.filter((D,N)=>N!==h)),h===n.length-1&&u.current?.focus()},children:a},h))}),t.jsx("input",{ref:u,id:f,className:l.input,size:1,value:m,disabled:i,readOnly:b,"aria-invalid":o?!0:void 0,"aria-describedby":o?_:void 0,onChange:a=>{p(a.target.value)},onKeyDown:w,onBlur:()=>{p(`${m},`)}})]})})]}),t.jsx("div",{className:l.reveal,children:t.jsxs("p",{className:l.counter,children:[n.length," / ",k]})})]}),t.jsx("p",{id:_,className:l.message,"aria-live":"polite",children:o})]})}const vn="_field_otub4_1",jn="_label_otub4_16",bn="_reveal_otub4_27",Nn="_input_otub4_37",gn="_empty_otub4_56",v={field:vn,label:jn,reveal:bn,input:Nn,empty:gn};function Ln({label:e,value:n,onChange:s}){const i=r.useId(),c=r.useRef(null),d=o=>{o.target!==c.current&&(o.preventDefault(),c.current?.focus())};return t.jsxs("div",{className:[v.field,!n&&v.empty].filter(Boolean).join(" "),onMouseDown:d,children:[t.jsx("label",{htmlFor:i,className:v.label,children:e}),t.jsx("div",{className:v.reveal,children:t.jsx("div",{children:t.jsx("input",{ref:c,id:i,className:v.input,value:n,onChange:o=>{s(o.target.value)}})})})]})}exports.Button=Le;exports.H1=R;exports.H2=se;exports.Hero=Qe;exports.Link=q;exports.LinkProvider=ye;exports.ListItem=T;exports.MultitagField=yn;exports.Paragraph=re;exports.SideNav=De;exports.SideNavLink=Be;exports.TableOfContents=Pe;exports.TableOfContentsLink=I;exports.TextField=Ln;exports.UnorderedList=fe;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),Z="_h1_1765w_1",Q={h1:Z};function D({children:e,className:n}){const s=[Q.h1,n].filter(Boolean).join(" ");return t.jsx("h1",{className:s,children:e})}const Y="_h2_1eque_1",ee={h2:Y};function ne({children:e}){return t.jsx("h2",{className:ee.h2,children:e})}const te="_paragraph_11t85_1",se={paragraph:te};function ie({children:e}){return t.jsx("p",{className:se.paragraph,children:e})}const B=typeof process<"u"&&process.env.NODE_ENV!=="production",T=new Set;function $(e){T.has(e)||(T.add(e),console.warn(`[@smartyweb/ui] ${e}`))}function oe(e){if(typeof e=="string")return`<${e}>`;if(typeof e=="function")return`<${e.name||"Component"}>`;if(typeof e=="object"&&e!==null&&"displayName"in e){const{displayName:n}=e;if(typeof n=="string")return`<${n}>`}return"an unknown element"}function E(e,n){for(const s of r.Children.toArray(e)){if(!r.isValidElement(s)){if(typeof s!="string"&&typeof s!="number")continue;const i=String(s).trim();if(i==="")continue;$(`<UnorderedList> received the text ${JSON.stringify(i.slice(0,40))} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`);continue}if(s.type===r.Fragment){const{children:i}=s.props;E(i,n);continue}n(s.type)||s.type==="li"||$(`<UnorderedList> received ${oe(s.type)} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`)}}function re(){$("<ListItem> was rendered outside of an <UnorderedList>. It renders an <li>, which browsers only style correctly inside a list.")}const ae="_list_1p627_1",ce="_item_1p627_14",M={list:ae,item:ce},R=r.createContext(!1);function k({children:e}){const n=r.useContext(R);return B&&!n&&re(),t.jsx("li",{className:M.item,children:e})}k.isSmartyListItem=!0;function le(e){return e===k?!0:typeof e=="function"&&e.isSmartyListItem===!0}function ue({children:e}){return B&&E(e,le),t.jsx(R,{value:!0,children:t.jsx("ul",{role:"list",className:M.list,children:e})})}const de="_link_1m7hb_1",fe="_accent_1m7hb_28",_e="_disabled_1m7hb_38",me="_newTabNote_1m7hb_48",v={link:de,accent:fe,disabled:_e,newTabNote:me},A=r.createContext(null);function pe({component:e,children:n}){return t.jsx(A,{value:e,children:n})}function he(){return r.useContext(A)}const xe=/\.[a-z][a-z\d]{1,4}$/;function ye(e,n){if(n)return"download";if(/^(https?:)?\/\//i.test(e))return"external";if(e.startsWith("#")||/^[a-z][a-z\d+.-]*:/i.test(e))return"plain";const s=(e.split(/[?#]/)[0]??"").toLowerCase();return xe.test(s)?"plain":"router"}function je(){return t.jsx("span",{className:v.newTabNote,children:" (opens in new tab)"})}function F({className:e,href:n,download:s=!1,onClick:i,children:a}){const d=he(),o=ye(n,s);if(o==="external")return t.jsxs("a",{className:e,href:n,target:"_blank",rel:"noopener noreferrer",onClick:i,children:[a,t.jsx(je,{})]});const c=o==="router"&&d?d:"a";return t.jsx(c,{className:e,href:n,download:o==="download"?"":void 0,onClick:i,children:a})}const ve="_button_1391k_1",be="_sm_1391k_26",Ne="_primary_1391k_33",ge="_secondary_1391k_49",Le="_negative_1391k_68",g={button:ve,sm:be,primary:Ne,secondary:ge,negative:Le};function $e({variant:e="primary",size:n="default",href:s,download:i,disabled:a,type:d="button",onClick:o,children:c}){const f=[g.button,g[e],n==="sm"&&g.sm].filter(Boolean).join(" ");return s===void 0||a?t.jsx("button",{className:f,type:d,disabled:a,onClick:o,children:c}):t.jsx(F,{className:f,href:s,download:i,onClick:o,children:c})}function W({variant:e="default",href:n,download:s,disabled:i,onClick:a,children:d}){const c=[v.link,e==="accent"&&v.accent,i&&v.disabled].filter(Boolean).join(" ");return n===void 0?t.jsx("button",{type:"button",className:c,disabled:i,onClick:i?void 0:a,"aria-disabled":i,children:d}):t.jsx(F,{className:c,href:n,download:s,onClick:a,children:d})}const we=typeof process<"u"&&process.env.NODE_ENV!=="production",I=new Set;function ke(e){I.has(e)||(I.add(e),console.warn(`[@smartyweb/ui] ${e}`))}function Ce(){ke("<SideNav> was rendered with no accessible name. Pass `label` so screen reader users can tell this nav apart from the other navigation landmarks on the page.")}const Oe="_nav_dxkjl_3",Te="_list_dxkjl_7",Ie="_item_dxkjl_16",Se="_link_dxkjl_20",De="_current_dxkjl_48",y={nav:Oe,list:Te,item:Ie,link:Se,current:De},H=r.createContext(null);function Be({label:e,current:n,children:s}){return we&&!e?.trim()&&Ce(),t.jsx("nav",{className:y.nav,"aria-label":e,children:t.jsx(H,{value:n??null,children:t.jsx("ul",{className:y.list,children:s})})})}function Ee({as:e="a",href:n,current:s,openInNewTab:i,onClick:a,children:d}){const o=r.useContext(H),c=s??(o!==null&&o===n),_=[y.link,c&&y.current].filter(Boolean).join(" ");return t.jsx("li",{className:y.item,children:t.jsx(e,{className:_,href:n,target:i?"_blank":void 0,rel:i?"noopener noreferrer":void 0,onClick:a,"aria-current":c?"location":void 0,children:d})})}const P=typeof process<"u"&&process.env.NODE_ENV!=="production",S=new Set;function w(e){S.has(e)||(S.add(e),console.warn(`[@smartyweb/ui] ${e}`))}function Me(e){if(typeof e=="string")return`<${e}>`;if(typeof e=="function")return`<${e.name||"Component"}>`;if(typeof e=="object"&&e!==null&&"displayName"in e){const{displayName:n}=e;if(typeof n=="string")return`<${n}>`}return"an unknown element"}function U(e,n){for(const s of r.Children.toArray(e)){if(!r.isValidElement(s)){if(typeof s!="string"&&typeof s!="number")continue;const i=String(s).trim();if(i==="")continue;w(`<TableOfContents> received the text ${JSON.stringify(i.slice(0,40))} as a direct child. Its list may only contain entries — wrap it in <TableOfContentsLink href="#…">.`);continue}if(s.type===r.Fragment){const{children:i}=s.props;U(i,n);continue}n(s.type)||s.type==="li"||w(`<TableOfContents> received ${Me(s.type)} as a direct child. Its list may only contain entries — use <TableOfContentsLink href="#…"> instead.`)}}function Re(){w("<TableOfContentsLink> was rendered outside of a <TableOfContents>. It renders an <li>, which browsers only style correctly inside a list.")}const Ae="_nav_1us0j_1",Fe="_heading_1us0j_8",We="_list_1us0j_19",He="_item_1us0j_28",b={nav:Ae,heading:Fe,list:We,item:He},z=r.createContext(!1);function C({href:e,children:n}){const s=r.useContext(z);return P&&!s&&Re(),t.jsx("li",{className:b.item,children:t.jsx(W,{href:e,children:n})})}C.isSmartyTableOfContentsLink=!0;function Pe(e){return e===C?!0:typeof e=="function"&&e.isSmartyTableOfContentsLink===!0}function Ue({title:e="Table of contents",children:n}){const s=r.useId();return P&&U(n,Pe),t.jsxs("nav",{className:b.nav,"aria-labelledby":s,children:[t.jsx("h2",{id:s,className:b.heading,children:e}),t.jsx(z,{value:!0,children:t.jsx("ul",{role:"list",className:b.list,children:n})})]})}const ze="_hero_93692_11",Ve="_layout_93692_16",qe="_content_93692_21",Je="_titleLine_93692_25",Ke="_titleWord_93692_29",Xe="_description_93692_35",Ge="_media_93692_48",p={hero:ze,layout:Ve,content:qe,titleLine:Je,titleWord:Ke,description:Xe,media:Ge};function Ze(e){return e.replace(/([- ])/g,n=>`${n===" "?" ":n}|split|`).split("|split|")}const Qe=e=>({"--hero-index":e});function Ye({title:e,description:n,media:s}){const i=Array.isArray(e);let a=0;const d=(i?e:[e]).map(o=>Ze(o).map(c=>({word:c,index:a++})));return t.jsx("section",{className:p.hero,children:t.jsxs("div",{className:p.layout,children:[t.jsx("div",{className:p.media,children:s}),t.jsxs("div",{className:p.content,children:[t.jsx(D,{children:d.map((o,c)=>t.jsx("span",{className:i?p.titleLine:void 0,children:o.map(({word:_,index:f})=>t.jsx("span",{className:p.titleWord,style:Qe(f),children:_},f))},c))}),t.jsx("p",{className:p.description,children:n})]})]})})}function en(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.58586 8L1.29297 2.70711L2.70718 1.29289L8.00008 6.58579L13.293 1.29289L14.7072 2.70711L9.41429 8L14.7072 13.2929L13.293 14.7071L8.00008 9.41421L2.70718 14.7071L1.29297 13.2929L6.58586 8Z",fill:"currentColor"})})}const nn="_field_14suf_1",tn="_error_14suf_17",sn="_message_14suf_21",on="_content_14suf_36",rn="_reveal_14suf_43",an="_label_14suf_53",cn="_tags_14suf_64",ln="_chips_14suf_71",un="_input_14suf_78",dn="_counter_14suf_95",fn="_empty_14suf_107",_n="_disabled_14suf_134",mn="_chip_14suf_71",pn="_chipText_14suf_160",hn="_remove_14suf_165",xn="_invalid_14suf_176",u={field:nn,error:tn,message:sn,content:on,reveal:rn,label:an,tags:cn,chips:ln,input:un,counter:dn,empty:fn,disabled:_n,chip:mn,chipText:pn,remove:hn,invalid:xn};function yn({children:e,invalid:n,onRemove:s}){return t.jsxs("li",{className:[u.chip,n&&u.invalid].filter(Boolean).join(" "),children:[t.jsx("span",{className:u.chipText,children:e}),s&&t.jsx("button",{type:"button",className:u.remove,"aria-label":`Remove ${e}${n?" (invalid)":""}`,onClick:s,children:t.jsx(en,{})})]})}const L=100;function jn({label:e,value:n,onChange:s,disabled:i=!1,isTagInvalid:a,onInputChange:d,error:o}){const c=r.useId(),_=`${c}-message`,f=r.useRef(null),[h,V]=r.useState(""),q=n.length>=L,J=l=>{V(l),d?.(l)},N=l=>{const m=l.split(/[\s,]+/),O=m.pop()??"",j=m.filter(Boolean).slice(0,Math.max(0,L-n.length));j.length&&s([...n,...j]),J(O)},K=l=>{l.key==="Enter"&&h&&!l.nativeEvent.isComposing?(l.preventDefault(),N(`${h},`)):l.key==="Backspace"&&!h&&n.length&&s(n.slice(0,-1))},X=l=>{i||l.target===f.current||l.target.closest("button")||(l.preventDefault(),f.current?.focus())},G=[u.field,!n.length&&u.empty,i&&u.disabled,o&&u.error].filter(Boolean).join(" ");return t.jsxs("div",{children:[t.jsxs("div",{className:G,onMouseDown:X,children:[t.jsxs("div",{className:u.content,children:[t.jsx("label",{htmlFor:c,className:u.label,children:e}),t.jsx("div",{className:u.reveal,children:t.jsxs("div",{className:u.tags,children:[n.length>0&&t.jsx("ul",{role:"list",className:u.chips,children:n.map((l,m)=>t.jsx(yn,{invalid:a?.(l,m)??!1,onRemove:i?void 0:()=>{s(n.filter((O,j)=>j!==m)),m===n.length-1&&f.current?.focus()},children:l},m))}),t.jsx("input",{ref:f,id:c,className:u.input,size:1,value:h,disabled:i,readOnly:q,"aria-invalid":o?!0:void 0,"aria-describedby":o?_:void 0,onChange:l=>{N(l.target.value)},onKeyDown:K,onBlur:()=>{N(`${h},`)}})]})})]}),t.jsx("div",{className:u.reveal,children:t.jsxs("p",{className:u.counter,children:[n.length," / ",L]})})]}),t.jsx("p",{id:_,className:u.message,"aria-live":"polite",children:o})]})}const vn="_field_otub4_1",bn="_label_otub4_16",Nn="_reveal_otub4_27",gn="_input_otub4_37",Ln="_empty_otub4_56",x={field:vn,label:bn,reveal:Nn,input:gn,empty:Ln};function $n({label:e,value:n,onChange:s}){const i=r.useId(),a=r.useRef(null),d=o=>{o.target!==a.current&&(o.preventDefault(),a.current?.focus())};return t.jsxs("div",{className:[x.field,!n&&x.empty].filter(Boolean).join(" "),onMouseDown:d,children:[t.jsx("label",{htmlFor:i,className:x.label,children:e}),t.jsx("div",{className:x.reveal,children:t.jsx("div",{children:t.jsx("input",{ref:a,id:i,className:x.input,value:n,onChange:o=>{s(o.target.value)}})})})]})}exports.Button=$e;exports.H1=D;exports.H2=ne;exports.Hero=Ye;exports.Link=W;exports.LinkProvider=pe;exports.ListItem=k;exports.MultitagField=jn;exports.Paragraph=ie;exports.SideNav=Be;exports.SideNavLink=Ee;exports.TableOfContents=Ue;exports.TableOfContentsLink=C;exports.TextField=$n;exports.UnorderedList=ue;
package/dist/index.js CHANGED
@@ -1,30 +1,30 @@
1
1
  "use client";
2
- import { jsx as s, jsxs as _ } from "react/jsx-runtime";
3
- import { Children as A, isValidElement as W, Fragment as F, createContext as k, useContext as O, useId as I, useRef as z, useState as on } from "react";
4
- const rn = "_h1_1765w_1", an = {
5
- h1: rn
2
+ import { jsx as s, jsxs as d } from "react/jsx-runtime";
3
+ import { Children as B, isValidElement as E, Fragment as A, createContext as $, useContext as w, useId as C, useRef as M, useState as tn } from "react";
4
+ const sn = "_h1_1765w_1", on = {
5
+ h1: sn
6
6
  };
7
- function cn({ children: n, className: e }) {
8
- const t = [an.h1, e].filter(Boolean).join(" ");
7
+ function rn({ children: n, className: e }) {
8
+ const t = [on.h1, e].filter(Boolean).join(" ");
9
9
  return /* @__PURE__ */ s("h1", { className: t, children: n });
10
10
  }
11
- const ln = "_h2_1eque_1", un = {
12
- h2: ln
11
+ const an = "_h2_1eque_1", cn = {
12
+ h2: an
13
13
  };
14
- function Le({ children: n }) {
15
- return /* @__PURE__ */ s("h2", { className: un.h2, children: n });
14
+ function ke({ children: n }) {
15
+ return /* @__PURE__ */ s("h2", { className: cn.h2, children: n });
16
16
  }
17
- const dn = "_paragraph_11t85_1", fn = {
18
- paragraph: dn
17
+ const ln = "_paragraph_11t85_1", un = {
18
+ paragraph: ln
19
19
  };
20
- function ke({ children: n }) {
21
- return /* @__PURE__ */ s("p", { className: fn.paragraph, children: n });
20
+ function Oe({ children: n }) {
21
+ return /* @__PURE__ */ s("p", { className: un.paragraph, children: n });
22
22
  }
23
- const H = typeof process < "u" && process.env.NODE_ENV !== "production", E = /* @__PURE__ */ new Set();
24
- function C(n) {
25
- E.has(n) || (E.add(n), console.warn(`[@smartyweb/ui] ${n}`));
23
+ const R = typeof process < "u" && process.env.NODE_ENV !== "production", I = /* @__PURE__ */ new Set();
24
+ function T(n) {
25
+ I.has(n) || (I.add(n), console.warn(`[@smartyweb/ui] ${n}`));
26
26
  }
27
- function _n(n) {
27
+ function dn(n) {
28
28
  if (typeof n == "string") return `<${n}>`;
29
29
  if (typeof n == "function") return `<${n.name || "Component"}>`;
30
30
  if (typeof n == "object" && n !== null && "displayName" in n) {
@@ -33,147 +33,83 @@ function _n(n) {
33
33
  }
34
34
  return "an unknown element";
35
35
  }
36
- function U(n, e) {
37
- for (const t of A.toArray(n)) {
38
- if (!W(t)) {
36
+ function W(n, e) {
37
+ for (const t of B.toArray(n)) {
38
+ if (!E(t)) {
39
39
  if (typeof t != "string" && typeof t != "number") continue;
40
40
  const i = String(t).trim();
41
41
  if (i === "") continue;
42
- C(
42
+ T(
43
43
  `<UnorderedList> received the text ${JSON.stringify(i.slice(0, 40))} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`
44
44
  );
45
45
  continue;
46
46
  }
47
- if (t.type === F) {
47
+ if (t.type === A) {
48
48
  const { children: i } = t.props;
49
- U(i, e);
49
+ W(i, e);
50
50
  continue;
51
51
  }
52
- e(t.type) || t.type === "li" || C(
53
- `<UnorderedList> received ${_n(t.type)} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`
52
+ e(t.type) || t.type === "li" || T(
53
+ `<UnorderedList> received ${dn(t.type)} as a direct child. A <ul> may only contain list items — wrap it in <ListItem>.`
54
54
  );
55
55
  }
56
56
  }
57
- function mn() {
58
- C(
57
+ function fn() {
58
+ T(
59
59
  "<ListItem> was rendered outside of an <UnorderedList>. It renders an <li>, which browsers only style correctly inside a list."
60
60
  );
61
61
  }
62
- const pn = "_list_1p627_1", hn = "_item_1p627_14", V = {
63
- list: pn,
64
- item: hn
65
- }, P = k(!1);
66
- function J({ children: n }) {
67
- const e = O(P);
68
- return H && !e && mn(), /* @__PURE__ */ s("li", { className: V.item, children: n });
69
- }
70
- J.isSmartyListItem = !0;
71
- function yn(n) {
72
- return n === J ? !0 : typeof n == "function" && n.isSmartyListItem === !0;
73
- }
74
- function Oe({ children: n }) {
75
- return H && U(n, yn), /* @__PURE__ */ s(P, { value: !0, children: /* @__PURE__ */ s("ul", { role: "list", className: V.list, children: n }) });
76
- }
77
- const vn = "_link_1m7hb_1", bn = "_accent_1m7hb_28", Nn = "_disabled_1m7hb_38", gn = "_newTabNote_1m7hb_48", $ = {
78
- link: vn,
79
- accent: bn,
80
- disabled: Nn,
81
- newTabNote: gn
82
- }, wn = /\.[a-z][a-z\d]{1,4}$/;
83
- function K(n, e) {
62
+ const _n = "_list_1p627_1", mn = "_item_1p627_14", F = {
63
+ list: _n,
64
+ item: mn
65
+ }, z = $(!1);
66
+ function H({ children: n }) {
67
+ const e = w(z);
68
+ return R && !e && fn(), /* @__PURE__ */ s("li", { className: F.item, children: n });
69
+ }
70
+ H.isSmartyListItem = !0;
71
+ function pn(n) {
72
+ return n === H ? !0 : typeof n == "function" && n.isSmartyListItem === !0;
73
+ }
74
+ function Te({ children: n }) {
75
+ return R && W(n, pn), /* @__PURE__ */ s(z, { value: !0, children: /* @__PURE__ */ s("ul", { role: "list", className: F.list, children: n }) });
76
+ }
77
+ const hn = "_link_1m7hb_1", yn = "_accent_1m7hb_28", vn = "_disabled_1m7hb_38", bn = "_newTabNote_1m7hb_48", N = {
78
+ link: hn,
79
+ accent: yn,
80
+ disabled: vn,
81
+ newTabNote: bn
82
+ }, U = $(null);
83
+ function xe({ component: n, children: e }) {
84
+ return /* @__PURE__ */ s(U, { value: n, children: e });
85
+ }
86
+ function Nn() {
87
+ return w(U);
88
+ }
89
+ const gn = /\.[a-z][a-z\d]{1,4}$/;
90
+ function $n(n, e) {
84
91
  if (e) return "download";
85
92
  if (/^(https?:)?\/\//i.test(n)) return "external";
86
93
  if (n.startsWith("#") || /^[a-z][a-z\d+.-]*:/i.test(n)) return "plain";
87
94
  const t = (n.split(/[?#]/)[0] ?? "").toLowerCase();
88
- return wn.test(t) ? "plain" : "router";
89
- }
90
- function X() {
91
- return /* @__PURE__ */ s("span", { className: $.newTabNote, children: " (opens in new tab)" });
92
- }
93
- const q = k(null);
94
- function Te({ component: n, children: e }) {
95
- return /* @__PURE__ */ s(q, { value: n, children: e });
95
+ return gn.test(t) ? "plain" : "router";
96
96
  }
97
- function G() {
98
- return O(q);
97
+ function wn() {
98
+ return /* @__PURE__ */ s("span", { className: N.newTabNote, children: " (opens in new tab)" });
99
99
  }
100
- const $n = "_button_1391k_1", Ln = "_sm_1391k_26", kn = "_primary_1391k_33", On = "_secondary_1391k_49", Tn = "_negative_1391k_68", T = {
101
- button: $n,
102
- sm: Ln,
103
- primary: kn,
104
- secondary: On,
105
- negative: Tn
106
- };
107
- function xe({
108
- as: n,
109
- variant: e = "primary",
110
- size: t = "default",
111
- href: i,
112
- openInNewTab: c = !1,
113
- download: u = !1,
114
- disabled: o,
115
- type: d = "button",
116
- onClick: f,
117
- children: l
118
- }) {
119
- const m = G(), g = [T.button, T[e], t === "sm" && T.sm].filter(Boolean).join(" ");
120
- if (i === void 0 || o)
121
- return /* @__PURE__ */ s("button", { className: g, type: d, disabled: o, onClick: f, children: l });
122
- const v = K(i, u), p = v === "external" || c && v !== "download";
123
- return (
124
- // The router link comes from context, set once at the app root, so it keeps its
125
- // identity across renders — the remount this rule guards against cannot happen.
126
- // eslint-disable-next-line react-hooks/static-components
127
- /* @__PURE__ */ _(
128
- n ?? (v === "router" && m ? m : "a"),
129
- {
130
- className: g,
131
- href: i,
132
- target: p ? "_blank" : void 0,
133
- rel: p ? "noopener noreferrer" : void 0,
134
- download: v === "download" ? "" : void 0,
135
- onClick: f,
136
- children: [
137
- l,
138
- p && /* @__PURE__ */ s(X, {})
139
- ]
140
- }
141
- )
142
- );
143
- }
144
- function xn({
145
- variant: n = "default",
146
- href: e,
147
- download: t = !1,
148
- disabled: i,
149
- onClick: c,
150
- children: u
151
- }) {
152
- const o = G(), f = [$.link, n === "accent" && $.accent, i && $.disabled].filter(Boolean).join(" ");
153
- if (e === void 0)
154
- return /* @__PURE__ */ s(
155
- "button",
156
- {
157
- type: "button",
158
- className: f,
159
- disabled: i,
160
- onClick: i ? void 0 : c,
161
- "aria-disabled": i,
162
- children: u
163
- }
164
- );
165
- const l = K(e, t);
166
- return l === "external" ? /* @__PURE__ */ _(
100
+ function V({ className: n, href: e, download: t = !1, onClick: i, children: r }) {
101
+ const u = Nn(), o = $n(e, t);
102
+ return o === "external" ? /* @__PURE__ */ d(
167
103
  "a",
168
104
  {
169
- className: f,
105
+ className: n,
170
106
  href: e,
171
107
  target: "_blank",
172
108
  rel: "noopener noreferrer",
173
- onClick: c,
109
+ onClick: i,
174
110
  children: [
175
- u,
176
- /* @__PURE__ */ s(X, {})
111
+ r,
112
+ /* @__PURE__ */ s(wn, {})
177
113
  ]
178
114
  }
179
115
  ) : (
@@ -181,61 +117,102 @@ function xn({
181
117
  // identity across renders — the remount this rule guards against cannot happen.
182
118
  // eslint-disable-next-line react-hooks/static-components
183
119
  /* @__PURE__ */ s(
184
- l === "router" && o ? o : "a",
120
+ o === "router" && u ? u : "a",
185
121
  {
186
- className: f,
122
+ className: n,
187
123
  href: e,
188
- download: l === "download" ? "" : void 0,
189
- onClick: c,
190
- children: u
124
+ download: o === "download" ? "" : void 0,
125
+ onClick: i,
126
+ children: r
191
127
  }
192
128
  )
193
129
  );
194
130
  }
195
- const Cn = typeof process < "u" && process.env.NODE_ENV !== "production", M = /* @__PURE__ */ new Set();
196
- function jn(n) {
197
- M.has(n) || (M.add(n), console.warn(`[@smartyweb/ui] ${n}`));
131
+ const Ln = "_button_1391k_1", kn = "_sm_1391k_26", On = "_primary_1391k_33", Tn = "_secondary_1391k_49", xn = "_negative_1391k_68", k = {
132
+ button: Ln,
133
+ sm: kn,
134
+ primary: On,
135
+ secondary: Tn,
136
+ negative: xn
137
+ };
138
+ function Ce({
139
+ variant: n = "primary",
140
+ size: e = "default",
141
+ href: t,
142
+ download: i,
143
+ disabled: r,
144
+ type: u = "button",
145
+ onClick: o,
146
+ children: c
147
+ }) {
148
+ const f = [k.button, k[n], e === "sm" && k.sm].filter(Boolean).join(" ");
149
+ return t === void 0 || r ? /* @__PURE__ */ s("button", { className: f, type: u, disabled: r, onClick: o, children: c }) : /* @__PURE__ */ s(V, { className: f, href: t, download: i, onClick: o, children: c });
198
150
  }
199
- function In() {
200
- jn(
151
+ function Cn({
152
+ variant: n = "default",
153
+ href: e,
154
+ download: t,
155
+ disabled: i,
156
+ onClick: r,
157
+ children: u
158
+ }) {
159
+ const c = [N.link, n === "accent" && N.accent, i && N.disabled].filter(Boolean).join(" ");
160
+ return e === void 0 ? /* @__PURE__ */ s(
161
+ "button",
162
+ {
163
+ type: "button",
164
+ className: c,
165
+ disabled: i,
166
+ onClick: i ? void 0 : r,
167
+ "aria-disabled": i,
168
+ children: u
169
+ }
170
+ ) : /* @__PURE__ */ s(V, { className: c, href: e, download: t, onClick: r, children: u });
171
+ }
172
+ const jn = typeof process < "u" && process.env.NODE_ENV !== "production", S = /* @__PURE__ */ new Set();
173
+ function In(n) {
174
+ S.has(n) || (S.add(n), console.warn(`[@smartyweb/ui] ${n}`));
175
+ }
176
+ function Sn() {
177
+ In(
201
178
  "<SideNav> was rendered with no accessible name. Pass `label` so screen reader users can tell this nav apart from the other navigation landmarks on the page."
202
179
  );
203
180
  }
204
- const Sn = "_nav_dxkjl_3", Dn = "_list_dxkjl_7", Bn = "_item_dxkjl_16", En = "_link_dxkjl_20", Mn = "_current_dxkjl_48", N = {
205
- nav: Sn,
206
- list: Dn,
207
- item: Bn,
208
- link: En,
181
+ const Dn = "_nav_dxkjl_3", Bn = "_list_dxkjl_7", En = "_item_dxkjl_16", An = "_link_dxkjl_20", Mn = "_current_dxkjl_48", v = {
182
+ nav: Dn,
183
+ list: Bn,
184
+ item: En,
185
+ link: An,
209
186
  current: Mn
210
- }, Z = k(null);
211
- function Ce({ label: n, current: e, children: t }) {
212
- return Cn && !n?.trim() && In(), /* @__PURE__ */ s("nav", { className: N.nav, "aria-label": n, children: /* @__PURE__ */ s(Z, { value: e ?? null, children: /* @__PURE__ */ s("ul", { className: N.list, children: t }) }) });
187
+ }, P = $(null);
188
+ function je({ label: n, current: e, children: t }) {
189
+ return jn && !n?.trim() && Sn(), /* @__PURE__ */ s("nav", { className: v.nav, "aria-label": n, children: /* @__PURE__ */ s(P, { value: e ?? null, children: /* @__PURE__ */ s("ul", { className: v.list, children: t }) }) });
213
190
  }
214
- function je({
191
+ function Ie({
215
192
  as: n = "a",
216
193
  href: e,
217
194
  current: t,
218
195
  openInNewTab: i,
219
- onClick: c,
196
+ onClick: r,
220
197
  children: u
221
198
  }) {
222
- const o = O(Z), d = t ?? (o !== null && o === e), f = [N.link, d && N.current].filter(Boolean).join(" ");
223
- return /* @__PURE__ */ s("li", { className: N.item, children: /* @__PURE__ */ s(
199
+ const o = w(P), c = t ?? (o !== null && o === e), _ = [v.link, c && v.current].filter(Boolean).join(" ");
200
+ return /* @__PURE__ */ s("li", { className: v.item, children: /* @__PURE__ */ s(
224
201
  n,
225
202
  {
226
- className: f,
203
+ className: _,
227
204
  href: e,
228
205
  target: i ? "_blank" : void 0,
229
206
  rel: i ? "noopener noreferrer" : void 0,
230
- onClick: c,
231
- "aria-current": d ? "location" : void 0,
207
+ onClick: r,
208
+ "aria-current": c ? "location" : void 0,
232
209
  children: u
233
210
  }
234
211
  ) });
235
212
  }
236
- const Q = typeof process < "u" && process.env.NODE_ENV !== "production", R = /* @__PURE__ */ new Set();
237
- function j(n) {
238
- R.has(n) || (R.add(n), console.warn(`[@smartyweb/ui] ${n}`));
213
+ const J = typeof process < "u" && process.env.NODE_ENV !== "production", D = /* @__PURE__ */ new Set();
214
+ function x(n) {
215
+ D.has(n) || (D.add(n), console.warn(`[@smartyweb/ui] ${n}`));
239
216
  }
240
217
  function Rn(n) {
241
218
  if (typeof n == "string") return `<${n}>`;
@@ -246,81 +223,81 @@ function Rn(n) {
246
223
  }
247
224
  return "an unknown element";
248
225
  }
249
- function Y(n, e) {
250
- for (const t of A.toArray(n)) {
251
- if (!W(t)) {
226
+ function K(n, e) {
227
+ for (const t of B.toArray(n)) {
228
+ if (!E(t)) {
252
229
  if (typeof t != "string" && typeof t != "number") continue;
253
230
  const i = String(t).trim();
254
231
  if (i === "") continue;
255
- j(
232
+ x(
256
233
  `<TableOfContents> received the text ${JSON.stringify(i.slice(0, 40))} as a direct child. Its list may only contain entries — wrap it in <TableOfContentsLink href="#…">.`
257
234
  );
258
235
  continue;
259
236
  }
260
- if (t.type === F) {
237
+ if (t.type === A) {
261
238
  const { children: i } = t.props;
262
- Y(i, e);
239
+ K(i, e);
263
240
  continue;
264
241
  }
265
- e(t.type) || t.type === "li" || j(
242
+ e(t.type) || t.type === "li" || x(
266
243
  `<TableOfContents> received ${Rn(t.type)} as a direct child. Its list may only contain entries — use <TableOfContentsLink href="#…"> instead.`
267
244
  );
268
245
  }
269
246
  }
270
- function An() {
271
- j(
247
+ function Wn() {
248
+ x(
272
249
  "<TableOfContentsLink> was rendered outside of a <TableOfContents>. It renders an <li>, which browsers only style correctly inside a list."
273
250
  );
274
251
  }
275
- const Wn = "_nav_1us0j_1", Fn = "_heading_1us0j_8", zn = "_list_1us0j_19", Hn = "_item_1us0j_28", L = {
276
- nav: Wn,
277
- heading: Fn,
278
- list: zn,
279
- item: Hn
280
- }, nn = k(!1);
281
- function en({ href: n, children: e }) {
282
- const t = O(nn);
283
- return Q && !t && An(), /* @__PURE__ */ s("li", { className: L.item, children: /* @__PURE__ */ s(xn, { href: n, children: e }) });
284
- }
285
- en.isSmartyTableOfContentsLink = !0;
286
- function Un(n) {
287
- return n === en ? !0 : typeof n == "function" && n.isSmartyTableOfContentsLink === !0;
288
- }
289
- function Ie({ title: n = "Table of contents", children: e }) {
290
- const t = I();
291
- return Q && Y(e, Un), /* @__PURE__ */ _("nav", { className: L.nav, "aria-labelledby": t, children: [
292
- /* @__PURE__ */ s("h2", { id: t, className: L.heading, children: n }),
293
- /* @__PURE__ */ s(nn, { value: !0, children: /* @__PURE__ */ s("ul", { role: "list", className: L.list, children: e }) })
252
+ const Fn = "_nav_1us0j_1", zn = "_heading_1us0j_8", Hn = "_list_1us0j_19", Un = "_item_1us0j_28", g = {
253
+ nav: Fn,
254
+ heading: zn,
255
+ list: Hn,
256
+ item: Un
257
+ }, X = $(!1);
258
+ function q({ href: n, children: e }) {
259
+ const t = w(X);
260
+ return J && !t && Wn(), /* @__PURE__ */ s("li", { className: g.item, children: /* @__PURE__ */ s(Cn, { href: n, children: e }) });
261
+ }
262
+ q.isSmartyTableOfContentsLink = !0;
263
+ function Vn(n) {
264
+ return n === q ? !0 : typeof n == "function" && n.isSmartyTableOfContentsLink === !0;
265
+ }
266
+ function Se({ title: n = "Table of contents", children: e }) {
267
+ const t = C();
268
+ return J && K(e, Vn), /* @__PURE__ */ d("nav", { className: g.nav, "aria-labelledby": t, children: [
269
+ /* @__PURE__ */ s("h2", { id: t, className: g.heading, children: n }),
270
+ /* @__PURE__ */ s(X, { value: !0, children: /* @__PURE__ */ s("ul", { role: "list", className: g.list, children: e }) })
294
271
  ] });
295
272
  }
296
- const Vn = "_hero_93692_11", Pn = "_layout_93692_16", Jn = "_content_93692_21", Kn = "_titleLine_93692_25", Xn = "_titleWord_93692_29", qn = "_description_93692_35", Gn = "_media_93692_48", y = {
297
- hero: Vn,
298
- layout: Pn,
299
- content: Jn,
300
- titleLine: Kn,
301
- titleWord: Xn,
302
- description: qn,
303
- media: Gn
273
+ const Pn = "_hero_93692_11", Jn = "_layout_93692_16", Kn = "_content_93692_21", Xn = "_titleLine_93692_25", qn = "_titleWord_93692_29", Gn = "_description_93692_35", Zn = "_media_93692_48", p = {
274
+ hero: Pn,
275
+ layout: Jn,
276
+ content: Kn,
277
+ titleLine: Xn,
278
+ titleWord: qn,
279
+ description: Gn,
280
+ media: Zn
304
281
  };
305
- function Zn(n) {
282
+ function Qn(n) {
306
283
  return n.replace(/([- ])/g, (e) => `${e === " " ? " " : e}|split|`).split("|split|");
307
284
  }
308
- const Qn = (n) => ({ "--hero-index": n });
309
- function Se({ title: n, description: e, media: t }) {
285
+ const Yn = (n) => ({ "--hero-index": n });
286
+ function De({ title: n, description: e, media: t }) {
310
287
  const i = Array.isArray(n);
311
- let c = 0;
288
+ let r = 0;
312
289
  const u = (i ? n : [n]).map(
313
- (o) => Zn(o).map((d) => ({ word: d, index: c++ }))
290
+ (o) => Qn(o).map((c) => ({ word: c, index: r++ }))
314
291
  );
315
- return /* @__PURE__ */ s("section", { className: y.hero, children: /* @__PURE__ */ _("div", { className: y.layout, children: [
316
- /* @__PURE__ */ s("div", { className: y.media, children: t }),
317
- /* @__PURE__ */ _("div", { className: y.content, children: [
318
- /* @__PURE__ */ s(cn, { children: u.map((o, d) => /* @__PURE__ */ s("span", { className: i ? y.titleLine : void 0, children: o.map(({ word: f, index: l }) => /* @__PURE__ */ s("span", { className: y.titleWord, style: Qn(l), children: f }, l)) }, d)) }),
319
- /* @__PURE__ */ s("p", { className: y.description, children: e })
292
+ return /* @__PURE__ */ s("section", { className: p.hero, children: /* @__PURE__ */ d("div", { className: p.layout, children: [
293
+ /* @__PURE__ */ s("div", { className: p.media, children: t }),
294
+ /* @__PURE__ */ d("div", { className: p.content, children: [
295
+ /* @__PURE__ */ s(rn, { children: u.map((o, c) => /* @__PURE__ */ s("span", { className: i ? p.titleLine : void 0, children: o.map(({ word: _, index: f }) => /* @__PURE__ */ s("span", { className: p.titleWord, style: Yn(f), children: _ }, f)) }, c)) }),
296
+ /* @__PURE__ */ s("p", { className: p.description, children: e })
320
297
  ] })
321
298
  ] }) });
322
299
  }
323
- function Yn() {
300
+ function ne() {
324
301
  return /* @__PURE__ */ s("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ s(
325
302
  "path",
326
303
  {
@@ -331,136 +308,136 @@ function Yn() {
331
308
  }
332
309
  ) });
333
310
  }
334
- const ne = "_field_14suf_1", ee = "_error_14suf_17", te = "_message_14suf_21", se = "_content_14suf_36", ie = "_reveal_14suf_43", oe = "_label_14suf_53", re = "_tags_14suf_64", ae = "_chips_14suf_71", ce = "_input_14suf_78", le = "_counter_14suf_95", ue = "_empty_14suf_107", de = "_disabled_14suf_134", fe = "_chip_14suf_71", _e = "_chipText_14suf_160", me = "_remove_14suf_165", pe = "_invalid_14suf_176", a = {
335
- field: ne,
336
- error: ee,
337
- message: te,
338
- content: se,
339
- reveal: ie,
340
- label: oe,
341
- tags: re,
342
- chips: ae,
343
- input: ce,
344
- counter: le,
345
- empty: ue,
346
- disabled: de,
347
- chip: fe,
348
- chipText: _e,
349
- remove: me,
350
- invalid: pe
311
+ const ee = "_field_14suf_1", te = "_error_14suf_17", se = "_message_14suf_21", ie = "_content_14suf_36", oe = "_reveal_14suf_43", re = "_label_14suf_53", ae = "_tags_14suf_64", ce = "_chips_14suf_71", le = "_input_14suf_78", ue = "_counter_14suf_95", de = "_empty_14suf_107", fe = "_disabled_14suf_134", _e = "_chip_14suf_71", me = "_chipText_14suf_160", pe = "_remove_14suf_165", he = "_invalid_14suf_176", l = {
312
+ field: ee,
313
+ error: te,
314
+ message: se,
315
+ content: ie,
316
+ reveal: oe,
317
+ label: re,
318
+ tags: ae,
319
+ chips: ce,
320
+ input: le,
321
+ counter: ue,
322
+ empty: de,
323
+ disabled: fe,
324
+ chip: _e,
325
+ chipText: me,
326
+ remove: pe,
327
+ invalid: he
351
328
  };
352
- function he({ children: n, invalid: e, onRemove: t }) {
353
- return /* @__PURE__ */ _("li", { className: [a.chip, e && a.invalid].filter(Boolean).join(" "), children: [
354
- /* @__PURE__ */ s("span", { className: a.chipText, children: n }),
329
+ function ye({ children: n, invalid: e, onRemove: t }) {
330
+ return /* @__PURE__ */ d("li", { className: [l.chip, e && l.invalid].filter(Boolean).join(" "), children: [
331
+ /* @__PURE__ */ s("span", { className: l.chipText, children: n }),
355
332
  t && /* @__PURE__ */ s(
356
333
  "button",
357
334
  {
358
335
  type: "button",
359
- className: a.remove,
336
+ className: l.remove,
360
337
  "aria-label": `Remove ${n}${e ? " (invalid)" : ""}`,
361
338
  onClick: t,
362
- children: /* @__PURE__ */ s(Yn, {})
339
+ children: /* @__PURE__ */ s(ne, {})
363
340
  }
364
341
  )
365
342
  ] });
366
343
  }
367
- const x = 100;
368
- function De({
344
+ const O = 100;
345
+ function Be({
369
346
  label: n,
370
347
  value: e,
371
348
  onChange: t,
372
349
  disabled: i = !1,
373
- isTagInvalid: c,
350
+ isTagInvalid: r,
374
351
  onInputChange: u,
375
352
  error: o
376
353
  }) {
377
- const d = I(), f = `${d}-message`, l = z(null), [m, S] = on(""), g = e.length >= x, v = (r) => {
378
- S(r), u?.(r);
379
- }, p = (r) => {
380
- const h = r.split(/[\s,]+/), B = h.pop() ?? "", w = h.filter(Boolean).slice(0, Math.max(0, x - e.length));
381
- w.length && t([...e, ...w]), v(B);
382
- }, D = (r) => {
383
- r.key === "Enter" && m && !r.nativeEvent.isComposing ? (r.preventDefault(), p(`${m},`)) : r.key === "Backspace" && !m && e.length && t(e.slice(0, -1));
384
- }, tn = (r) => {
385
- i || r.target === l.current || r.target.closest("button") || (r.preventDefault(), l.current?.focus());
386
- }, sn = [
387
- a.field,
388
- !e.length && a.empty,
389
- i && a.disabled,
390
- o && a.error
354
+ const c = C(), _ = `${c}-message`, f = M(null), [h, G] = tn(""), Z = e.length >= O, Q = (a) => {
355
+ G(a), u?.(a);
356
+ }, L = (a) => {
357
+ const m = a.split(/[\s,]+/), j = m.pop() ?? "", b = m.filter(Boolean).slice(0, Math.max(0, O - e.length));
358
+ b.length && t([...e, ...b]), Q(j);
359
+ }, Y = (a) => {
360
+ a.key === "Enter" && h && !a.nativeEvent.isComposing ? (a.preventDefault(), L(`${h},`)) : a.key === "Backspace" && !h && e.length && t(e.slice(0, -1));
361
+ }, nn = (a) => {
362
+ i || a.target === f.current || a.target.closest("button") || (a.preventDefault(), f.current?.focus());
363
+ }, en = [
364
+ l.field,
365
+ !e.length && l.empty,
366
+ i && l.disabled,
367
+ o && l.error
391
368
  ].filter(Boolean).join(" ");
392
- return /* @__PURE__ */ _("div", { children: [
393
- /* @__PURE__ */ _("div", { className: sn, onMouseDown: tn, children: [
394
- /* @__PURE__ */ _("div", { className: a.content, children: [
395
- /* @__PURE__ */ s("label", { htmlFor: d, className: a.label, children: n }),
396
- /* @__PURE__ */ s("div", { className: a.reveal, children: /* @__PURE__ */ _("div", { className: a.tags, children: [
397
- e.length > 0 && /* @__PURE__ */ s("ul", { role: "list", className: a.chips, children: e.map((r, h) => /* @__PURE__ */ s(
398
- he,
369
+ return /* @__PURE__ */ d("div", { children: [
370
+ /* @__PURE__ */ d("div", { className: en, onMouseDown: nn, children: [
371
+ /* @__PURE__ */ d("div", { className: l.content, children: [
372
+ /* @__PURE__ */ s("label", { htmlFor: c, className: l.label, children: n }),
373
+ /* @__PURE__ */ s("div", { className: l.reveal, children: /* @__PURE__ */ d("div", { className: l.tags, children: [
374
+ e.length > 0 && /* @__PURE__ */ s("ul", { role: "list", className: l.chips, children: e.map((a, m) => /* @__PURE__ */ s(
375
+ ye,
399
376
  {
400
- invalid: c?.(r, h) ?? !1,
377
+ invalid: r?.(a, m) ?? !1,
401
378
  onRemove: i ? void 0 : () => {
402
- t(e.filter((B, w) => w !== h)), h === e.length - 1 && l.current?.focus();
379
+ t(e.filter((j, b) => b !== m)), m === e.length - 1 && f.current?.focus();
403
380
  },
404
- children: r
381
+ children: a
405
382
  },
406
- h
383
+ m
407
384
  )) }),
408
385
  /* @__PURE__ */ s(
409
386
  "input",
410
387
  {
411
- ref: l,
412
- id: d,
413
- className: a.input,
388
+ ref: f,
389
+ id: c,
390
+ className: l.input,
414
391
  size: 1,
415
- value: m,
392
+ value: h,
416
393
  disabled: i,
417
- readOnly: g,
394
+ readOnly: Z,
418
395
  "aria-invalid": o ? !0 : void 0,
419
- "aria-describedby": o ? f : void 0,
420
- onChange: (r) => {
421
- p(r.target.value);
396
+ "aria-describedby": o ? _ : void 0,
397
+ onChange: (a) => {
398
+ L(a.target.value);
422
399
  },
423
- onKeyDown: D,
400
+ onKeyDown: Y,
424
401
  onBlur: () => {
425
- p(`${m},`);
402
+ L(`${h},`);
426
403
  }
427
404
  }
428
405
  )
429
406
  ] }) })
430
407
  ] }),
431
- /* @__PURE__ */ s("div", { className: a.reveal, children: /* @__PURE__ */ _("p", { className: a.counter, children: [
408
+ /* @__PURE__ */ s("div", { className: l.reveal, children: /* @__PURE__ */ d("p", { className: l.counter, children: [
432
409
  e.length,
433
410
  " / ",
434
- x
411
+ O
435
412
  ] }) })
436
413
  ] }),
437
- /* @__PURE__ */ s("p", { id: f, className: a.message, "aria-live": "polite", children: o })
414
+ /* @__PURE__ */ s("p", { id: _, className: l.message, "aria-live": "polite", children: o })
438
415
  ] });
439
416
  }
440
- const ye = "_field_otub4_1", ve = "_label_otub4_16", be = "_reveal_otub4_27", Ne = "_input_otub4_37", ge = "_empty_otub4_56", b = {
441
- field: ye,
442
- label: ve,
443
- reveal: be,
444
- input: Ne,
445
- empty: ge
417
+ const ve = "_field_otub4_1", be = "_label_otub4_16", Ne = "_reveal_otub4_27", ge = "_input_otub4_37", $e = "_empty_otub4_56", y = {
418
+ field: ve,
419
+ label: be,
420
+ reveal: Ne,
421
+ input: ge,
422
+ empty: $e
446
423
  };
447
- function Be({ label: n, value: e, onChange: t }) {
448
- const i = I(), c = z(null), u = (o) => {
449
- o.target !== c.current && (o.preventDefault(), c.current?.focus());
424
+ function Ee({ label: n, value: e, onChange: t }) {
425
+ const i = C(), r = M(null), u = (o) => {
426
+ o.target !== r.current && (o.preventDefault(), r.current?.focus());
450
427
  };
451
- return /* @__PURE__ */ _(
428
+ return /* @__PURE__ */ d(
452
429
  "div",
453
430
  {
454
- className: [b.field, !e && b.empty].filter(Boolean).join(" "),
431
+ className: [y.field, !e && y.empty].filter(Boolean).join(" "),
455
432
  onMouseDown: u,
456
433
  children: [
457
- /* @__PURE__ */ s("label", { htmlFor: i, className: b.label, children: n }),
458
- /* @__PURE__ */ s("div", { className: b.reveal, children: /* @__PURE__ */ s("div", { children: /* @__PURE__ */ s(
434
+ /* @__PURE__ */ s("label", { htmlFor: i, className: y.label, children: n }),
435
+ /* @__PURE__ */ s("div", { className: y.reveal, children: /* @__PURE__ */ s("div", { children: /* @__PURE__ */ s(
459
436
  "input",
460
437
  {
461
- ref: c,
438
+ ref: r,
462
439
  id: i,
463
- className: b.input,
440
+ className: y.input,
464
441
  value: e,
465
442
  onChange: (o) => {
466
443
  t(o.target.value);
@@ -472,19 +449,19 @@ function Be({ label: n, value: e, onChange: t }) {
472
449
  );
473
450
  }
474
451
  export {
475
- xe as Button,
476
- cn as H1,
477
- Le as H2,
478
- Se as Hero,
479
- xn as Link,
480
- Te as LinkProvider,
481
- J as ListItem,
482
- De as MultitagField,
483
- ke as Paragraph,
484
- Ce as SideNav,
485
- je as SideNavLink,
486
- Ie as TableOfContents,
487
- en as TableOfContentsLink,
488
- Be as TextField,
489
- Oe as UnorderedList
452
+ Ce as Button,
453
+ rn as H1,
454
+ ke as H2,
455
+ De as Hero,
456
+ Cn as Link,
457
+ xe as LinkProvider,
458
+ H as ListItem,
459
+ Be as MultitagField,
460
+ Oe as Paragraph,
461
+ je as SideNav,
462
+ Ie as SideNavLink,
463
+ Se as TableOfContents,
464
+ q as TableOfContentsLink,
465
+ Ee as TextField,
466
+ Te as UnorderedList
490
467
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartyweb/ui",
3
- "version": "2.6.0-irina-button-review.gea26df8",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",