@skdx/react 0.30.0 → 0.31.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.
- package/dist/accordion/Accordion.cjs +1 -1
- package/dist/accordion/Accordion.js +1 -1
- package/dist/autocomplete/Autocomplete.cjs +1 -1
- package/dist/autocomplete/Autocomplete.js +1 -1
- package/dist/avatar/Avatar.cjs +1 -1
- package/dist/avatar/Avatar.d.cts +1 -1
- package/dist/avatar/Avatar.d.ts +1 -1
- package/dist/avatar/Avatar.js +1 -1
- package/dist/backdrop/Backdrop.cjs +2 -0
- package/dist/backdrop/Backdrop.d.cts +9 -0
- package/dist/backdrop/Backdrop.d.ts +9 -0
- package/dist/backdrop/Backdrop.js +2 -0
- package/dist/backdrop/index.d.cts +2 -0
- package/dist/backdrop/index.d.ts +2 -0
- package/dist/backdrop/types.d.cts +3 -0
- package/dist/backdrop/types.d.ts +3 -0
- package/dist/button/Button.cjs +1 -1
- package/dist/button/Button.js +1 -1
- package/dist/checkbox-card/CheckboxCard.cjs +1 -1
- package/dist/checkbox-card/CheckboxCard.js +1 -1
- package/dist/checkbox-group/CheckboxGroup.cjs +1 -1
- package/dist/checkbox-group/CheckboxGroup.js +1 -1
- package/dist/checkbox-group/CheckboxGroupAnatomy.d.cts +10 -1
- package/dist/checkbox-group/CheckboxGroupAnatomy.d.ts +10 -1
- package/dist/checkbox-group/CheckboxGroupItem.d.cts +2 -1
- package/dist/checkbox-group/CheckboxGroupItem.d.ts +2 -1
- package/dist/checkbox-group/CheckboxGroupSelectAll.d.cts +3 -2
- package/dist/checkbox-group/CheckboxGroupSelectAll.d.ts +3 -2
- package/dist/chip/Chip.cjs +2 -0
- package/dist/chip/Chip.d.cts +9 -0
- package/dist/chip/Chip.d.ts +9 -0
- package/dist/chip/Chip.js +2 -0
- package/dist/chip/index.d.cts +2 -0
- package/dist/chip/index.d.ts +2 -0
- package/dist/chip/types.d.cts +3 -0
- package/dist/chip/types.d.ts +3 -0
- package/dist/color-picker/ColorPicker.cjs +1 -1
- package/dist/color-picker/ColorPicker.js +1 -1
- package/dist/combobox/Combobox.cjs +1 -1
- package/dist/combobox/Combobox.js +1 -1
- package/dist/date-picker/DatePicker.cjs +1 -1
- package/dist/date-picker/DatePicker.js +1 -1
- package/dist/date-picker/DatePickerTimeField.d.cts +1 -1
- package/dist/date-picker/DatePickerTimeField.d.ts +1 -1
- package/dist/date-range-picker/DateRangePicker.cjs +2 -0
- package/dist/date-range-picker/DateRangePicker.d.cts +9 -0
- package/dist/date-range-picker/DateRangePicker.d.ts +9 -0
- package/dist/date-range-picker/DateRangePicker.js +2 -0
- package/dist/date-range-picker/index.d.cts +2 -0
- package/dist/date-range-picker/index.d.ts +2 -0
- package/dist/date-range-picker/types.d.cts +3 -0
- package/dist/date-range-picker/types.d.ts +3 -0
- package/dist/date-time-picker/DateTimePicker.cjs +2 -0
- package/dist/date-time-picker/DateTimePicker.d.cts +9 -0
- package/dist/date-time-picker/DateTimePicker.d.ts +9 -0
- package/dist/date-time-picker/DateTimePicker.js +2 -0
- package/dist/date-time-picker/index.d.cts +2 -0
- package/dist/date-time-picker/index.d.ts +2 -0
- package/dist/date-time-picker/types.d.cts +3 -0
- package/dist/date-time-picker/types.d.ts +3 -0
- package/dist/dialog/Dialog.cjs +1 -1
- package/dist/dialog/Dialog.js +1 -1
- package/dist/dialog/Dialogs.d.cts +24 -0
- package/dist/dialog/Dialogs.d.ts +24 -0
- package/dist/dialog/index.d.cts +2 -1
- package/dist/dialog/index.d.ts +2 -1
- package/dist/dialog/types.d.cts +6 -0
- package/dist/dialog/types.d.ts +6 -0
- package/dist/fab/Fab.cjs +2 -0
- package/dist/fab/Fab.d.cts +9 -0
- package/dist/fab/Fab.d.ts +9 -0
- package/dist/fab/Fab.js +2 -0
- package/dist/fab/index.d.cts +2 -0
- package/dist/fab/index.d.ts +2 -0
- package/dist/fab/types.d.cts +3 -0
- package/dist/fab/types.d.ts +3 -0
- package/dist/field/Field.cjs +1 -1
- package/dist/field/Field.js +1 -1
- package/dist/floating-panel/FloatingPanel.cjs +1 -1
- package/dist/floating-panel/FloatingPanel.js +1 -1
- package/dist/floating-panel/types.d.cts +4 -0
- package/dist/floating-panel/types.d.ts +4 -0
- package/dist/gauge/Gauge.cjs +2 -0
- package/dist/gauge/Gauge.d.cts +9 -0
- package/dist/gauge/Gauge.d.ts +9 -0
- package/dist/gauge/Gauge.js +2 -0
- package/dist/gauge/index.d.cts +2 -0
- package/dist/gauge/index.d.ts +2 -0
- package/dist/gauge/types.d.cts +3 -0
- package/dist/gauge/types.d.ts +3 -0
- package/dist/grid/Grid.cjs +2 -0
- package/dist/grid/Grid.d.cts +9 -0
- package/dist/grid/Grid.d.ts +9 -0
- package/dist/grid/Grid.js +2 -0
- package/dist/grid/index.d.cts +2 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/grid/types.d.cts +3 -0
- package/dist/grid/types.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +1 -1
- package/dist/link/Link.cjs +1 -1
- package/dist/link/Link.js +1 -1
- package/dist/listbox/Listbox.cjs +1 -1
- package/dist/listbox/Listbox.js +1 -1
- package/dist/paper/Paper.cjs +2 -0
- package/dist/paper/Paper.d.cts +9 -0
- package/dist/paper/Paper.d.ts +9 -0
- package/dist/paper/Paper.js +2 -0
- package/dist/paper/index.d.cts +2 -0
- package/dist/paper/index.d.ts +2 -0
- package/dist/paper/types.d.cts +3 -0
- package/dist/paper/types.d.ts +3 -0
- package/dist/password-input/types.d.cts +6 -2
- package/dist/password-input/types.d.ts +6 -2
- package/dist/primitives/table.cjs +1 -1
- package/dist/primitives/table.js +1 -1
- package/dist/scroll-area/ScrollArea.cjs +1 -1
- package/dist/scroll-area/ScrollArea.js +1 -1
- package/dist/speed-dial/SpeedDial.cjs +1 -1
- package/dist/speed-dial/SpeedDial.d.cts +1 -1
- package/dist/speed-dial/SpeedDial.d.ts +1 -1
- package/dist/speed-dial/SpeedDial.js +1 -1
- package/dist/speed-dial/SpeedDialAnatomy.d.cts +2 -1
- package/dist/speed-dial/SpeedDialAnatomy.d.ts +2 -1
- package/dist/speed-dial/types.d.cts +5 -0
- package/dist/speed-dial/types.d.ts +5 -0
- package/dist/stack/Stack.cjs +2 -0
- package/dist/stack/Stack.d.cts +9 -0
- package/dist/stack/Stack.d.ts +9 -0
- package/dist/stack/Stack.js +2 -0
- package/dist/stack/index.d.cts +2 -0
- package/dist/stack/index.d.ts +2 -0
- package/dist/stack/types.d.cts +3 -0
- package/dist/stack/types.d.ts +3 -0
- package/dist/table/Table.cjs +1 -1
- package/dist/table/Table.d.cts +2 -2
- package/dist/table/Table.d.ts +2 -2
- package/dist/table/Table.js +1 -1
- package/dist/table/TableAnatomy.d.cts +2 -1
- package/dist/table/TableAnatomy.d.ts +2 -1
- package/dist/table/TableColumnHeaderFilterInput.d.cts +18 -0
- package/dist/table/TableColumnHeaderFilterInput.d.ts +18 -0
- package/dist/table/TableHeaderCell.d.cts +1 -1
- package/dist/table/TableHeaderCell.d.ts +1 -1
- package/dist/table/index.d.cts +1 -1
- package/dist/table/index.d.ts +1 -1
- package/dist/table/primitives.d.cts +2 -1
- package/dist/table/primitives.d.ts +2 -1
- package/dist/table/types.d.cts +52 -0
- package/dist/table/types.d.ts +52 -0
- package/dist/table/useTableFilter.d.cts +3 -0
- package/dist/table/useTableFilter.d.ts +3 -0
- package/dist/time/Time.cjs +1 -1
- package/dist/time/Time.d.cts +1 -1
- package/dist/time/Time.d.ts +1 -1
- package/dist/time/Time.js +1 -1
- package/dist/timeline/Timeline.cjs +1 -1
- package/dist/timeline/Timeline.d.cts +1 -1
- package/dist/timeline/Timeline.d.ts +1 -1
- package/dist/timeline/Timeline.js +1 -1
- package/dist/tooltip/Tooltip.cjs +2 -0
- package/dist/tooltip/Tooltip.d.cts +16 -0
- package/dist/tooltip/Tooltip.d.ts +16 -0
- package/dist/tooltip/Tooltip.js +2 -0
- package/dist/tooltip/index.d.cts +2 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/types.d.cts +3 -0
- package/dist/tooltip/types.d.ts +3 -0
- package/dist/utils/csv.cjs +3 -0
- package/dist/utils/csv.d.cts +43 -0
- package/dist/utils/csv.d.ts +43 -0
- package/dist/utils/csv.js +3 -0
- package/dist/utils/dialogs.cjs +2 -0
- package/dist/utils/dialogs.d.cts +96 -0
- package/dist/utils/dialogs.d.ts +96 -0
- package/dist/utils/dialogs.js +2 -0
- package/dist/utils/dismissal.cjs +1 -1
- package/dist/utils/dismissal.d.cts +7 -0
- package/dist/utils/dismissal.d.ts +7 -0
- package/dist/utils/dismissal.js +1 -1
- package/dist/utils/field-core.cjs +1 -1
- package/dist/utils/field-core.d.cts +2 -0
- package/dist/utils/field-core.d.ts +2 -0
- package/dist/utils/field-core.js +1 -1
- package/dist/utils/media-query.cjs +2 -0
- package/dist/utils/media-query.d.cts +7 -0
- package/dist/utils/media-query.d.ts +7 -0
- package/dist/utils/media-query.js +2 -0
- package/dist/utils/useDismiss.cjs +1 -1
- package/dist/utils/useDismiss.js +1 -1
- package/dist/utils/useMediaQuery.cjs +2 -0
- package/dist/utils/useMediaQuery.d.cts +10 -0
- package/dist/utils/useMediaQuery.d.ts +10 -0
- package/dist/utils/useMediaQuery.js +2 -0
- package/package.json +102 -2
|
@@ -46,6 +46,8 @@ export interface FieldCharacterCountOptions {
|
|
|
46
46
|
export declare function characterCountMessage(remaining: number): string;
|
|
47
47
|
/** Whether a count has passed its threshold and should be rendered/announced. */
|
|
48
48
|
export declare function characterCountVisible(count: number, maxLength: number, threshold?: number): boolean;
|
|
49
|
+
/** Joins a Field's messages into one string, separated by a period unless a message already ends in sentence punctuation. */
|
|
50
|
+
export declare function joinFieldMessages(messages: string[]): string;
|
|
49
51
|
/** Fallback message when native constraint validation has no `validationMessage`. */
|
|
50
52
|
export declare const NATIVE_INVALID_FALLBACK_MESSAGE = "This field is invalid.";
|
|
51
53
|
/** Marks an element as this Field's control, an escape hatch for composites in shadow DOM. */
|
package/dist/utils/field-core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var C="validity-change",a="data-skdx-field",u="data-skdx-field-name",p="data-skdx-field-message",F="data-skdx-field-description",I="data-skdx-field-error",$="data-skdx-field-character-count",E="data-skdx-field-pending",c="data-skdx-field-resubmit",m="data-skdx-form-field",_="data-skdx-form-message",G=["validity-change","invalid","change","blur"],D="data-skdx-error-summary",j=1e3;function M(i){let e=Math.abs(i),t=e===1?"character":"characters";return i<0?`You have ${e} ${t} too many`:`You have ${e} ${t} remaining`}function V(i,e,t=0){return t<=0?!0:i>=e*t/100}var O="This field is invalid.",w="data-skdx-field-control",x=[`[${w}]`,'input:not([type="hidden"])',"select","textarea",'[role="textbox"]','[role="searchbox"]','[role="combobox"]','[role="listbox"]','[role="radiogroup"]','[role="group"]','[role="slider"]','[role="spinbutton"]','[role="checkbox"]','[role="radio"]','[role="switch"]'].join(", "),Y="data-skdx-field-required-indicator",k=new Set(["INPUT","SELECT","TEXTAREA"]),R=new Set(["radiogroup","group"]),B=['input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function T(i){return i==null?[]:(Array.isArray(i)?i:[i]).filter(t=>typeof t=="string"&&t.trim()!=="")}function S(i){for(let e of Array.from(i.querySelectorAll(x)))if(e.getAttribute("aria-hidden")!=="true"&&e.closest(`[${a}]`)===i)return e;return null}function f(i,e){return v(i,a,e)}function v(i,e,t){for(let r of Array.from(i.querySelectorAll(t)))if(r.closest(`[${e}]`)===i)return r;return null}function P(i){if(!i)return;let e=i;return e.type==="checkbox"||e.type==="radio"?e.checked:"value"in i?e.value:i.querySelector('input[aria-hidden="true"]')?.value}function d(i){return i==null||i===!1||i===""?!1:!(Array.isArray(i)&&i.length===0)}function o(i,e,t){t?i.setAttribute(e,""):i.removeAttribute(e)}function y(i,...e){let t=i.split(/\s+/).filter(Boolean);for(let r of e)r&&!t.includes(r)&&t.push(r);return t.join(" ")}function z(i){return i.closest("form, skdx-form")??i.parentElement??i}function N(i){let e=S(i),r=f(i,`[${I}]`)?.textContent?.trim()||i.getAttribute(p)||i.getAttribute(u)||"";return!e?.id||!r?[]:[{id:e.id,message:r}]}function H(i){let e=v(i,m,x);if(!e?.id||e.getAttribute("aria-invalid")!=="true")return[];let r=v(i,m,`[${_}]:not([hidden])`)?.textContent?.trim()||i.getAttribute(u)||"";return r?[{id:e.id,message:r}]:[]}function K(i){return Array.from(i.querySelectorAll(`[${a}][data-invalid], [${m}]`)).flatMap(t=>(t.hasAttribute(a)?N:H)(t))}var b="__skdxFieldCheckValidity",g="__skdxFieldReset";async function Q(i){let e=Array.from(i.querySelectorAll(`[${a}]`));return(await Promise.all(e.map(r=>r[b]?.()??Promise.resolve(!0)))).every(Boolean)}function X(i){for(let e of Array.from(i.querySelectorAll(`[${a}]`)))e[g]?.()}function J(i,e=document){let t=e.getElementById(i);if(!t)return;let r=t.getAttribute("role"),s=(t.tagName==="FIELDSET"||r!==null&&R.has(r)?t.querySelector(B):null)??t;s.focus(),s.scrollIntoView?.({block:"center"})}var A=class{constructor(e){this.options=e;this.props={};this.root=null;this.form=null;this.control=null;this.baseDescribedBy="";this.baseLabelledBy="";this.wroteLabelledBy=!1;this.wroteRequired=!1;this.wroteDisabled=!1;this.wroteGroupDisabled=!1;this.runToken=0;this.pending=!1;this.injected=[];this.custom=[];this.characterCount=null;this.awaitingSubmit=!1;this.handleInput=()=>{let e=this.isOverLimit(this.snapshot.count),t=this.readCount();this.update({dirty:!0,filled:d(this.resolveValue()),count:t,errors:this.composeErrors(t)}),this.scheduleCountAnnouncement(t,e),(this.props.mode==="change"||this.snapshot.errors.length>0)&&this.scheduleValidation()};this.handleFocusOut=()=>{let e=this.readCount();this.update({touched:!0,filled:d(this.resolveValue()),count:e,errors:this.composeErrors(e)});let t=this.validationTimer!==void 0;clearTimeout(this.validationTimer),this.validationTimer=void 0;let r=this.props.mode??"blur";(t||r==="blur"||this.snapshot.errors.length>0)&&this.runValidation()};this.handleSubmit=e=>{if(!this.form)return;let t=e.target;if(t!==this.form&&t?.closest?.("form")!==this.form||this.isEngineResubmit(e))return;this.markTouched();let r=this.runValidation({silent:this.hasErrorSummary()});if(L(r)){e.preventDefault(),this.awaitingSubmit=!0,Promise.resolve(r).then(()=>{this.awaitingSubmit&&(this.awaitingSubmit=!1,this.resubmitIfSettled())});return}(r.length>0||this.pending)&&e.preventDefault()};this.snapshot={controlId:"",errors:[],valid:!0,touched:!1,dirty:!1,filled:!1,count:0,validity:null}}get state(){return this.snapshot}setProps(e){let t=this.props.value;this.props=e;let r=T(e.errors??null),n=!q(this.injected,r);n&&(this.injected=r);let s=e.value!==t;if(!n&&!s)return;let l=this.readCount();this.update({count:l,filled:d(this.resolveValue()),errors:this.composeErrors(l)})}setCharacterCount(e){if((this.characterCount?.maxLength??null)===(e?.maxLength??null)&&(this.characterCount?.threshold??0)===(e?.threshold??0))return;this.characterCount=e;let r=this.readCount();this.update({count:r,errors:this.composeErrors(r)})}readCount(){let e=this.resolveValue();return typeof e=="string"?e.length:0}countMessage(e){return(this.props.getCharacterCountMessage??M)(e)}isOverLimit(e){return this.characterCount!==null&&e>this.characterCount.maxLength}composeErrors(e=this.snapshot.count){let t=[...this.injected,...this.custom];return this.characterCount&&this.isOverLimit(e)&&t.push(this.countMessage(this.characterCount.maxLength-e)),t}scheduleCountAnnouncement(e,t){let r=this.characterCount;if(!r)return;if(clearTimeout(this.announceTimer),this.isOverLimit(e)){t||this.options.announce(this.countMessage(r.maxLength-e),"assertive");return}if(!V(e,r.maxLength,r.threshold))return;let n=r.maxLength-e;this.announceTimer=setTimeout(()=>{this.options.announce(this.countMessage(n),"polite")},1e3)}connect(e){this.root=e,e.setAttribute(a,""),Object.defineProperty(e,b,{value:()=>this.validate(),configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(e,g,{value:()=>this.reset(),configurable:!0,enumerable:!1,writable:!0}),e.addEventListener("input",this.handleInput,!0),e.addEventListener("change",this.handleInput,!0),e.addEventListener("focusout",this.handleFocusOut,!0),this.form=e.closest("form"),this.form&&e.ownerDocument.addEventListener("submit",this.handleSubmit,!0),this.sync();let t=this.readCount();this.update({filled:d(this.resolveValue()),count:t,errors:this.composeErrors(t)})}disconnect(){clearTimeout(this.announceTimer),clearTimeout(this.validationTimer),this.validationTimer=void 0,this.awaitingSubmit=!1;let e=this.root;e&&(e.removeEventListener("input",this.handleInput,!0),e.removeEventListener("change",this.handleInput,!0),e.removeEventListener("focusout",this.handleFocusOut,!0),this.form&&e.ownerDocument.removeEventListener("submit",this.handleSubmit,!0),delete e[b],delete e[g],this.root=null,this.form=null,this.control=null)}sync(){let e=this.root;if(!e)return;let t=S(e);t!==this.control&&(this.control=t,this.baseDescribedBy=t?.getAttribute("aria-describedby")??"",this.baseLabelledBy=t?.getAttribute("aria-labelledby")??"",this.wroteLabelledBy=!1,this.wroteRequired=!1,this.wroteDisabled=!1,this.wroteGroupDisabled=!1);let{name:r}=this.props;r?e.setAttribute(u,r):e.removeAttribute(u);let n=this.snapshot.errors.join(" ");n?e.setAttribute(p,n):e.removeAttribute(p),this.applyStateAttributes(e),t&&(t.id||(t.id=this.options.controlId),t.id!==this.snapshot.controlId&&(this.snapshot={...this.snapshot,controlId:t.id,validity:this.readValidity()},this.options.onSnapshotChange(this.snapshot)),this.applyDescribedBy(e,t),this.snapshot.errors.length>0?t.setAttribute("aria-invalid","true"):t.removeAttribute("aria-invalid"),this.applyLabelledBy(e,t),this.applyConstraintState(t),this.applyStateAttributes(t))}applyDescribedBy(e,t){let r=f(e,`[${F}]`)!==null,n=f(e,`[${I}]`)!==null,s=y(this.baseDescribedBy,r?this.options.descriptionId:void 0,n?this.options.errorId:void 0);s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby")}applyLabelledBy(e,t){let r=e.ownerDocument.getElementById(this.options.labelId)!==null;this.options.grouped&&r?(t.setAttribute("aria-labelledby",y(this.baseLabelledBy,this.options.labelId)),this.wroteLabelledBy=!0):this.wroteLabelledBy&&(this.baseLabelledBy?t.setAttribute("aria-labelledby",this.baseLabelledBy):t.removeAttribute("aria-labelledby"),this.wroteLabelledBy=!1)}applyConstraintState(e){let t=k.has(e.tagName),r=this.props.required===!0,n=this.props.disabled===!0;r?(t?e.setAttribute("required",""):e.setAttribute("aria-required","true"),this.wroteRequired=!0):this.wroteRequired&&(e.removeAttribute(t?"required":"aria-required"),this.wroteRequired=!1),n?(t?e.setAttribute("disabled",""):e.setAttribute("aria-disabled","true"),this.wroteDisabled=!0):this.wroteDisabled&&(e.removeAttribute(t?"disabled":"aria-disabled"),this.wroteDisabled=!1),t||this.applyGroupDisabled(e,n)}applyGroupDisabled(e,t){let r=e.getAttribute("role");if(!(!(e.tagName==="FIELDSET"||r!==null&&R.has(r))||!t&&!this.wroteGroupDisabled)){for(let s of e.querySelectorAll("input, select, textarea, button"))t?s.setAttribute("disabled",""):s.removeAttribute("disabled");this.wroteGroupDisabled=t}}validate(){return Promise.resolve(this.runValidation()).then(e=>e.length===0)}reset(){this.injected=[],this.custom=[],this.pending=!1,this.awaitingSubmit=!1,this.runToken++,clearTimeout(this.announceTimer),clearTimeout(this.validationTimer),this.validationTimer=void 0,this.markPending(!1);let e=this.readCount();this.update({touched:!1,dirty:!1,count:e,filled:d(this.resolveValue()),errors:this.composeErrors(e)}),this.sync()}markTouched(){this.snapshot.touched||this.update({touched:!0})}applyStateAttributes(e){let{errors:t,touched:r,dirty:n,filled:s,count:l}=this.snapshot;o(e,"data-invalid",t.length>0),o(e,"data-valid",t.length===0),o(e,"data-touched",r),o(e,"data-dirty",n),o(e,"data-filled",s),o(e,"data-over-limit",this.isOverLimit(l)),o(e,"data-disabled",this.props.disabled===!0)}resolveValue(){return this.props.value!==void 0?this.props.value:P(this.control)}readValidity(){return this.control?.validity??null}markPending(e){this.root&&o(this.root,E,e)}nativeMessage(){let e=this.control;return!e?.validity||e.validity.valid?null:e.validationMessage||this.props.invalidMessage||O}runValidation(e={}){let t=++this.runToken,r=this.props.validate?.(this.resolveValue());return L(r)?(this.pending=!0,this.markPending(!0),Promise.resolve(r).then(n=>t!==this.runToken?this.snapshot.errors:(this.pending=!1,this.markPending(!1),this.commit(n,e)))):this.commit(r,e)}commit(e,t){if(this.custom=T(e),this.custom.length===0){let h=this.nativeMessage();h&&!this.injected.includes(h)&&(this.custom=[h])}let r=this.readCount(),n=this.composeErrors(r),s=this.snapshot.errors.length===0;this.update({errors:n,count:r,filled:d(this.resolveValue())});let l=n[0];return l&&s&&!t.silent&&this.options.announce(l,"assertive"),n}update(e){let t={...this.snapshot,...e,valid:!0,validity:this.readValidity()};t.valid=t.errors.length===0,!U(this.snapshot,t)&&(this.snapshot=t,this.sync(),this.options.onSnapshotChange(t),this.root?.dispatchEvent(new CustomEvent(C,{bubbles:!0,composed:!0,detail:{valid:t.valid,errors:t.errors,touched:t.touched,dirty:t.dirty,filled:t.filled,count:t.count,validity:t.validity}})))}scheduleValidation(){clearTimeout(this.validationTimer),this.validationTimer=void 0;let e=this.props.mode==="change"?this.props.validationDebounceTime??0:0;if(e<=0){this.runValidation();return}this.validationTimer=setTimeout(()=>{this.validationTimer=void 0,this.runValidation()},e)}hasErrorSummary(){return this.form?.querySelector(`[${D}]`)!=null}isEngineResubmit(e){return this.form?.hasAttribute(c)?(this.snapshot.errors.length>0&&e.preventDefault(),!0):!1}resubmitIfSettled(){let e=this.form;if(!(!e||typeof e.requestSubmit!="function")&&!e.querySelector(`[${E}]`)&&!e.querySelector(`[${a}][data-invalid]`)){e.setAttribute(c,"");try{e.requestSubmit()}finally{e.removeAttribute(c)}}}};function L(i){return typeof i?.then=="function"}function q(i,e){return i.length===e.length&&i.every((t,r)=>t===e[r])}function U(i,e){return i.controlId===e.controlId&&i.valid===e.valid&&i.touched===e.touched&&i.dirty===e.dirty&&i.filled===e.filled&&i.count===e.count&&i.validity===e.validity&&i.errors.length===e.errors.length&&i.errors.every((t,r)=>t===e.errors[r])}export{j as CHARACTER_COUNT_ANNOUNCE_DELAY_MS,G as ERROR_SUMMARY_RESCAN_EVENTS,$ as FIELD_CHARACTER_COUNT_ATTRIBUTE,w as FIELD_CONTROL_ATTRIBUTE,x as FIELD_CONTROL_SELECTOR,F as FIELD_DESCRIPTION_ATTRIBUTE,I as FIELD_ERROR_ATTRIBUTE,D as FIELD_ERROR_SUMMARY_ATTRIBUTE,p as FIELD_MESSAGE_ATTRIBUTE,u as FIELD_NAME_ATTRIBUTE,E as FIELD_PENDING_ATTRIBUTE,Y as FIELD_REQUIRED_INDICATOR_ATTRIBUTE,c as FIELD_RESUBMIT_ATTRIBUTE,a as FIELD_ROOT_ATTRIBUTE,C as FIELD_VALIDITY_CHANGE_EVENT,m as FORM_FIELD_ATTRIBUTE,_ as FORM_MESSAGE_ATTRIBUTE,A as FieldController,O as NATIVE_INVALID_FALLBACK_MESSAGE,M as characterCountMessage,V as characterCountVisible,K as collectFieldErrors,z as errorSummaryScope,S as findFieldControl,J as focusFieldTarget,d as isFilled,T as normalizeMessages,P as readControlValue,X as resetFields,Q as validateFields};
|
|
2
|
+
var C="validity-change",a="data-skdx-field",u="data-skdx-field-name",p="data-skdx-field-message",F="data-skdx-field-description",x="data-skdx-field-error",$="data-skdx-field-character-count",E="data-skdx-field-pending",c="data-skdx-field-resubmit",f="data-skdx-form-field",_="data-skdx-form-message",G=["validity-change","invalid","change","blur"],D="data-skdx-error-summary",j=1e3;function M(i){let e=Math.abs(i),t=e===1?"character":"characters";return i<0?`You have ${e} ${t} too many`:`You have ${e} ${t} remaining`}function V(i,e,t=0){return t<=0?!0:i>=e*t/100}function Y(i){return i.map((e,t)=>t===i.length-1||/[.!?]$/.test(e)?e:`${e}.`).join(" ")}var O="This field is invalid.",w="data-skdx-field-control",I=[`[${w}]`,'input:not([type="hidden"])',"select","textarea",'[role="textbox"]','[role="searchbox"]','[role="combobox"]','[role="listbox"]','[role="radiogroup"]','[role="group"]','[role="slider"]','[role="spinbutton"]','[role="checkbox"]','[role="radio"]','[role="switch"]'].join(", "),z="data-skdx-field-required-indicator",k=new Set(["INPUT","SELECT","TEXTAREA"]),R=new Set(["radiogroup","group"]),B=['input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function T(i){return i==null?[]:(Array.isArray(i)?i:[i]).filter(t=>typeof t=="string"&&t.trim()!=="")}function S(i){for(let e of Array.from(i.querySelectorAll(I)))if(e.getAttribute("aria-hidden")!=="true"&&e.closest(`[${a}]`)===i)return e;return null}function m(i,e){return v(i,a,e)}function v(i,e,t){for(let r of Array.from(i.querySelectorAll(t)))if(r.closest(`[${e}]`)===i)return r;return null}function P(i){if(!i)return;let e=i;return e.type==="checkbox"||e.type==="radio"?e.checked:"value"in i?e.value:i.querySelector('input[aria-hidden="true"]')?.value}function d(i){return i==null||i===!1||i===""?!1:!(Array.isArray(i)&&i.length===0)}function o(i,e,t){t?i.setAttribute(e,""):i.removeAttribute(e)}function y(i,...e){let t=i.split(/\s+/).filter(Boolean);for(let r of e)r&&!t.includes(r)&&t.push(r);return t.join(" ")}function K(i){return i.closest("form, skdx-form")??i.parentElement??i}function N(i){let e=S(i),r=m(i,`[${x}]`)?.textContent?.trim()||i.getAttribute(p)||i.getAttribute(u)||"";return!e?.id||!r?[]:[{id:e.id,message:r}]}function H(i){let e=v(i,f,I);if(!e?.id||e.getAttribute("aria-invalid")!=="true")return[];let r=v(i,f,`[${_}]:not([hidden])`)?.textContent?.trim()||i.getAttribute(u)||"";return r?[{id:e.id,message:r}]:[]}function Q(i){return Array.from(i.querySelectorAll(`[${a}][data-invalid], [${f}]`)).flatMap(t=>(t.hasAttribute(a)?N:H)(t))}var b="__skdxFieldCheckValidity",g="__skdxFieldReset";async function X(i){let e=Array.from(i.querySelectorAll(`[${a}]`));return(await Promise.all(e.map(r=>r[b]?.()??Promise.resolve(!0)))).every(Boolean)}function J(i){for(let e of Array.from(i.querySelectorAll(`[${a}]`)))e[g]?.()}function W(i,e=document){let t=e.getElementById(i);if(!t)return;let r=t.getAttribute("role"),s=(t.tagName==="FIELDSET"||r!==null&&R.has(r)?t.querySelector(B):null)??t;s.focus(),s.scrollIntoView?.({block:"center"})}var A=class{constructor(e){this.options=e;this.props={};this.root=null;this.form=null;this.control=null;this.baseDescribedBy="";this.baseLabelledBy="";this.wroteLabelledBy=!1;this.wroteRequired=!1;this.wroteDisabled=!1;this.wroteGroupDisabled=!1;this.runToken=0;this.pending=!1;this.injected=[];this.custom=[];this.characterCount=null;this.awaitingSubmit=!1;this.handleInput=()=>{let e=this.isOverLimit(this.snapshot.count),t=this.readCount();this.update({dirty:!0,filled:d(this.resolveValue()),count:t,errors:this.composeErrors(t)}),this.scheduleCountAnnouncement(t,e),(this.props.mode==="change"||this.snapshot.errors.length>0)&&this.scheduleValidation()};this.handleFocusOut=()=>{let e=this.readCount();this.update({touched:!0,filled:d(this.resolveValue()),count:e,errors:this.composeErrors(e)});let t=this.validationTimer!==void 0;clearTimeout(this.validationTimer),this.validationTimer=void 0;let r=this.props.mode??"blur";(t||r==="blur"||this.snapshot.errors.length>0)&&this.runValidation()};this.handleSubmit=e=>{if(!this.form)return;let t=e.target;if(t!==this.form&&t?.closest?.("form")!==this.form||this.isEngineResubmit(e))return;this.markTouched();let r=this.runValidation({silent:this.hasErrorSummary()});if(L(r)){e.preventDefault(),this.awaitingSubmit=!0,Promise.resolve(r).then(()=>{this.awaitingSubmit&&(this.awaitingSubmit=!1,this.resubmitIfSettled())});return}(r.length>0||this.pending)&&e.preventDefault()};this.snapshot={controlId:"",errors:[],valid:!0,touched:!1,dirty:!1,filled:!1,count:0,validity:null}}get state(){return this.snapshot}setProps(e){let t=this.props.value;this.props=e;let r=T(e.errors??null),n=!q(this.injected,r);n&&(this.injected=r);let s=e.value!==t;if(!n&&!s)return;let l=this.readCount();this.update({count:l,filled:d(this.resolveValue()),errors:this.composeErrors(l)})}setCharacterCount(e){if((this.characterCount?.maxLength??null)===(e?.maxLength??null)&&(this.characterCount?.threshold??0)===(e?.threshold??0))return;this.characterCount=e;let r=this.readCount();this.update({count:r,errors:this.composeErrors(r)})}readCount(){let e=this.resolveValue();return typeof e=="string"?e.length:0}countMessage(e){return(this.props.getCharacterCountMessage??M)(e)}isOverLimit(e){return this.characterCount!==null&&e>this.characterCount.maxLength}composeErrors(e=this.snapshot.count){let t=[...this.injected,...this.custom];return this.characterCount&&this.isOverLimit(e)&&t.push(this.countMessage(this.characterCount.maxLength-e)),t}scheduleCountAnnouncement(e,t){let r=this.characterCount;if(!r)return;if(clearTimeout(this.announceTimer),this.isOverLimit(e)){t||this.options.announce(this.countMessage(r.maxLength-e),"assertive");return}if(!V(e,r.maxLength,r.threshold))return;let n=r.maxLength-e;this.announceTimer=setTimeout(()=>{this.options.announce(this.countMessage(n),"polite")},1e3)}connect(e){this.root=e,e.setAttribute(a,""),Object.defineProperty(e,b,{value:()=>this.validate(),configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(e,g,{value:()=>this.reset(),configurable:!0,enumerable:!1,writable:!0}),e.addEventListener("input",this.handleInput,!0),e.addEventListener("change",this.handleInput,!0),e.addEventListener("focusout",this.handleFocusOut,!0),this.form=e.closest("form"),this.form&&e.ownerDocument.addEventListener("submit",this.handleSubmit,!0),this.sync();let t=this.readCount();this.update({filled:d(this.resolveValue()),count:t,errors:this.composeErrors(t)})}disconnect(){clearTimeout(this.announceTimer),clearTimeout(this.validationTimer),this.validationTimer=void 0,this.awaitingSubmit=!1;let e=this.root;e&&(e.removeEventListener("input",this.handleInput,!0),e.removeEventListener("change",this.handleInput,!0),e.removeEventListener("focusout",this.handleFocusOut,!0),this.form&&e.ownerDocument.removeEventListener("submit",this.handleSubmit,!0),delete e[b],delete e[g],this.root=null,this.form=null,this.control=null)}sync(){let e=this.root;if(!e)return;let t=S(e);t!==this.control&&(this.control=t,this.baseDescribedBy=t?.getAttribute("aria-describedby")??"",this.baseLabelledBy=t?.getAttribute("aria-labelledby")??"",this.wroteLabelledBy=!1,this.wroteRequired=!1,this.wroteDisabled=!1,this.wroteGroupDisabled=!1);let{name:r}=this.props;r?e.setAttribute(u,r):e.removeAttribute(u);let n=this.snapshot.errors.join(" ");n?e.setAttribute(p,n):e.removeAttribute(p),this.applyStateAttributes(e),t&&(t.id||(t.id=this.options.controlId),t.id!==this.snapshot.controlId&&(this.snapshot={...this.snapshot,controlId:t.id,validity:this.readValidity()},this.options.onSnapshotChange(this.snapshot)),this.applyDescribedBy(e,t),this.snapshot.errors.length>0?t.setAttribute("aria-invalid","true"):t.removeAttribute("aria-invalid"),this.applyLabelledBy(e,t),this.applyConstraintState(t),this.applyStateAttributes(t))}applyDescribedBy(e,t){let r=m(e,`[${F}]`)!==null,n=m(e,`[${x}]`)!==null,s=y(this.baseDescribedBy,r?this.options.descriptionId:void 0,n?this.options.errorId:void 0);s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby")}applyLabelledBy(e,t){let r=e.ownerDocument.getElementById(this.options.labelId)!==null;this.options.grouped&&r?(t.setAttribute("aria-labelledby",y(this.baseLabelledBy,this.options.labelId)),this.wroteLabelledBy=!0):this.wroteLabelledBy&&(this.baseLabelledBy?t.setAttribute("aria-labelledby",this.baseLabelledBy):t.removeAttribute("aria-labelledby"),this.wroteLabelledBy=!1)}applyConstraintState(e){let t=k.has(e.tagName),r=this.props.required===!0,n=this.props.disabled===!0;r?(t?e.setAttribute("required",""):e.setAttribute("aria-required","true"),this.wroteRequired=!0):this.wroteRequired&&(e.removeAttribute(t?"required":"aria-required"),this.wroteRequired=!1),n?(t?e.setAttribute("disabled",""):e.setAttribute("aria-disabled","true"),this.wroteDisabled=!0):this.wroteDisabled&&(e.removeAttribute(t?"disabled":"aria-disabled"),this.wroteDisabled=!1),t||this.applyGroupDisabled(e,n)}applyGroupDisabled(e,t){let r=e.getAttribute("role");if(!(!(e.tagName==="FIELDSET"||r!==null&&R.has(r))||!t&&!this.wroteGroupDisabled)){for(let s of e.querySelectorAll("input, select, textarea, button"))t?s.setAttribute("disabled",""):s.removeAttribute("disabled");this.wroteGroupDisabled=t}}validate(){return Promise.resolve(this.runValidation()).then(e=>e.length===0)}reset(){this.injected=[],this.custom=[],this.pending=!1,this.awaitingSubmit=!1,this.runToken++,clearTimeout(this.announceTimer),clearTimeout(this.validationTimer),this.validationTimer=void 0,this.markPending(!1);let e=this.readCount();this.update({touched:!1,dirty:!1,count:e,filled:d(this.resolveValue()),errors:this.composeErrors(e)}),this.sync()}markTouched(){this.snapshot.touched||this.update({touched:!0})}applyStateAttributes(e){let{errors:t,touched:r,dirty:n,filled:s,count:l}=this.snapshot;o(e,"data-invalid",t.length>0),o(e,"data-valid",t.length===0),o(e,"data-touched",r),o(e,"data-dirty",n),o(e,"data-filled",s),o(e,"data-over-limit",this.isOverLimit(l)),o(e,"data-disabled",this.props.disabled===!0)}resolveValue(){return this.props.value!==void 0?this.props.value:P(this.control)}readValidity(){return this.control?.validity??null}markPending(e){this.root&&o(this.root,E,e)}nativeMessage(){let e=this.control;return!e?.validity||e.validity.valid?null:e.validationMessage||this.props.invalidMessage||O}runValidation(e={}){let t=++this.runToken,r=this.props.validate?.(this.resolveValue());return L(r)?(this.pending=!0,this.markPending(!0),Promise.resolve(r).then(n=>t!==this.runToken?this.snapshot.errors:(this.pending=!1,this.markPending(!1),this.commit(n,e)))):this.commit(r,e)}commit(e,t){if(this.custom=T(e),this.custom.length===0){let h=this.nativeMessage();h&&!this.injected.includes(h)&&(this.custom=[h])}let r=this.readCount(),n=this.composeErrors(r),s=this.snapshot.errors.length===0;this.update({errors:n,count:r,filled:d(this.resolveValue())});let l=n[0];return l&&s&&!t.silent&&this.options.announce(l,"assertive"),n}update(e){let t={...this.snapshot,...e,valid:!0,validity:this.readValidity()};t.valid=t.errors.length===0,!U(this.snapshot,t)&&(this.snapshot=t,this.sync(),this.options.onSnapshotChange(t),this.root?.dispatchEvent(new CustomEvent(C,{bubbles:!0,composed:!0,detail:{valid:t.valid,errors:t.errors,touched:t.touched,dirty:t.dirty,filled:t.filled,count:t.count,validity:t.validity}})))}scheduleValidation(){clearTimeout(this.validationTimer),this.validationTimer=void 0;let e=this.props.mode==="change"?this.props.validationDebounceTime??0:0;if(e<=0){this.runValidation();return}this.validationTimer=setTimeout(()=>{this.validationTimer=void 0,this.runValidation()},e)}hasErrorSummary(){return this.form?.querySelector(`[${D}]`)!=null}isEngineResubmit(e){return this.form?.hasAttribute(c)?(this.snapshot.errors.length>0&&e.preventDefault(),!0):!1}resubmitIfSettled(){let e=this.form;if(!(!e||typeof e.requestSubmit!="function")&&!e.querySelector(`[${E}]`)&&!e.querySelector(`[${a}][data-invalid]`)){e.setAttribute(c,"");try{e.requestSubmit()}finally{e.removeAttribute(c)}}}};function L(i){return typeof i?.then=="function"}function q(i,e){return i.length===e.length&&i.every((t,r)=>t===e[r])}function U(i,e){return i.controlId===e.controlId&&i.valid===e.valid&&i.touched===e.touched&&i.dirty===e.dirty&&i.filled===e.filled&&i.count===e.count&&i.validity===e.validity&&i.errors.length===e.errors.length&&i.errors.every((t,r)=>t===e.errors[r])}export{j as CHARACTER_COUNT_ANNOUNCE_DELAY_MS,G as ERROR_SUMMARY_RESCAN_EVENTS,$ as FIELD_CHARACTER_COUNT_ATTRIBUTE,w as FIELD_CONTROL_ATTRIBUTE,I as FIELD_CONTROL_SELECTOR,F as FIELD_DESCRIPTION_ATTRIBUTE,x as FIELD_ERROR_ATTRIBUTE,D as FIELD_ERROR_SUMMARY_ATTRIBUTE,p as FIELD_MESSAGE_ATTRIBUTE,u as FIELD_NAME_ATTRIBUTE,E as FIELD_PENDING_ATTRIBUTE,z as FIELD_REQUIRED_INDICATOR_ATTRIBUTE,c as FIELD_RESUBMIT_ATTRIBUTE,a as FIELD_ROOT_ATTRIBUTE,C as FIELD_VALIDITY_CHANGE_EVENT,f as FORM_FIELD_ATTRIBUTE,_ as FORM_MESSAGE_ATTRIBUTE,A as FieldController,O as NATIVE_INVALID_FALLBACK_MESSAGE,M as characterCountMessage,V as characterCountVisible,Q as collectFieldErrors,K as errorSummaryScope,S as findFieldControl,W as focusFieldTarget,d as isFilled,Y as joinFieldMessages,T as normalizeMessages,P as readControlValue,J as resetFields,X as validateFields};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(e,n)=>{for(var t in n)a(e,t,{get:n[t],enumerable:!0})},u=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of r(n))!c.call(e,i)&&i!==t&&a(e,i,{get:()=>n[i],enumerable:!(o=d(n,i))||o.enumerable});return e};var f=e=>u(a({},"__esModule",{value:!0}),e);var m={};s(m,{matchesMediaQuery:()=>w,subscribeMediaQuery:()=>h});module.exports=f(m);function w(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function h(e,n){if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(e),o=i=>n(i.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}0&&(module.exports={matchesMediaQuery,subscribeMediaQuery});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Whether `query` currently matches; `false` wherever `matchMedia` is missing (SSR, some test runners). */
|
|
2
|
+
export declare function matchesMediaQuery(query: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Calls `onChange` with the new match state whenever `query` flips, and returns the unsubscribe.
|
|
5
|
+
* A no-op returning a no-op wherever `matchMedia` is missing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function subscribeMediaQuery(query: string, onChange: (matches: boolean) => void): () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Whether `query` currently matches; `false` wherever `matchMedia` is missing (SSR, some test runners). */
|
|
2
|
+
export declare function matchesMediaQuery(query: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Calls `onChange` with the new match state whenever `query` flips, and returns the unsubscribe.
|
|
5
|
+
* A no-op returning a no-op wherever `matchMedia` is missing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function subscribeMediaQuery(query: string, onChange: (matches: boolean) => void): () => void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function a(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function d(e,i){if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let n=window.matchMedia(e),t=o=>i(o.matches);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}export{a as matchesMediaQuery,d as subscribeMediaQuery};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var K=Object.create;var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var U=(e,n)=>{for(var s in n)f(e,s,{get:n[s],enumerable:!0})},T=(e,n,s,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of k(n))!C.call(e,r)&&r!==s&&f(e,r,{get:()=>n[r],enumerable:!(c=g(n,r))||c.enumerable});return e};var j=(e,n,s)=>(s=e!=null?K(x(e)):{},T(n||!e||!e.__esModule?f(s,"default",{value:e,enumerable:!0}):s,e)),A=e=>T(f({},"__esModule",{value:!0}),e);var _={};U(_,{useDismiss:()=>M});module.exports=A(_);var E=j(require("react"),1),o=require("./dismissal.cjs"),d=require("./useCallbackRef.cjs");function M({enabled:e,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:c,onInteractOutside:r,insideSelector:p},y){let O=(0,d.useCallbackRef)(n),w=n!==void 0,N=(0,d.useCallbackRef)(()=>y),D=(0,d.useCallbackRef)(s),L=(0,d.useCallbackRef)(c),m=(0,d.useCallbackRef)(r),h=E.useRef({insideElements:()=>N().map(t=>t.current)}),v=(0,d.useCallbackRef)(t=>{if(y.some(l=>l.current?.contains(t)))return!1;let a=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return p&&a?.closest(p)?!1:!(0,o.nestedLayerContains)(h.current,t)});E.useEffect(()=>{if(!e)return;let t=globalThis.document,a=h.current,l=(0,o.pushDismissLayer)(a),I=i=>{(0,o.handleEscapeKeyDown)(i,a,w?O:void 0)},R=i=>{let u=i.target;u&&v(u)&&(m(i),D(i))},F=i=>{let u=(0,o.focusOutsideTarget)(i);if(!u||!v(u))return;let b=(0,o.focusOutsideEvent)(i);m(b),L(b)};t.addEventListener("keydown",I);let P=window.setTimeout(()=>{t.addEventListener("pointerdown",R,!0),t.addEventListener("focusin",F,!0)},0);return()=>{l(),t.removeEventListener("keydown",I),window.clearTimeout(P),t.removeEventListener("pointerdown",R,!0),t.removeEventListener("focusin",F,!0)}},[e,w,O,D,L,m,v])}0&&(module.exports={useDismiss});
|
package/dist/utils/useDismiss.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import*as
|
|
2
|
+
import*as i from"react";import{focusOutsideEvent as T,focusOutsideTarget as N,handleEscapeKeyDown as P,nestedLayerContains as K,pushDismissLayer as g}from"./dismissal.js";import{useCallbackRef as t}from"./useCallbackRef.js";function C({enabled:c,onEscapeKeyDown:a,onPointerDownOutside:h,onFocusOutside:I,onInteractOutside:R,insideSelector:f},E){let m=t(a),v=a!==void 0,F=t(()=>E),l=t(h),p=t(I),r=t(R),y=i.useRef({insideElements:()=>F().map(e=>e.current)}),d=t(e=>{if(E.some(u=>u.current?.contains(e)))return!1;let o=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return f&&o?.closest(f)?!1:!K(y.current,e)});i.useEffect(()=>{if(!c)return;let e=globalThis.document,o=y.current,u=g(o),O=n=>{P(n,o,v?m:void 0)},w=n=>{let s=n.target;s&&d(s)&&(r(n),l(n))},D=n=>{let s=N(n);if(!s||!d(s))return;let L=T(n);r(L),p(L)};e.addEventListener("keydown",O);let b=window.setTimeout(()=>{e.addEventListener("pointerdown",w,!0),e.addEventListener("focusin",D,!0)},0);return()=>{u(),e.removeEventListener("keydown",O),window.clearTimeout(b),e.removeEventListener("pointerdown",w,!0),e.removeEventListener("focusin",D,!0)}},[c,v,m,l,p,r,d])}export{C as useDismiss};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var u=Object.create;var r=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},i=(e,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!p.call(e,s)&&s!==a&&r(e,s,{get:()=>t[s],enumerable:!(c=b(t,s))||c.enumerable});return e};var d=(e,t,a)=>(a=e!=null?u(m(e)):{},i(t||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),f=e=>i(r({},"__esModule",{value:!0}),e);var h={};S(h,{useMediaQuery:()=>g});module.exports=f(h);var o=d(require("react"),1),n=require("./media-query.cjs"),R=()=>!1;function g(e){let t=o.useCallback(c=>(0,n.subscribeMediaQuery)(e,c),[e]),a=o.useCallback(()=>(0,n.matchesMediaQuery)(e),[e]);return o.useSyncExternalStore(t,a,R)}0&&(module.exports={useMediaQuery});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `query` matches, kept live through `matchMedia`. `false` on the
|
|
3
|
+
* server and during hydration, so server and client markup never disagree.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const narrow = useMediaQuery('(max-width: 600px)');
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function useMediaQuery(query: string): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `query` matches, kept live through `matchMedia`. `false` on the
|
|
3
|
+
* server and during hydration, so server and client markup never disagree.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const narrow = useMediaQuery('(max-width: 600px)');
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function useMediaQuery(query: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skdx/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Accessible React components for the SkandaDX design system — the core layer, styled by @skdx/skins and @skdx/tokens or by your own CSS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -93,6 +93,16 @@
|
|
|
93
93
|
"default": "./dist/avatar/Avatar.cjs"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
+
"./backdrop": {
|
|
97
|
+
"import": {
|
|
98
|
+
"types": "./dist/backdrop/index.d.ts",
|
|
99
|
+
"default": "./dist/backdrop/Backdrop.js"
|
|
100
|
+
},
|
|
101
|
+
"require": {
|
|
102
|
+
"types": "./dist/backdrop/index.d.cts",
|
|
103
|
+
"default": "./dist/backdrop/Backdrop.cjs"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
96
106
|
"./badge": {
|
|
97
107
|
"import": {
|
|
98
108
|
"types": "./dist/badge/index.d.ts",
|
|
@@ -193,6 +203,16 @@
|
|
|
193
203
|
"default": "./dist/checkbox-group/CheckboxGroup.cjs"
|
|
194
204
|
}
|
|
195
205
|
},
|
|
206
|
+
"./chip": {
|
|
207
|
+
"import": {
|
|
208
|
+
"types": "./dist/chip/index.d.ts",
|
|
209
|
+
"default": "./dist/chip/Chip.js"
|
|
210
|
+
},
|
|
211
|
+
"require": {
|
|
212
|
+
"types": "./dist/chip/index.d.cts",
|
|
213
|
+
"default": "./dist/chip/Chip.cjs"
|
|
214
|
+
}
|
|
215
|
+
},
|
|
196
216
|
"./clipboard": {
|
|
197
217
|
"import": {
|
|
198
218
|
"types": "./dist/clipboard/index.d.ts",
|
|
@@ -263,6 +283,26 @@
|
|
|
263
283
|
"default": "./dist/date-picker/DatePicker.cjs"
|
|
264
284
|
}
|
|
265
285
|
},
|
|
286
|
+
"./date-range-picker": {
|
|
287
|
+
"import": {
|
|
288
|
+
"types": "./dist/date-range-picker/index.d.ts",
|
|
289
|
+
"default": "./dist/date-range-picker/DateRangePicker.js"
|
|
290
|
+
},
|
|
291
|
+
"require": {
|
|
292
|
+
"types": "./dist/date-range-picker/index.d.cts",
|
|
293
|
+
"default": "./dist/date-range-picker/DateRangePicker.cjs"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"./date-time-picker": {
|
|
297
|
+
"import": {
|
|
298
|
+
"types": "./dist/date-time-picker/index.d.ts",
|
|
299
|
+
"default": "./dist/date-time-picker/DateTimePicker.js"
|
|
300
|
+
},
|
|
301
|
+
"require": {
|
|
302
|
+
"types": "./dist/date-time-picker/index.d.cts",
|
|
303
|
+
"default": "./dist/date-time-picker/DateTimePicker.cjs"
|
|
304
|
+
}
|
|
305
|
+
},
|
|
266
306
|
"./dialog": {
|
|
267
307
|
"import": {
|
|
268
308
|
"types": "./dist/dialog/index.d.ts",
|
|
@@ -303,6 +343,16 @@
|
|
|
303
343
|
"default": "./dist/editable/Editable.cjs"
|
|
304
344
|
}
|
|
305
345
|
},
|
|
346
|
+
"./fab": {
|
|
347
|
+
"import": {
|
|
348
|
+
"types": "./dist/fab/index.d.ts",
|
|
349
|
+
"default": "./dist/fab/Fab.js"
|
|
350
|
+
},
|
|
351
|
+
"require": {
|
|
352
|
+
"types": "./dist/fab/index.d.cts",
|
|
353
|
+
"default": "./dist/fab/Fab.cjs"
|
|
354
|
+
}
|
|
355
|
+
},
|
|
306
356
|
"./field": {
|
|
307
357
|
"import": {
|
|
308
358
|
"types": "./dist/field/index.d.ts",
|
|
@@ -343,6 +393,26 @@
|
|
|
343
393
|
"default": "./dist/form/Form.cjs"
|
|
344
394
|
}
|
|
345
395
|
},
|
|
396
|
+
"./gauge": {
|
|
397
|
+
"import": {
|
|
398
|
+
"types": "./dist/gauge/index.d.ts",
|
|
399
|
+
"default": "./dist/gauge/Gauge.js"
|
|
400
|
+
},
|
|
401
|
+
"require": {
|
|
402
|
+
"types": "./dist/gauge/index.d.cts",
|
|
403
|
+
"default": "./dist/gauge/Gauge.cjs"
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
"./grid": {
|
|
407
|
+
"import": {
|
|
408
|
+
"types": "./dist/grid/index.d.ts",
|
|
409
|
+
"default": "./dist/grid/Grid.js"
|
|
410
|
+
},
|
|
411
|
+
"require": {
|
|
412
|
+
"types": "./dist/grid/index.d.cts",
|
|
413
|
+
"default": "./dist/grid/Grid.cjs"
|
|
414
|
+
}
|
|
415
|
+
},
|
|
346
416
|
"./heading": {
|
|
347
417
|
"import": {
|
|
348
418
|
"types": "./dist/heading/index.d.ts",
|
|
@@ -483,6 +553,16 @@
|
|
|
483
553
|
"default": "./dist/pagination/Pagination.cjs"
|
|
484
554
|
}
|
|
485
555
|
},
|
|
556
|
+
"./paper": {
|
|
557
|
+
"import": {
|
|
558
|
+
"types": "./dist/paper/index.d.ts",
|
|
559
|
+
"default": "./dist/paper/Paper.js"
|
|
560
|
+
},
|
|
561
|
+
"require": {
|
|
562
|
+
"types": "./dist/paper/index.d.cts",
|
|
563
|
+
"default": "./dist/paper/Paper.cjs"
|
|
564
|
+
}
|
|
565
|
+
},
|
|
486
566
|
"./password-input": {
|
|
487
567
|
"import": {
|
|
488
568
|
"types": "./dist/password-input/index.d.ts",
|
|
@@ -643,6 +723,16 @@
|
|
|
643
723
|
"default": "./dist/split-button/SplitButton.cjs"
|
|
644
724
|
}
|
|
645
725
|
},
|
|
726
|
+
"./stack": {
|
|
727
|
+
"import": {
|
|
728
|
+
"types": "./dist/stack/index.d.ts",
|
|
729
|
+
"default": "./dist/stack/Stack.js"
|
|
730
|
+
},
|
|
731
|
+
"require": {
|
|
732
|
+
"types": "./dist/stack/index.d.cts",
|
|
733
|
+
"default": "./dist/stack/Stack.cjs"
|
|
734
|
+
}
|
|
735
|
+
},
|
|
646
736
|
"./stepper": {
|
|
647
737
|
"import": {
|
|
648
738
|
"types": "./dist/stepper/index.d.ts",
|
|
@@ -803,6 +893,16 @@
|
|
|
803
893
|
"default": "./dist/toolbar/Toolbar.cjs"
|
|
804
894
|
}
|
|
805
895
|
},
|
|
896
|
+
"./tooltip": {
|
|
897
|
+
"import": {
|
|
898
|
+
"types": "./dist/tooltip/index.d.ts",
|
|
899
|
+
"default": "./dist/tooltip/Tooltip.js"
|
|
900
|
+
},
|
|
901
|
+
"require": {
|
|
902
|
+
"types": "./dist/tooltip/index.d.cts",
|
|
903
|
+
"default": "./dist/tooltip/Tooltip.cjs"
|
|
904
|
+
}
|
|
905
|
+
},
|
|
806
906
|
"./tour": {
|
|
807
907
|
"import": {
|
|
808
908
|
"types": "./dist/tour/index.d.ts",
|
|
@@ -1505,7 +1605,7 @@
|
|
|
1505
1605
|
"tsup": "^8.5.1",
|
|
1506
1606
|
"typescript": "^6.0.3",
|
|
1507
1607
|
"vitest": "^4.1.10",
|
|
1508
|
-
"@skdx/shared": "0.
|
|
1608
|
+
"@skdx/shared": "0.31.0"
|
|
1509
1609
|
},
|
|
1510
1610
|
"scripts": {
|
|
1511
1611
|
"lint": "eslint . --cache --cache-location node_modules/.cache/eslint/",
|