@sectile/vue 0.14.0 → 0.14.2
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/alert-dialog.d.ts +1 -1
- package/dist/cascade-select.d.ts +93 -1
- package/dist/cascade-select.js +1 -1
- package/dist/cascade-select.js.map +1 -1
- package/dist/chart.js +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/combobox.d.ts +93 -1
- package/dist/combobox.js +1 -1
- package/dist/combobox.js.map +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/drawer.d.ts +1 -1
- package/dist/internal/popup.d.ts +2 -0
- package/dist/internal/popup.js +1 -1
- package/dist/internal/popup.js.map +1 -1
- package/dist/listbox.js +1 -1
- package/dist/listbox.js.map +1 -1
- package/dist/menu.d.ts +93 -1
- package/dist/menu.js +1 -1
- package/dist/menu.js.map +1 -1
- package/dist/select.js +1 -1
- package/dist/select.js.map +1 -1
- package/dist/tabs.js +1 -1
- package/dist/tabs.js.map +1 -1
- package/dist/tooltip.d.ts +1 -1
- package/package.json +15 -14
package/dist/combobox.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
2
|
import { type ComboboxItem as ComboboxItemDefinition, type ComboboxPolicies } from '@sectile/dom/combobox';
|
|
3
|
+
import type { PositionBoundary, PositionOptions, PositionPadding, PositionStrategy, PositionTracking } from '@sectile/dom/position';
|
|
3
4
|
import { type PrimitiveAs } from './primitive.js';
|
|
4
|
-
export interface ComboboxRootProps {
|
|
5
|
+
export interface ComboboxRootProps extends Omit<PositionOptions, 'arrowPadding'> {
|
|
5
6
|
readonly items: readonly ComboboxItemDefinition<string>[];
|
|
6
7
|
readonly modelValue?: string | null;
|
|
7
8
|
readonly defaultValue?: string | null;
|
|
@@ -12,6 +13,7 @@ export interface ComboboxRootProps {
|
|
|
12
13
|
readonly disabled?: boolean;
|
|
13
14
|
readonly?: boolean;
|
|
14
15
|
readonly label?: string;
|
|
16
|
+
readonly position?: boolean;
|
|
15
17
|
readonly policies?: ComboboxPolicies<string>;
|
|
16
18
|
readonly as?: PrimitiveAs;
|
|
17
19
|
readonly asChild?: boolean;
|
|
@@ -81,6 +83,46 @@ export declare const ComboboxRoot: import("vue").DefineComponent<import("vue").E
|
|
|
81
83
|
type: StringConstructor;
|
|
82
84
|
default: undefined;
|
|
83
85
|
};
|
|
86
|
+
position: {
|
|
87
|
+
type: BooleanConstructor;
|
|
88
|
+
default: boolean;
|
|
89
|
+
};
|
|
90
|
+
side: {
|
|
91
|
+
type: PropType<'top' | 'right' | 'bottom' | 'left'>;
|
|
92
|
+
default: string;
|
|
93
|
+
};
|
|
94
|
+
align: {
|
|
95
|
+
type: PropType<'start' | 'center' | 'end'>;
|
|
96
|
+
default: string;
|
|
97
|
+
};
|
|
98
|
+
sideOffset: {
|
|
99
|
+
type: NumberConstructor;
|
|
100
|
+
default: number;
|
|
101
|
+
};
|
|
102
|
+
collisionPadding: {
|
|
103
|
+
type: PropType<PositionPadding>;
|
|
104
|
+
default: number;
|
|
105
|
+
};
|
|
106
|
+
collisionBoundary: {
|
|
107
|
+
type: PropType<PositionBoundary>;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
avoidCollisions: {
|
|
111
|
+
type: BooleanConstructor;
|
|
112
|
+
default: boolean;
|
|
113
|
+
};
|
|
114
|
+
hideWhenDetached: {
|
|
115
|
+
type: BooleanConstructor;
|
|
116
|
+
default: boolean;
|
|
117
|
+
};
|
|
118
|
+
strategy: {
|
|
119
|
+
type: PropType<PositionStrategy>;
|
|
120
|
+
default: string;
|
|
121
|
+
};
|
|
122
|
+
tracking: {
|
|
123
|
+
type: PropType<PositionTracking>;
|
|
124
|
+
default: string;
|
|
125
|
+
};
|
|
84
126
|
policies: {
|
|
85
127
|
type: PropType<ComboboxPolicies<string>>;
|
|
86
128
|
default: undefined;
|
|
@@ -140,6 +182,46 @@ export declare const ComboboxRoot: import("vue").DefineComponent<import("vue").E
|
|
|
140
182
|
type: StringConstructor;
|
|
141
183
|
default: undefined;
|
|
142
184
|
};
|
|
185
|
+
position: {
|
|
186
|
+
type: BooleanConstructor;
|
|
187
|
+
default: boolean;
|
|
188
|
+
};
|
|
189
|
+
side: {
|
|
190
|
+
type: PropType<'top' | 'right' | 'bottom' | 'left'>;
|
|
191
|
+
default: string;
|
|
192
|
+
};
|
|
193
|
+
align: {
|
|
194
|
+
type: PropType<'start' | 'center' | 'end'>;
|
|
195
|
+
default: string;
|
|
196
|
+
};
|
|
197
|
+
sideOffset: {
|
|
198
|
+
type: NumberConstructor;
|
|
199
|
+
default: number;
|
|
200
|
+
};
|
|
201
|
+
collisionPadding: {
|
|
202
|
+
type: PropType<PositionPadding>;
|
|
203
|
+
default: number;
|
|
204
|
+
};
|
|
205
|
+
collisionBoundary: {
|
|
206
|
+
type: PropType<PositionBoundary>;
|
|
207
|
+
default: undefined;
|
|
208
|
+
};
|
|
209
|
+
avoidCollisions: {
|
|
210
|
+
type: BooleanConstructor;
|
|
211
|
+
default: boolean;
|
|
212
|
+
};
|
|
213
|
+
hideWhenDetached: {
|
|
214
|
+
type: BooleanConstructor;
|
|
215
|
+
default: boolean;
|
|
216
|
+
};
|
|
217
|
+
strategy: {
|
|
218
|
+
type: PropType<PositionStrategy>;
|
|
219
|
+
default: string;
|
|
220
|
+
};
|
|
221
|
+
tracking: {
|
|
222
|
+
type: PropType<PositionTracking>;
|
|
223
|
+
default: string;
|
|
224
|
+
};
|
|
143
225
|
policies: {
|
|
144
226
|
type: PropType<ComboboxPolicies<string>>;
|
|
145
227
|
default: undefined;
|
|
@@ -168,6 +250,16 @@ export declare const ComboboxRoot: import("vue").DefineComponent<import("vue").E
|
|
|
168
250
|
disabled: boolean;
|
|
169
251
|
readonly: boolean;
|
|
170
252
|
label: string;
|
|
253
|
+
position: boolean;
|
|
254
|
+
side: "bottom" | "left" | "right" | "top";
|
|
255
|
+
align: "center" | "end" | "start";
|
|
256
|
+
sideOffset: number;
|
|
257
|
+
collisionPadding: PositionPadding;
|
|
258
|
+
collisionBoundary: PositionBoundary;
|
|
259
|
+
avoidCollisions: boolean;
|
|
260
|
+
hideWhenDetached: boolean;
|
|
261
|
+
strategy: PositionStrategy;
|
|
262
|
+
tracking: PositionTracking;
|
|
171
263
|
policies: ComboboxPolicies<string>;
|
|
172
264
|
as: PrimitiveAs;
|
|
173
265
|
asChild: boolean;
|
package/dist/combobox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{computed,defineComponent,h,inject,mergeProps,nextTick,onBeforeUnmount,onMounted,provide,shallowRef,watch}from"vue";import{createCombobox}from"@sectile/dom/combobox";import{createTextState}from"@sectile/dom/text";import{Primitive}from"./primitive.js";import{useNativeInputFormControl}from"./internal/form-control.js";import{reconcileCollectionState}from"./internal/collection.js";import{useControlledStateInvariant}from"./internal/controlled-state.js";const key=Symbol("SectileComboboxRoot");const partProps={as:{type:[String,Object,Function],default:"span"},asChild:{type:Boolean,default:false}};const ComboboxRoot=defineComponent({name:"SectileComboboxRoot",inheritAttrs:false,props:{items:{type:Array,required:true},modelValue:{type:String,default:void 0},defaultValue:{type:String,default:null},inputValue:{type:String,default:void 0},defaultInputValue:{type:String,default:""},open:{type:Boolean,default:void 0},defaultOpen:{type:Boolean,default:false},disabled:{type:Boolean,default:false},readonly:{type:Boolean,default:false},label:{type:String,default:void 0},policies:{type:Object,default:void 0},as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},emits:{"update:modelValue":_value=>true,"update:inputValue":_value=>true,"update:open":_value=>true,highlight:_value=>true,accept:_value=>true},slots:Object,setup(props,{attrs,emit,slots}){const input=shallowRef();const popup=shallowRef();const connection=shallowRef();const localValue=shallowRef(props.modelValue!==void 0?props.modelValue:props.defaultValue);const localInput=shallowRef(props.inputValue??props.defaultInputValue);const localOpen=shallowRef(props.open??props.defaultOpen);const highlighted=shallowRef(null);let proposedInputState=null;const controlled={value:useControlledStateInvariant("ComboboxRoot","modelValue",()=>props.modelValue),input:useControlledStateInvariant("ComboboxRoot","inputValue",()=>props.inputValue),open:useControlledStateInvariant("ComboboxRoot","open",()=>props.open)};const state=computed(()=>Object.freeze({value:props.modelValue!==void 0?props.modelValue:localValue.value,inputValue:props.inputValue??localInput.value,highlightedValue:highlighted.value,open:props.open??localOpen.value,disabled:props.disabled,readonly:props.readonly}));const refresh=()=>{const snapshot=connection.value?.getSnapshot().state;if(snapshot===void 0)return;localValue.value=snapshot.selection.selected[0]??null;localInput.value=snapshot.text.snapshot.text;localOpen.value=snapshot.popupOpen;highlighted.value=snapshot.cursor.current;refreshItems()};const refreshItems=()=>{if(popup.value===void 0||connection.value===void 0)return;popup.value.querySelectorAll("[data-sectile-combobox-id]").forEach(element=>{const id=element.dataset["sectileComboboxId"];if(id!==void 0)connection.value?.setItemAttributes(element,{id,disabled:element.dataset["disabled"]==="true"})})};const connect=()=>{connection.value?.disconnect();if(input.value===void 0)return;const items=props.items.map(item=>item.id);const requestedValue=controlled.value?props.modelValue:localValue.value;const reconciled=reconcileCollectionState(items,requestedValue===null?[]:[requestedValue],highlighted.value,[],"single",{preserveNullCurrent:true});const value=reconciled.selected[0]??null;localValue.value=value;highlighted.value=reconciled.current;if(controlled.value&&requestedValue!==value)emit("update:modelValue",value);connection.value=createCombobox({input:input.value,...popup.value===void 0?{}:{popup:popup.value},items:props.items,...props.policies===void 0?{}:{policies:props.policies},...controlled.value?{value}:{defaultValue:value},defaultHighlightedValue:reconciled.current,...controlled.input?{inputState:createTextState(props.inputValue)}:{defaultInputState:createTextState(localInput.value)},...controlled.open?{open:props.open}:{defaultOpen:localOpen.value},disabled:props.disabled,readOnly:props.readonly,onValueChange:({value:value2})=>{localValue.value=value2;emit("update:modelValue",value2)},onInputStateChange:({value:value2})=>{proposedInputState=value2;localInput.value=value2.snapshot.text;emit("update:inputValue",value2.snapshot.text);if(!controlled.input)return;const proposal=value2;void nextTick(()=>{if(connection.value===void 0||proposedInputState!==proposal)return;if(props.inputValue!==proposal.snapshot.text)return;proposedInputState=null;syncControlledValues(proposal)})},onOpenChange:({value:value2})=>{localOpen.value=value2;emit("update:open",value2)},onHighlightedValueChange:({value:value2})=>{highlighted.value=value2;emit("highlight",value2)},onAccept:id=>emit("accept",id),onUpdate:refresh});connection.value.setInputAttributes(props.label);connection.value.setPopupAttributes(props.label);refreshItems();refresh()};provide(key,{state,label:computed(()=>props.label),connection:computed(()=>connection.value),registerInput:element=>{input.value=element},registerPopup:element=>{popup.value=element},registerItem:(element,id,disabled)=>connection.value?.setItemAttributes(element,{id,disabled})});onMounted(connect);onBeforeUnmount(()=>{connection.value?.disconnect();connection.value=void 0;proposedInputState=null});watch(()=>props.items,(items,previousItems)=>{if(!sameComboboxItems(items,previousItems))connect()});watch([()=>props.disabled,()=>props.readonly,()=>props.label,()=>props.policies],connect);watch([()=>props.modelValue,()=>props.inputValue,()=>props.open],()=>{const inputState=controlled.input&&proposedInputState!==null&&proposedInputState.snapshot.text===props.inputValue?proposedInputState:controlled.input?createTextState(props.inputValue):void 0;proposedInputState=null;syncControlledValues(inputState)});const syncControlledValues=inputState=>{if(connection.value===void 0)return;const result=connection.value.syncControlledValues({...controlled.value?{value:props.modelValue}:{},...controlled.input?{inputState:inputState??createTextState(props.inputValue)}:{},...controlled.open?{open:props.open}:{}});if(!result.ok)throw new TypeError(result.error.message);refresh()};return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,"data-scope":"combobox","data-part":"root","data-state":state.value.open?"open":"closed","data-disabled":props.disabled?"":void 0,"data-readonly":props.readonly?"":void 0}),{default:()=>slots["default"]?.(state.value)})}});const ComboboxInput=defineComponent({name:"SectileComboboxInput",inheritAttrs:false,props:{name:{type:String,default:void 0},form:{type:String,default:void 0},required:{type:Boolean,default:false},as:{type:[String,Object,Function],default:"input"},asChild:{type:Boolean,default:false}},setup(props,{attrs}){const root=useRoot("ComboboxInput");const input=shallowRef(null);const participation=useNativeInputFormControl(input);const renderServerValue=typeof window==="undefined";return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:node=>{input.value=node instanceof HTMLInputElement?node:null;root.registerInput(input.value??void 0)},type:"text",role:"combobox",...renderServerValue?{value:root.state.value.inputValue}:{},name:props.name,form:props.form,required:props.required,disabled:root.state.value.disabled,readonly:root.state.value.readonly,"aria-label":root.label.value,"aria-autocomplete":"list","aria-expanded":String(root.state.value.open),"data-scope":"combobox","data-part":"input"},participation.controlProps.value))}});const ComboboxContent=defineComponent({name:"SectileComboboxContent",inheritAttrs:false,props:{as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},slots:Object,setup(props,{attrs,slots}){const root=useRoot("ComboboxContent");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:node=>root.registerPopup(node instanceof HTMLElement?node:void 0),role:"listbox",hidden:!root.state.value.open,"aria-label":root.label.value,"data-scope":"combobox","data-part":"content","data-state":root.state.value.open?"open":"closed"}),{default:()=>slots["default"]?.(root.state.value)})}});const ComboboxItem=defineComponent({name:"SectileComboboxItem",inheritAttrs:false,props:{value:{type:String,required:true},disabled:{type:Boolean,default:false},...partProps},slots:Object,setup(props,{attrs,slots}){const root=useRoot("ComboboxItem");const state=computed(()=>({value:props.value,selected:root.state.value.value===props.value,highlighted:root.state.value.highlightedValue===props.value,disabled:root.state.value.disabled||props.disabled}));return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:node=>{if(node instanceof HTMLElement)root.registerItem(node,props.value,state.value.disabled)},role:"option","aria-selected":String(state.value.selected),"aria-disabled":state.value.disabled?"true":void 0,"data-sectile-combobox-id":props.value,"data-disabled":state.value.disabled?"true":void 0,"data-scope":"combobox","data-part":"item","data-selected":state.value.selected?"":void 0,"data-highlighted":state.value.highlighted?"":void 0}),{default:()=>slots["default"]?.(state.value)})}});const ComboboxEmpty=defineComponent({name:"SectileComboboxEmpty",inheritAttrs:false,props:partProps,slots:Object,setup(props,{attrs,slots}){const root=useRoot("ComboboxEmpty");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,role:"status","data-scope":"combobox","data-part":"empty"}),{default:()=>slots["default"]?.(root.state.value)})}});function useRoot(part){const root=inject(key);if(root===void 0)throw new TypeError(`${part} must be used inside ComboboxRoot.`);return root}function sameComboboxItems(items,previousItems){return items.length===previousItems.length&&items.every((item,index)=>{const previousItem=previousItems[index];return previousItem!==void 0&&item.id===previousItem.id&&item.label===previousItem.label})}export{ComboboxContent,ComboboxEmpty,ComboboxInput,ComboboxItem,ComboboxRoot};
|
|
1
|
+
import{computed,defineComponent,h,inject,mergeProps,nextTick,onBeforeUnmount,onMounted,provide,shallowRef,watch}from"vue";import{createCombobox}from"@sectile/dom/combobox";import{createTextState}from"@sectile/dom/text";import{Primitive}from"./primitive.js";import{useNativeInputFormControl}from"./internal/form-control.js";import{reconcileCollectionState}from"./internal/collection.js";import{useControlledStateInvariant}from"./internal/controlled-state.js";const key=Symbol("SectileComboboxRoot");const partProps={as:{type:[String,Object,Function],default:"span"},asChild:{type:Boolean,default:false}};const ComboboxRoot=defineComponent({name:"SectileComboboxRoot",inheritAttrs:false,props:{items:{type:Array,required:true},modelValue:{type:String,default:void 0},defaultValue:{type:String,default:null},inputValue:{type:String,default:void 0},defaultInputValue:{type:String,default:""},open:{type:Boolean,default:void 0},defaultOpen:{type:Boolean,default:false},disabled:{type:Boolean,default:false},readonly:{type:Boolean,default:false},label:{type:String,default:void 0},position:{type:Boolean,default:true},side:{type:String,default:"bottom"},align:{type:String,default:"start"},sideOffset:{type:Number,default:8},collisionPadding:{type:[Number,Object],default:8},collisionBoundary:{type:[String,Object],default:void 0},avoidCollisions:{type:Boolean,default:true},hideWhenDetached:{type:Boolean,default:false},strategy:{type:String,default:"absolute"},tracking:{type:String,default:"events"},policies:{type:Object,default:void 0},as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},emits:{"update:modelValue":_value=>true,"update:inputValue":_value=>true,"update:open":_value=>true,highlight:_value=>true,accept:_value=>true},slots:Object,setup(props,{attrs,emit,slots}){const input=shallowRef();const popup=shallowRef();const connection=shallowRef();const localValue=shallowRef(props.modelValue!==void 0?props.modelValue:props.defaultValue);const localInput=shallowRef(props.inputValue??props.defaultInputValue);const localOpen=shallowRef(props.open??props.defaultOpen);const highlighted=shallowRef(null);let proposedInputState=null;const controlled={value:useControlledStateInvariant("ComboboxRoot","modelValue",()=>props.modelValue),input:useControlledStateInvariant("ComboboxRoot","inputValue",()=>props.inputValue),open:useControlledStateInvariant("ComboboxRoot","open",()=>props.open)};const state=computed(()=>Object.freeze({value:props.modelValue!==void 0?props.modelValue:localValue.value,inputValue:props.inputValue??localInput.value,highlightedValue:highlighted.value,open:props.open??localOpen.value,disabled:props.disabled,readonly:props.readonly}));const refresh=()=>{const snapshot=connection.value?.getSnapshot().state;if(snapshot===void 0)return;localValue.value=snapshot.selection.selected[0]??null;localInput.value=snapshot.text.snapshot.text;localOpen.value=snapshot.popupOpen;highlighted.value=snapshot.cursor.current;refreshItems()};const refreshItems=()=>{if(popup.value===void 0||connection.value===void 0)return;popup.value.querySelectorAll("[data-sectile-combobox-id]").forEach(element=>{const id=element.dataset["sectileComboboxId"];if(id!==void 0)connection.value?.setItemAttributes(element,{id,disabled:element.dataset["disabled"]==="true"})})};const connect=()=>{connection.value?.disconnect();if(input.value===void 0)return;const items=props.items.map(item=>item.id);const requestedValue=controlled.value?props.modelValue:localValue.value;const reconciled=reconcileCollectionState(items,requestedValue===null?[]:[requestedValue],highlighted.value,[],"single",{preserveNullCurrent:true});const value=reconciled.selected[0]??null;localValue.value=value;highlighted.value=reconciled.current;if(controlled.value&&requestedValue!==value)emit("update:modelValue",value);connection.value=createCombobox({input:input.value,...popup.value===void 0?{}:{popup:popup.value},items:props.items,...props.policies===void 0?{}:{policies:props.policies},...controlled.value?{value}:{defaultValue:value},defaultHighlightedValue:reconciled.current,...controlled.input?{inputState:createTextState(props.inputValue)}:{defaultInputState:createTextState(localInput.value)},...controlled.open?{open:props.open}:{defaultOpen:localOpen.value},disabled:props.disabled,readOnly:props.readonly,position:props.position,side:props.side,align:props.align,sideOffset:props.sideOffset,collisionPadding:props.collisionPadding,...props.collisionBoundary===void 0?{}:{collisionBoundary:props.collisionBoundary},avoidCollisions:props.avoidCollisions,hideWhenDetached:props.hideWhenDetached,strategy:props.strategy,tracking:props.tracking,onValueChange:({value:value2})=>{localValue.value=value2;emit("update:modelValue",value2)},onInputStateChange:({value:value2})=>{proposedInputState=value2;localInput.value=value2.snapshot.text;emit("update:inputValue",value2.snapshot.text);if(!controlled.input)return;const proposal=value2;void nextTick(()=>{if(connection.value===void 0||proposedInputState!==proposal)return;if(props.inputValue!==proposal.snapshot.text)return;proposedInputState=null;syncControlledValues(proposal)})},onOpenChange:({value:value2})=>{localOpen.value=value2;emit("update:open",value2)},onHighlightedValueChange:({value:value2})=>{highlighted.value=value2;emit("highlight",value2)},onAccept:id=>emit("accept",id),onUpdate:refresh});connection.value.setInputAttributes(props.label);connection.value.setPopupAttributes(props.label);refreshItems();refresh()};let mounted=false;let connectScheduled=false;const scheduleConnect=()=>{if(!mounted||connectScheduled)return;connectScheduled=true;void nextTick(()=>{connectScheduled=false;if(mounted)connect()})};provide(key,{state,position:computed(()=>props.position),strategy:computed(()=>props.strategy),label:computed(()=>props.label),connection:computed(()=>connection.value),registerInput:element=>{const changed=input.value!==element;input.value=element;if(changed)scheduleConnect()},registerPopup:element=>{const changed=popup.value!==element;popup.value=element;if(changed)scheduleConnect()},registerItem:(element,id,disabled)=>connection.value?.setItemAttributes(element,{id,disabled})});onMounted(()=>{mounted=true;connect()});onBeforeUnmount(()=>{mounted=false;connection.value?.disconnect();connection.value=void 0;proposedInputState=null});watch(()=>props.items,(items,previousItems)=>{if(!sameComboboxItems(items,previousItems))connect()});watch([()=>props.disabled,()=>props.readonly,()=>props.label,()=>props.position,()=>props.side,()=>props.align,()=>props.sideOffset,()=>props.collisionPadding,()=>props.collisionBoundary,()=>props.avoidCollisions,()=>props.hideWhenDetached,()=>props.strategy,()=>props.tracking,()=>props.policies],connect);watch([()=>props.modelValue,()=>props.inputValue,()=>props.open],()=>{const inputState=controlled.input&&proposedInputState!==null&&proposedInputState.snapshot.text===props.inputValue?proposedInputState:controlled.input?createTextState(props.inputValue):void 0;proposedInputState=null;syncControlledValues(inputState)});const syncControlledValues=inputState=>{if(connection.value===void 0)return;const result=connection.value.syncControlledValues({...controlled.value?{value:props.modelValue}:{},...controlled.input?{inputState:inputState??createTextState(props.inputValue)}:{},...controlled.open?{open:props.open}:{}});if(!result.ok)throw new TypeError(result.error.message);refresh()};return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,"data-scope":"combobox","data-part":"root","data-state":state.value.open?"open":"closed","data-disabled":props.disabled?"":void 0,"data-readonly":props.readonly?"":void 0}),{default:()=>slots["default"]?.(state.value)})}});const ComboboxInput=defineComponent({name:"SectileComboboxInput",inheritAttrs:false,props:{name:{type:String,default:void 0},form:{type:String,default:void 0},required:{type:Boolean,default:false},as:{type:[String,Object,Function],default:"input"},asChild:{type:Boolean,default:false}},setup(props,{attrs}){const root=useRoot("ComboboxInput");const input=shallowRef(null);const participation=useNativeInputFormControl(input);const renderServerValue=typeof window==="undefined";const registerInput=node=>{input.value=node instanceof HTMLInputElement?node:null;root.registerInput(input.value??void 0)};return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:registerInput,type:"text",role:"combobox",...renderServerValue?{value:root.state.value.inputValue}:{},name:props.name,form:props.form,required:props.required,disabled:root.state.value.disabled,readonly:root.state.value.readonly,"aria-label":root.label.value,"aria-autocomplete":"list","aria-expanded":String(root.state.value.open),"data-scope":"combobox","data-part":"input"},participation.controlProps.value))}});const ComboboxContent=defineComponent({name:"SectileComboboxContent",inheritAttrs:false,props:{as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},slots:Object,setup(props,{attrs,slots}){const root=useRoot("ComboboxContent");const element=shallowRef();const registerContent=node=>{const content=node instanceof HTMLElement?node:void 0;element.value=content;root.registerPopup(content)};return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:registerContent,role:"listbox",hidden:!root.state.value.open,"aria-label":root.label.value,style:root.position.value?{position:root.strategy.value,visibility:element.value===void 0?"hidden":void 0}:void 0,"data-scope":"combobox","data-part":"content","data-state":root.state.value.open?"open":"closed"}),{default:()=>slots["default"]?.(root.state.value)})}});const ComboboxItem=defineComponent({name:"SectileComboboxItem",inheritAttrs:false,props:{value:{type:String,required:true},disabled:{type:Boolean,default:false},...partProps},slots:Object,setup(props,{attrs,slots}){const root=useRoot("ComboboxItem");const state=computed(()=>({value:props.value,selected:root.state.value.value===props.value,highlighted:root.state.value.highlightedValue===props.value,disabled:root.state.value.disabled||props.disabled}));return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:node=>{if(node instanceof HTMLElement)root.registerItem(node,props.value,state.value.disabled)},role:"option","aria-selected":String(state.value.selected),"aria-disabled":state.value.disabled?"true":void 0,"data-sectile-combobox-id":props.value,"data-disabled":state.value.disabled?"true":void 0,"data-scope":"combobox","data-part":"item","data-selected":state.value.selected?"":void 0,"data-highlighted":state.value.highlighted?"":void 0}),{default:()=>slots["default"]?.(state.value)})}});const ComboboxEmpty=defineComponent({name:"SectileComboboxEmpty",inheritAttrs:false,props:partProps,slots:Object,setup(props,{attrs,slots}){const root=useRoot("ComboboxEmpty");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,role:"status","data-scope":"combobox","data-part":"empty"}),{default:()=>slots["default"]?.(root.state.value)})}});function useRoot(part){const root=inject(key);if(root===void 0)throw new TypeError(`${part} must be used inside ComboboxRoot.`);return root}function sameComboboxItems(items,previousItems){return items.length===previousItems.length&&items.every((item,index)=>{const previousItem=previousItems[index];return previousItem!==void 0&&item.id===previousItem.id&&item.label===previousItem.label})}export{ComboboxContent,ComboboxEmpty,ComboboxInput,ComboboxItem,ComboboxRoot};
|
|
2
2
|
//# sourceMappingURL=combobox.js.map
|
package/dist/combobox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/combobox.ts"],"mappings":"AAAA,OACE,SAAU,gBAAiB,EAAG,OAAQ,WAAY,SAAU,gBAAiB,UAAW,QACxF,WAAY,UACP,MACP,OACE,mBACK,
|
|
1
|
+
{"version":3,"sources":["../src/combobox.ts"],"mappings":"AAAA,OACE,SAAU,gBAAiB,EAAG,OAAQ,WAAY,SAAU,gBAAiB,UAAW,QACxF,WAAY,UACP,MACP,OACE,mBACK,wBAQP,OAAS,oBAAuC,oBAChD,OAAS,cAAmC,iBAC5C,OAAS,8BAAiC,6BAC1C,OAAS,6BAAgC,2BACzC,OAAS,gCAAmC,iCAiC5C,MAAM,IAAM,OAAO,qBAAqB,EACxC,MAAM,UAAY,CAAE,GAAI,CAAE,KAAM,CAAC,OAAQ,OAAQ,QAAQ,EAA4B,QAAS,MAAM,EAAI,QAAS,CAAE,KAAM,QAAS,QAAS,KAAK,CAAE,EAE3I,MAAM,aAAe,gBAAgB,CAC1C,KAAM,sBAAuB,aAAc,MAC3C,MAAO,CACL,MAAO,CAAE,KAAM,MAA8D,SAAU,IAAI,EAC3F,WAAY,CAAE,KAAM,OAAmC,QAAS,MAAS,EAAI,aAAc,CAAE,KAAM,OAAmC,QAAS,IAAI,EACnJ,WAAY,CAAE,KAAM,OAAQ,QAAS,MAAS,EAAI,kBAAmB,CAAE,KAAM,OAAQ,QAAS,EAAE,EAChG,KAAM,CAAE,KAAM,QAAS,QAAS,MAAS,EAAI,YAAa,CAAE,KAAM,QAAS,QAAS,KAAK,EACzF,SAAU,CAAE,KAAM,QAAS,QAAS,KAAK,EAAI,SAAU,CAAE,KAAM,QAAS,QAAS,KAAK,EAAI,MAAO,CAAE,KAAM,OAAQ,QAAS,MAAS,EACnI,SAAU,CAAE,KAAM,QAAS,QAAS,IAAI,EACxC,KAAM,CAAE,KAAM,OAA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aAAa,KAAM,MAAM,MAAO,MAAM,MAAM,QAAQ,CAAG,EACpK,KAAM,SAAU,gBAAiB,OAAO,MAAM,MAAM,QAAQ,EAAG,gBAAiB,MAAM,MAAM,SAAW,OAAS,OAChH,2BAA4B,MAAM,MAAO,gBAAiB,MAAM,MAAM,SAAW,OAAS,OAC1F,aAAc,WAAY,YAAa,OAAQ,gBAAiB,MAAM,MAAM,SAAW,GAAK,OAC5F,mBAAoB,MAAM,MAAM,YAAc,GAAK,OACpD,EAAG,CAAE,QAAS,IAAM,MAAM,SAAS,IAAI,MAAM,KAAK,CAAC,CAAE,CACxD,EACD,EAEM,MAAM,cAAgB,gBAAgB,CAC3C,KAAM,uBAAwB,aAAc,MAAO,MAAO,UAC1D,MAAO,OACP,MAAM,MAAO,CAAE,MAAO,KAAK,EAAE,CAAI,MAAM,KAAO,QAAQ,eAAe,EAAG,MAAO,IAAkB,EAAE,UAAW,WAAW,MAAO,CAC9H,GAAI,MAAM,GAAI,QAAS,MAAM,QAAS,KAAM,SAAU,aAAc,WAAY,YAAa,QAC9F,EAAG,CAAE,QAAS,IAAM,MAAM,SAAS,IAAI,KAAK,MAAM,KAAK,CAAC,CAAE,CAAG,EAC/D,EAED,SAAS,QAAQ,KAAY,CAAa,MAAM,KAAO,OAAgB,GAAG,EAAG,GAAI,OAAS,OAAW,MAAM,IAAI,UAAU,GAAG,IAAI,oCAAoC,EAAG,OAAO,IAAM,CAEpL,SAAS,kBACP,MACA,cAAwD,CAExD,OAAO,MAAM,SAAW,cAAc,QACjC,MAAM,MAAM,CAAC,KAAM,QAAS,CAC7B,MAAM,aAAe,cAAc,KAAK,EACxC,OAAO,eAAiB,QACnB,KAAK,KAAO,aAAa,IACzB,KAAK,QAAU,aAAa,KACnC,CAAC,CACL","names":["value"],"file":"combobox.js"}
|
package/dist/dialog.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const DialogContent: import("vue").Component;
|
|
|
9
9
|
export declare const DialogTitle: import("vue").Component;
|
|
10
10
|
export declare const DialogDescription: import("vue").Component;
|
|
11
11
|
export declare const DialogClose: import("vue").Component;
|
|
12
|
-
export type DialogRootProps = PopupRootProps
|
|
12
|
+
export type DialogRootProps = Omit<PopupRootProps, 'position'>;
|
|
13
13
|
export type DialogRootSlotProps = PopupRootSlotProps;
|
|
14
14
|
export type DialogPartProps = PopupPartProps;
|
|
15
15
|
export type DialogPortalProps = PopupPortalProps;
|
package/dist/drawer.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const DrawerDescription: import("vue").Component;
|
|
|
11
11
|
export declare const DrawerClose: import("vue").Component;
|
|
12
12
|
export type DrawerOpenChangeHandler = PopupFactoryOptions['onOpenChange'];
|
|
13
13
|
export type DrawerInteractOutsideHandler = NonNullable<PopupFactoryOptions['onInteractOutside']>;
|
|
14
|
-
export type DrawerRootProps = Omit<PopupRootProps, 'align' | 'sideOffset' | 'collisionPadding' | 'collisionBoundary' | 'avoidCollisions' | 'arrowPadding' | 'hideWhenDetached' | 'strategy' | 'tracking'> & {
|
|
14
|
+
export type DrawerRootProps = Omit<PopupRootProps, 'align' | 'sideOffset' | 'collisionPadding' | 'collisionBoundary' | 'avoidCollisions' | 'arrowPadding' | 'hideWhenDetached' | 'position' | 'strategy' | 'tracking'> & {
|
|
15
15
|
readonly side?: DrawerSide;
|
|
16
16
|
readonly swipeToDismiss?: boolean;
|
|
17
17
|
readonly swipeThreshold?: number;
|
package/dist/internal/popup.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface PopupFactoryOptions extends PositionOptions {
|
|
|
40
40
|
readonly onOpenChange: (open: boolean) => void;
|
|
41
41
|
readonly onUpdate: () => void;
|
|
42
42
|
readonly manageVisibility?: boolean;
|
|
43
|
+
readonly position?: boolean;
|
|
43
44
|
}
|
|
44
45
|
export interface PopupComponentConfig {
|
|
45
46
|
readonly scope: string;
|
|
@@ -69,6 +70,7 @@ export interface PopupRootProps extends PositionOptions {
|
|
|
69
70
|
readonly closeOnInteractOutside?: boolean;
|
|
70
71
|
readonly interactOutsideExclusions?: readonly HTMLElement[];
|
|
71
72
|
readonly unmountOnExit?: boolean;
|
|
73
|
+
readonly position?: boolean;
|
|
72
74
|
}
|
|
73
75
|
export interface PopupPartProps {
|
|
74
76
|
readonly as?: PrimitiveAs;
|
package/dist/internal/popup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Fragment,Teleport,computed,defineComponent,h,inject,mergeProps,nextTick,onBeforeUnmount,provide,ref,shallowRef,watch}from"vue";import{Primitive}from"../primitive.js";import{useHostDirection,useHostId,useHostPortalTarget}from"../host-provider.js";import{usePresence}from"./presence.js";import{useControlledStateInvariant}from"./controlled-state.js";function createPopupComponents(config){const contextKey=Symbol(`Sectile${config.scope}Root`);const useRoot=part=>{const context=inject(contextKey);if(context===void 0)throw new TypeError(`${part} must be used inside ${config.scope} Root.`);return context};const primitiveProps={as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}};const buttonProps={as:{type:[String,Object,Function],default:"button"},asChild:{type:Boolean,default:false}};const Root=defineComponent({name:`Sectile${pascal(config.scope)}Root`,inheritAttrs:false,props:{open:{type:Boolean,default:void 0},defaultOpen:{type:Boolean,default:false},disabled:{type:Boolean,default:false},modal:{type:Boolean,default:config.modal},label:{type:String,default:void 0},initialFocus:{type:Object,default:void 0},autoFocus:{type:Boolean,default:true},restoreFocus:{type:Boolean,default:true},trapFocus:{type:Boolean,default:config.modal},closeOnInteractOutside:{type:Boolean,default:config.closeOnInteractOutside??false},interactOutsideExclusions:{type:Array,default:void 0},side:{type:String,default:config.defaultSide??"bottom"},swipeToDismiss:{type:Boolean,default:true},swipeThreshold:{type:Number,default:80},swipeVelocityThreshold:{type:Number,default:.5},align:{type:String,default:"center"},sideOffset:{type:Number,default:8},collisionPadding:{type:[Number,Object],default:8},collisionBoundary:{type:[String,Object],default:void 0},avoidCollisions:{type:Boolean,default:true},arrowPadding:{type:Number,default:8},hideWhenDetached:{type:Boolean,default:false},strategy:{type:String,default:"absolute"},tracking:{type:String,default:"events"},unmountOnExit:{type:Boolean,default:false}},emits:{"update:open":_open=>true,interactOutside:_event=>true},slots:Object,setup(props,{emit,slots}){const controlled=useControlledStateInvariant(`${config.scope}Root`,"open",()=>props.open);const localOpen=ref(controlled?props.open:props.defaultOpen);const trigger=shallowRef();const anchor=shallowRef();const arrow=shallowRef();const overlay=shallowRef();const handle=shallowRef();const content=shallowRef();const connection=shallowRef();const id=useHostId();const contentID=`sectile-${config.scope}-${id}-content`;const titleID=`sectile-${config.scope}-${id}-title`;const descriptionID=`sectile-${config.scope}-${id}-description`;const open=computed(()=>localOpen.value);const disabled=computed(()=>props.disabled);const modal=computed(()=>props.modal);const unmountOnExit=computed(()=>props.unmountOnExit);const label=computed(()=>props.label);const side=computed(()=>props.side);const strategy=computed(()=>props.strategy);const update=()=>{if(connection.value===void 0)return;void connection.value.getSnapshot().revision};const disconnect=()=>{connection.value?.disconnect();connection.value=void 0};const connect=()=>{if(content.value===void 0)return;disconnect();connection.value=config.create({root:content.value,...trigger.value===void 0?{}:{trigger:trigger.value},...anchor.value===void 0?{}:{anchor:anchor.value},...arrow.value===void 0?{}:{arrow:arrow.value},...overlay.value===void 0?{}:{overlay:overlay.value},...handle.value===void 0?{}:{handle:handle.value},...controlled?{open:props.open}:{defaultOpen:localOpen.value},disabled:props.disabled,modal:props.modal,...props.label===void 0?{labelledBy:titleID}:{label:props.label},describedBy:descriptionID,...props.initialFocus===void 0?{}:{initialFocus:props.initialFocus},autoFocus:props.autoFocus,restoreFocus:props.restoreFocus,trapFocus:props.trapFocus,closeOnInteractOutside:props.closeOnInteractOutside,...props.interactOutsideExclusions===void 0?{}:{interactOutsideExclusions:props.interactOutsideExclusions},side:props.side,swipeToDismiss:props.swipeToDismiss,swipeThreshold:props.swipeThreshold,swipeVelocityThreshold:props.swipeVelocityThreshold,align:props.align,sideOffset:props.sideOffset,collisionPadding:props.collisionPadding,...props.collisionBoundary===void 0?{}:{collisionBoundary:props.collisionBoundary},avoidCollisions:props.avoidCollisions,arrowPadding:props.arrowPadding,hideWhenDetached:props.hideWhenDetached,strategy:props.strategy,tracking:props.tracking,manageVisibility:false,onOpenChange:next=>{if(!controlled)localOpen.value=next;emit("update:open",next)},onInteractOutside:event=>{emit("interactOutside",event)},onUpdate:update});update()};let connectScheduled=false;let destroyed=false;const scheduleConnect=()=>{if(connectScheduled||destroyed||props.unmountOnExit&&!localOpen.value)return;connectScheduled=true;void nextTick(()=>{connectScheduled=false;if(!destroyed)connect()})};const elements={trigger,anchor,arrow,overlay,handle,content};const registerElement=(part,element)=>{const target=elements[part];if(target.value===element)return;target.value=element;if(content.value===void 0)disconnect();else scheduleConnect()};const activateTrigger=event=>{if(event?.defaultPrevented===true||connection.value!==void 0||props.disabled||localOpen.value)return;if(!controlled)localOpen.value=true;emit("update:open",true)};const deactivateTrigger=event=>{if(event?.defaultPrevented===true||connection.value!==void 0||!localOpen.value)return;if(!controlled)localOpen.value=false;emit("update:open",false)};watch(()=>props.open,next=>{if(!controlled||next===void 0)return;if(connection.value===void 0){localOpen.value=next;return}const result=connection.value.syncControlledValue(next);if(!result.ok)throw new TypeError(`${config.scope} controlled open state could not be synchronized.`);localOpen.value=next});watch([()=>props.disabled,()=>props.modal,()=>props.label,()=>props.initialFocus,()=>props.autoFocus,()=>props.restoreFocus,()=>props.trapFocus,()=>props.closeOnInteractOutside,()=>props.interactOutsideExclusions,()=>props.side,()=>props.swipeToDismiss,()=>props.swipeThreshold,()=>props.swipeVelocityThreshold,()=>props.align,()=>props.sideOffset,()=>props.collisionPadding,()=>props.collisionBoundary,()=>props.avoidCollisions,()=>props.arrowPadding,()=>props.hideWhenDetached,()=>props.strategy,()=>props.tracking],connect);onBeforeUnmount(()=>{destroyed=true;disconnect()});provide(contextKey,{open,disabled,modal,unmountOnExit,label,contentID,titleID,descriptionID,side,strategy,registerElement,activateTrigger,deactivateTrigger,close:()=>{connection.value?.handleEvent("close")},refresh:()=>{connection.value?.refresh()}});return()=>h(Fragment,null,slots["default"]?.({open:open.value,disabled:props.disabled})??[])}});const Trigger=defineComponent({name:`Sectile${pascal(config.scope)}Trigger`,inheritAttrs:false,props:buttonProps,setup(props,{attrs,slots}){const root=useRoot("Trigger");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:element=>{root.registerElement("trigger",element instanceof HTMLElement?element:void 0)},...config.triggerMode==="click"?{onClick:root.activateTrigger}:{onFocus:root.activateTrigger,onBlur:root.deactivateTrigger,onMouseenter:root.activateTrigger,onMouseleave:root.deactivateTrigger},type:props.as==="button"?"button":void 0,disabled:root.disabled.value,"aria-haspopup":config.role==="tooltip"?void 0:"dialog","aria-expanded":config.triggerMode==="click"?String(root.open.value):void 0,"aria-controls":config.role==="tooltip"?void 0:root.contentID,"aria-describedby":config.role==="tooltip"?root.contentID:void 0,"data-scope":config.scope,"data-part":"trigger","data-state":root.open.value?"open":"closed"}),slots)}});const Content=defineComponent({name:`Sectile${pascal(config.scope)}Content`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Content");const direction=useHostDirection();const element=shallowRef();const present=usePresence(root.open,element);watch(present,async()=>{await nextTick();root.refresh()},{flush:"post"});return()=>{if(root.unmountOnExit.value&&!present.value)return null;return h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:candidate=>{const node=candidate instanceof HTMLElement?candidate:void 0;element.value=node;root.registerElement("content",node)},id:root.contentID,role:config.role,hidden:!present.value,dir:direction.value,style:config.positioned===true?{position:root.strategy.value,visibility:element.value===void 0?"hidden":void 0}:void 0,"aria-modal":config.role==="tooltip"?void 0:String(root.modal.value),"aria-label":root.label.value,"aria-labelledby":root.label.value===void 0?root.titleID:void 0,"aria-describedby":root.descriptionID,"data-scope":config.scope,"data-part":"content","data-state":root.open.value?"open":"closed","data-side":config.directional===true?root.side.value:void 0,"data-swipe-direction":config.directional===true?swipeDirection(root.side.value):void 0}),slots)}}});const Anchor=defineComponent({name:`Sectile${pascal(config.scope)}Anchor`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Anchor");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:element=>{root.registerElement("anchor",element instanceof HTMLElement?element:void 0)},"data-scope":config.scope,"data-part":"anchor"}),slots)}});const Arrow=defineComponent({name:`Sectile${pascal(config.scope)}Arrow`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Arrow");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:element=>{root.registerElement("arrow",element instanceof HTMLElement?element:void 0)},"aria-hidden":"true","data-scope":config.scope,"data-part":"arrow"}),slots)}});const Overlay=defineComponent({name:`Sectile${pascal(config.scope)}Overlay`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Overlay");const element=shallowRef();const present=usePresence(root.open,element);return()=>{if(root.unmountOnExit.value&&!present.value)return null;return h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:candidate=>{const node=candidate instanceof HTMLElement?candidate:void 0;element.value=node;root.registerElement("overlay",node)},hidden:!present.value,"aria-hidden":"true","data-scope":config.scope,"data-part":"overlay","data-state":root.open.value?"open":"closed","data-side":config.directional===true?root.side.value:void 0,"data-swipe-direction":config.directional===true?swipeDirection(root.side.value):void 0}),slots)}}});const Handle=defineComponent({name:`Sectile${pascal(config.scope)}Handle`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Handle");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:candidate=>{root.registerElement("handle",candidate instanceof HTMLElement?candidate:void 0)},"aria-hidden":"true","data-scope":config.scope,"data-part":"handle","data-state":root.open.value?"open":"closed","data-side":config.directional===true?root.side.value:void 0,"data-swipe-direction":config.directional===true?swipeDirection(root.side.value):void 0}),slots)}});const Title=createLabelPart("Title","title",root=>root.titleID);const Description=createLabelPart("Description","description",root=>root.descriptionID);const Close=defineComponent({name:`Sectile${pascal(config.scope)}Close`,inheritAttrs:false,props:buttonProps,setup(props,{attrs,slots}){const root=useRoot("Close");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,type:props.as==="button"?"button":void 0,"data-scope":config.scope,"data-part":"close",onClick:root.close}),slots)}});const Portal=defineComponent({name:`Sectile${pascal(config.scope)}Portal`,inheritAttrs:false,props:{to:{type:[String,Object],default:void 0},disabled:{type:Boolean,default:false},defer:{type:Boolean,default:false}},setup(props,{slots}){const portalTarget=useHostPortalTarget();return()=>h(Teleport,{to:props.to??portalTarget.value??"body",disabled:props.disabled,defer:props.defer},slots["default"]?.())}});function createLabelPart(name,part,id){return defineComponent({name:`Sectile${pascal(config.scope)}${name}`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot(name);return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,id:id(root),"data-scope":config.scope,"data-part":part}),slots)}})}return Object.freeze({Root,Trigger,Anchor,Portal,Overlay,Content,Handle,Title,Description,Close,Arrow})}function pascal(value){return value.split("-").map(part=>part[0]?.toUpperCase()+part.slice(1)).join("")}function swipeDirection(side){return side==="top"?"up":side==="bottom"?"down":side}export{createPopupComponents};
|
|
1
|
+
import{Fragment,Teleport,computed,defineComponent,h,inject,mergeProps,nextTick,onBeforeUnmount,provide,ref,shallowRef,watch}from"vue";import{Primitive}from"../primitive.js";import{useHostDirection,useHostId,useHostPortalTarget}from"../host-provider.js";import{usePresence}from"./presence.js";import{useControlledStateInvariant}from"./controlled-state.js";function createPopupComponents(config){const contextKey=Symbol(`Sectile${config.scope}Root`);const useRoot=part=>{const context=inject(contextKey);if(context===void 0)throw new TypeError(`${part} must be used inside ${config.scope} Root.`);return context};const primitiveProps={as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}};const buttonProps={as:{type:[String,Object,Function],default:"button"},asChild:{type:Boolean,default:false}};const Root=defineComponent({name:`Sectile${pascal(config.scope)}Root`,inheritAttrs:false,props:{open:{type:Boolean,default:void 0},defaultOpen:{type:Boolean,default:false},disabled:{type:Boolean,default:false},modal:{type:Boolean,default:config.modal},label:{type:String,default:void 0},initialFocus:{type:Object,default:void 0},autoFocus:{type:Boolean,default:true},restoreFocus:{type:Boolean,default:true},trapFocus:{type:Boolean,default:config.modal},closeOnInteractOutside:{type:Boolean,default:config.closeOnInteractOutside??false},interactOutsideExclusions:{type:Array,default:void 0},side:{type:String,default:config.defaultSide??"bottom"},position:{type:Boolean,default:true},swipeToDismiss:{type:Boolean,default:true},swipeThreshold:{type:Number,default:80},swipeVelocityThreshold:{type:Number,default:.5},align:{type:String,default:"center"},sideOffset:{type:Number,default:8},collisionPadding:{type:[Number,Object],default:8},collisionBoundary:{type:[String,Object],default:void 0},avoidCollisions:{type:Boolean,default:true},arrowPadding:{type:Number,default:8},hideWhenDetached:{type:Boolean,default:false},strategy:{type:String,default:"absolute"},tracking:{type:String,default:"events"},unmountOnExit:{type:Boolean,default:false}},emits:{"update:open":_open=>true,interactOutside:_event=>true},slots:Object,setup(props,{emit,slots}){const controlled=useControlledStateInvariant(`${config.scope}Root`,"open",()=>props.open);const localOpen=ref(controlled?props.open:props.defaultOpen);const trigger=shallowRef();const anchor=shallowRef();const arrow=shallowRef();const overlay=shallowRef();const handle=shallowRef();const content=shallowRef();const connection=shallowRef();const id=useHostId();const contentID=`sectile-${config.scope}-${id}-content`;const titleID=`sectile-${config.scope}-${id}-title`;const descriptionID=`sectile-${config.scope}-${id}-description`;const open=computed(()=>localOpen.value);const disabled=computed(()=>props.disabled);const modal=computed(()=>props.modal);const unmountOnExit=computed(()=>props.unmountOnExit);const label=computed(()=>props.label);const side=computed(()=>props.side);const position=computed(()=>props.position);const strategy=computed(()=>props.strategy);const update=()=>{if(connection.value===void 0)return;void connection.value.getSnapshot().revision};const disconnect=()=>{connection.value?.disconnect();connection.value=void 0};const connect=()=>{if(content.value===void 0)return;disconnect();connection.value=config.create({root:content.value,...trigger.value===void 0?{}:{trigger:trigger.value},...anchor.value===void 0?{}:{anchor:anchor.value},...arrow.value===void 0?{}:{arrow:arrow.value},...overlay.value===void 0?{}:{overlay:overlay.value},...handle.value===void 0?{}:{handle:handle.value},...controlled?{open:props.open}:{defaultOpen:localOpen.value},disabled:props.disabled,modal:props.modal,...props.label===void 0?{labelledBy:titleID}:{label:props.label},describedBy:descriptionID,...props.initialFocus===void 0?{}:{initialFocus:props.initialFocus},autoFocus:props.autoFocus,restoreFocus:props.restoreFocus,trapFocus:props.trapFocus,closeOnInteractOutside:props.closeOnInteractOutside,...props.interactOutsideExclusions===void 0?{}:{interactOutsideExclusions:props.interactOutsideExclusions},side:props.side,...config.positioned===true?{position:props.position}:{},swipeToDismiss:props.swipeToDismiss,swipeThreshold:props.swipeThreshold,swipeVelocityThreshold:props.swipeVelocityThreshold,align:props.align,sideOffset:props.sideOffset,collisionPadding:props.collisionPadding,...props.collisionBoundary===void 0?{}:{collisionBoundary:props.collisionBoundary},avoidCollisions:props.avoidCollisions,arrowPadding:props.arrowPadding,hideWhenDetached:props.hideWhenDetached,strategy:props.strategy,tracking:props.tracking,manageVisibility:false,onOpenChange:next=>{if(!controlled)localOpen.value=next;emit("update:open",next)},onInteractOutside:event=>{emit("interactOutside",event)},onUpdate:update});update()};let connectScheduled=false;let destroyed=false;const scheduleConnect=()=>{if(connectScheduled||destroyed||props.unmountOnExit&&!localOpen.value)return;connectScheduled=true;void nextTick(()=>{connectScheduled=false;if(!destroyed)connect()})};const elements={trigger,anchor,arrow,overlay,handle,content};const registerElement=(part,element)=>{const target=elements[part];if(target.value===element)return;target.value=element;if(content.value===void 0)disconnect();else scheduleConnect()};const activateTrigger=event=>{if(event?.defaultPrevented===true||connection.value!==void 0||props.disabled||localOpen.value)return;if(!controlled)localOpen.value=true;emit("update:open",true)};const deactivateTrigger=event=>{if(event?.defaultPrevented===true||connection.value!==void 0||!localOpen.value)return;if(!controlled)localOpen.value=false;emit("update:open",false)};watch(()=>props.open,next=>{if(!controlled||next===void 0)return;if(connection.value===void 0){localOpen.value=next;return}const result=connection.value.syncControlledValue(next);if(!result.ok)throw new TypeError(`${config.scope} controlled open state could not be synchronized.`);localOpen.value=next});watch([()=>props.disabled,()=>props.modal,()=>props.label,()=>props.initialFocus,()=>props.autoFocus,()=>props.restoreFocus,()=>props.trapFocus,()=>props.closeOnInteractOutside,()=>props.interactOutsideExclusions,()=>props.side,()=>props.position,()=>props.swipeToDismiss,()=>props.swipeThreshold,()=>props.swipeVelocityThreshold,()=>props.align,()=>props.sideOffset,()=>props.collisionPadding,()=>props.collisionBoundary,()=>props.avoidCollisions,()=>props.arrowPadding,()=>props.hideWhenDetached,()=>props.strategy,()=>props.tracking],connect);onBeforeUnmount(()=>{destroyed=true;disconnect()});provide(contextKey,{open,disabled,modal,unmountOnExit,label,contentID,titleID,descriptionID,side,position,strategy,registerElement,activateTrigger,deactivateTrigger,close:()=>{connection.value?.handleEvent("close")},refresh:()=>{connection.value?.refresh()}});return()=>h(Fragment,null,slots["default"]?.({open:open.value,disabled:props.disabled})??[])}});const Trigger=defineComponent({name:`Sectile${pascal(config.scope)}Trigger`,inheritAttrs:false,props:buttonProps,setup(props,{attrs,slots}){const root=useRoot("Trigger");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:element=>{root.registerElement("trigger",element instanceof HTMLElement?element:void 0)},...config.triggerMode==="click"?{onClick:root.activateTrigger}:{onFocus:root.activateTrigger,onBlur:root.deactivateTrigger,onMouseenter:root.activateTrigger,onMouseleave:root.deactivateTrigger},type:props.as==="button"?"button":void 0,disabled:root.disabled.value,"aria-haspopup":config.role==="tooltip"?void 0:"dialog","aria-expanded":config.triggerMode==="click"?String(root.open.value):void 0,"aria-controls":config.role==="tooltip"?void 0:root.contentID,"aria-describedby":config.role==="tooltip"?root.contentID:void 0,"data-scope":config.scope,"data-part":"trigger","data-state":root.open.value?"open":"closed"}),slots)}});const Content=defineComponent({name:`Sectile${pascal(config.scope)}Content`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Content");const direction=useHostDirection();const element=shallowRef();const present=usePresence(root.open,element);watch(present,async()=>{await nextTick();root.refresh()},{flush:"post"});return()=>{if(root.unmountOnExit.value&&!present.value)return null;return h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:candidate=>{const node=candidate instanceof HTMLElement?candidate:void 0;element.value=node;root.registerElement("content",node)},id:root.contentID,role:config.role,hidden:!present.value,dir:direction.value,style:config.positioned===true&&root.position.value?{position:root.strategy.value,visibility:element.value===void 0?"hidden":void 0}:void 0,"aria-modal":config.role==="tooltip"?void 0:String(root.modal.value),"aria-label":root.label.value,"aria-labelledby":root.label.value===void 0?root.titleID:void 0,"aria-describedby":root.descriptionID,"data-scope":config.scope,"data-part":"content","data-state":root.open.value?"open":"closed","data-side":config.directional===true?root.side.value:void 0,"data-swipe-direction":config.directional===true?swipeDirection(root.side.value):void 0}),slots)}}});const Anchor=defineComponent({name:`Sectile${pascal(config.scope)}Anchor`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Anchor");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:element=>{root.registerElement("anchor",element instanceof HTMLElement?element:void 0)},"data-scope":config.scope,"data-part":"anchor"}),slots)}});const Arrow=defineComponent({name:`Sectile${pascal(config.scope)}Arrow`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Arrow");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:element=>{root.registerElement("arrow",element instanceof HTMLElement?element:void 0)},"aria-hidden":"true","data-scope":config.scope,"data-part":"arrow"}),slots)}});const Overlay=defineComponent({name:`Sectile${pascal(config.scope)}Overlay`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Overlay");const element=shallowRef();const present=usePresence(root.open,element);return()=>{if(root.unmountOnExit.value&&!present.value)return null;return h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:candidate=>{const node=candidate instanceof HTMLElement?candidate:void 0;element.value=node;root.registerElement("overlay",node)},hidden:!present.value,"aria-hidden":"true","data-scope":config.scope,"data-part":"overlay","data-state":root.open.value?"open":"closed","data-side":config.directional===true?root.side.value:void 0,"data-swipe-direction":config.directional===true?swipeDirection(root.side.value):void 0}),slots)}}});const Handle=defineComponent({name:`Sectile${pascal(config.scope)}Handle`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot("Handle");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,elementRef:candidate=>{root.registerElement("handle",candidate instanceof HTMLElement?candidate:void 0)},"aria-hidden":"true","data-scope":config.scope,"data-part":"handle","data-state":root.open.value?"open":"closed","data-side":config.directional===true?root.side.value:void 0,"data-swipe-direction":config.directional===true?swipeDirection(root.side.value):void 0}),slots)}});const Title=createLabelPart("Title","title",root=>root.titleID);const Description=createLabelPart("Description","description",root=>root.descriptionID);const Close=defineComponent({name:`Sectile${pascal(config.scope)}Close`,inheritAttrs:false,props:buttonProps,setup(props,{attrs,slots}){const root=useRoot("Close");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,type:props.as==="button"?"button":void 0,"data-scope":config.scope,"data-part":"close",onClick:root.close}),slots)}});const Portal=defineComponent({name:`Sectile${pascal(config.scope)}Portal`,inheritAttrs:false,props:{to:{type:[String,Object],default:void 0},disabled:{type:Boolean,default:false},defer:{type:Boolean,default:false}},setup(props,{slots}){const portalTarget=useHostPortalTarget();return()=>h(Teleport,{to:props.to??portalTarget.value??"body",disabled:props.disabled,defer:props.defer},slots["default"]?.())}});function createLabelPart(name,part,id){return defineComponent({name:`Sectile${pascal(config.scope)}${name}`,inheritAttrs:false,props:primitiveProps,setup(props,{attrs,slots}){const root=useRoot(name);return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,id:id(root),"data-scope":config.scope,"data-part":part}),slots)}})}return Object.freeze({Root,Trigger,Anchor,Portal,Overlay,Content,Handle,Title,Description,Close,Arrow})}function pascal(value){return value.split("-").map(part=>part[0]?.toUpperCase()+part.slice(1)).join("")}function swipeDirection(side){return side==="top"?"up":side==="bottom"?"down":side}export{createPopupComponents};
|
|
2
2
|
//# sourceMappingURL=popup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/internal/popup.ts"],"mappings":"AAAA,OACE,SACA,SACA,SACA,gBACA,EACA,OACA,WACA,SACA,gBACA,QACA,IACA,WACA,UAMK,MASP,OAAS,cAAmC,kBAC5C,OAAS,iBAAkB,UAAW,wBAA2B,sBACjE,OAAS,gBAAmB,gBAC5B,OAAS,gCAAmC,wBA4FtC,SAAU,sBAAsB,OAA4B,CAahE,MAAM,WAAa,OAAO,UAAU,OAAO,KAAK,MAAM,EACtD,MAAM,QAAW,MAA8B,CAC7C,MAAM,QAAU,OAAqB,UAAU,EAC/C,GAAI,UAAY,OAAW,MAAM,IAAI,UAAU,GAAG,IAAI,wBAAwB,OAAO,KAAK,QAAQ,EAClG,OAAO,OACT,EACA,MAAM,eAAiB,CACrB,GAAI,CAAE,KAAM,CAAC,OAAQ,OAAQ,QAAQ,EAA4B,QAAS,KAAK,EAC/E,QAAS,CAAE,KAAM,QAAS,QAAS,KAAK,GAE1C,MAAM,YAAc,CAClB,GAAI,CAAE,KAAM,CAAC,OAAQ,OAAQ,QAAQ,EAA4B,QAAS,QAAQ,EAClF,QAAS,CAAE,KAAM,QAAS,QAAS,KAAK,GAG1C,MAAM,KAAO,gBAAgB,CAC3B,KAAM,UAAU,OAAO,OAAO,KAAK,CAAC,OACpC,aAAc,MACd,MAAO,CACL,KAAM,CAAE,KAAM,QAAS,QAAS,MAAS,EACzC,YAAa,CAAE,KAAM,QAAS,QAAS,KAAK,EAC5C,SAAU,CAAE,KAAM,QAAS,QAAS,KAAK,EACzC,MAAO,CAAE,KAAM,QAAS,QAAS,OAAO,KAAK,EAC7C,MAAO,CA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AC/D,OAAO,OAAS,MAAQ,KAAO,OAAS,SAAW,OAAS,IAC9D","names":[],"file":"popup.js"}
|
package/dist/listbox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{computed,defineComponent,h,inject,mergeProps,nextTick,provide,shallowRef,watch}from"vue";import{DEFAULT_LISTBOX_SELECTION_MODE,createListboxControllerFromItems,getListboxItemAttributes,getListboxRootAttributes}from"@sectile/dom/listbox";import{Primitive}from"./primitive.js";import{visuallyHiddenInputStyle}from"./internal/native-input.js";import{hiddenSelectSubmissionCapabilities,useCompositeFormControl}from"./internal/form-control.js";import{useHostDirection,useHostId}from"./host-provider.js";import{reconcileCollectionState,sameIDs}from"./internal/collection.js";import{useControlledStateInvariant}from"./internal/controlled-state.js";const listboxRootContextKey=Symbol("SectileListboxRoot");const listboxItemContextKey=Symbol("SectileListboxItem");const listboxPartProps={as:{type:[String,Object,Function],default:"span"},asChild:{type:Boolean,default:false}};const ListboxRoot=defineComponent({name:"SectileListboxRoot",inheritAttrs:false,props:{items:{type:Array,required:true},selectionMode:{type:String,default:DEFAULT_LISTBOX_SELECTION_MODE},modelValue:{type:[String,Array],default:void 0},defaultValue:{type:[String,Array],default:void 0},disabledItems:{type:Array,default:()=>[]},disabled:{type:Boolean,default:false},readonly:{type:Boolean,default:false},orientation:{type:String,default:"vertical"},name:{type:String,default:void 0},form:{type:String,default:void 0},required:{type:Boolean,default:false},textValue:{type:Function,default:void 0},as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},emits:{"update:modelValue":_value=>true,highlight:_value=>true,activate:_value=>true},slots:Object,setup(props,{attrs,emit,slots}){const direction=useHostDirection();const instanceID=useHostId();const itemID=id=>`sectile-listbox-${instanceID}-option-${encodeURIComponent(id).replaceAll("%","-")}`;const rootElement=shallowRef(null);const submissionElement=shallowRef(null);let controllerProps=snapshotListboxControllerProps({...props,direction:direction.value});const participation=useCompositeFormControl({root:rootElement,submissions:[{element:submissionElement,capabilities:hiddenSelectSubmissionCapabilities}],reset:()=>{queueMicrotask(()=>{const next=controlled?toIDs(props.modelValue,props.selectionMode):initialValue;controller.value=createController(controlled,next,next[0]??firstEnabledItem(controllerProps)??null,controllerProps,emit);snapshot.value=controller.value.getSnapshot()})}});const controlled=useControlledStateInvariant("ListboxRoot","modelValue",()=>props.modelValue);const initialValue=toIDs(controlled?props.modelValue:props.defaultValue,props.selectionMode);const controller=shallowRef(createController(controlled,initialValue,initialValue[0]??firstEnabledItem(controllerProps)??null,controllerProps,emit));const snapshot=shallowRef(controller.value.getSnapshot());const rebuild=()=>{const nextControllerProps=snapshotListboxControllerProps({...props,direction:direction.value});if(sameListboxControllerProps(controllerProps,nextControllerProps)){return}const requested=controlled?toIDs(props.modelValue,props.selectionMode):snapshot.value.state.selection.selected;const reconciled=reconcileCollectionState(nextControllerProps.items,requested,snapshot.value.state.cursor.current,nextControllerProps.disabledItems,nextControllerProps.selectionMode);controller.value=createController(controlled,reconciled.selected,reconciled.current,nextControllerProps,emit);controllerProps=nextControllerProps;snapshot.value=controller.value.getSnapshot();if(controlled&&!sameIDs(requested,reconciled.selected)){emit("update:modelValue",fromIDs(reconciled.selected,props.selectionMode))}};watch(()=>props.modelValue,value=>{if(!controlled||value===void 0)return;const result=controller.value.syncControlledValues({value:toIDs(value,props.selectionMode)});if(!result.ok)throw new TypeError(result.error.message);snapshot.value=result.value});watch([()=>props.items,()=>props.selectionMode,()=>props.disabledItems,()=>props.disabled,()=>props.readonly,()=>props.orientation,()=>props.textValue,direction],rebuild);const selectedIDs=computed(()=>snapshot.value.state.selection.selected);const selectedIDSet=computed(()=>new Set(selectedIDs.value));const highlightedValue=computed(()=>snapshot.value.state.cursor.current);const disabled=computed(()=>props.disabled);const readonly=computed(()=>props.readonly);const disabledItems=computed(()=>new Set(props.disabledItems));const slotProps=computed(()=>Object.freeze({value:fromIDs(selectedIDs.value,props.selectionMode),highlightedValue:highlightedValue.value,disabled:disabled.value,readonly:readonly.value}));const applyResult=(result,root)=>{if(!result.ok)return false;snapshot.value=result.snapshot;applyEffects(result.commands,emit);if(root!==void 0)void nextTick(()=>root.focus());return true};const select=(id,target)=>{const event=props.selectionMode==="multiple"?{type:"toggle",id}:{type:"activate",id};applyResult(controller.value.handleEvent(event),target.closest('[role="listbox"]'))};const handleKeydown=event=>{const result=controller.value.handleKeyboardInput(event);if(!applyResult(result,event.currentTarget))return;event.preventDefault()};provide(listboxRootContextKey,{selectedIDs,selectedIDSet,highlightedValue,disabled,readonly,disabledItems,itemID,select});const rootAttributes=computed(()=>getListboxRootAttributes({selectionMode:props.selectionMode,orientation:props.orientation,direction:direction.value,disabled:props.disabled,readOnly:props.readonly,...highlightedValue.value===null?{}:{activeDescendantID:itemID(highlightedValue.value)}}));return()=>{const root=h(Primitive,mergeProps(attrs,rootAttributes.value,{as:props.as,asChild:props.asChild,onKeydown:handleKeydown,elementRef:element=>{rootElement.value=element}},participation.controlProps.value),{default:()=>slots["default"]?.(slotProps.value)});if(!participation.participating&&props.name===void 0&&props.form===void 0&&!props.required)return root;return[root,h("select",{ref:submissionElement,name:props.name,form:props.form,required:props.required,multiple:props.selectionMode==="multiple",tabindex:-1,"aria-hidden":"true",style:visuallyHiddenInputStyle},props.items.map(id=>h("option",{value:id,selected:selectedIDSet.value.has(id)},id)))]}}});const ListboxItem=defineComponent({name:"SectileListboxItem",inheritAttrs:false,props:{value:{type:String,required:true},disabled:{type:Boolean,default:false},as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},slots:Object,setup(props,{attrs,slots}){const root=useListboxRootContext("ListboxItem");const slotProps=computed(()=>Object.freeze({value:props.value,selected:root.selectedIDSet.value.has(props.value),highlighted:root.highlightedValue.value===props.value,disabled:root.disabled.value||props.disabled||root.disabledItems.value.has(props.value)}));provide(listboxItemContextKey,{slotProps});const attributes=computed(()=>getListboxItemAttributes({cursor:{current:root.highlightedValue.value},selection:{has:id=>root.selectedIDSet.value.has(id)}},{id:props.value,disabled:props.disabled},{disabled:slotProps.value.disabled,elementID:root.itemID(props.value)}));const handleClick=event=>{if(!event.defaultPrevented&&!slotProps.value.disabled){root.select(props.value,event.currentTarget)}};return()=>h(Primitive,mergeProps(attrs,attributes.value,{as:props.as,asChild:props.asChild,onClick:handleClick}),{default:()=>slots["default"]?.(slotProps.value)})}});const ListboxItemText=defineComponent({name:"SectileListboxItemText",inheritAttrs:false,props:listboxPartProps,slots:Object,setup(props,{attrs,slots}){const item=useListboxItemContext("ListboxItemText");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,"data-scope":"listbox","data-part":"item-text","data-state":item.slotProps.value.selected?"checked":"unchecked"}),{default:()=>slots["default"]?.(item.slotProps.value)})}});const ListboxItemIndicator=defineComponent({name:"SectileListboxItemIndicator",inheritAttrs:false,props:listboxPartProps,slots:Object,setup(props,{attrs,slots}){const item=useListboxItemContext("ListboxItemIndicator");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,hidden:!item.slotProps.value.selected,"aria-hidden":"true","data-scope":"listbox","data-part":"item-indicator","data-state":item.slotProps.value.selected?"checked":"unchecked"}),{default:()=>slots["default"]?.(item.slotProps.value)})}});function useListboxRootContext(part){const context=inject(listboxRootContextKey);if(context===void 0)throw new TypeError(`${part} must be used inside ListboxRoot.`);return context}function snapshotListboxControllerProps(props){return Object.freeze({...props,items:Object.freeze([...props.items]),disabledItems:Object.freeze([...props.disabledItems])})}function sameListboxControllerProps(left,right){return sameIDs(left.items,right.items)&&sameIDs(left.disabledItems,right.disabledItems)&&left.selectionMode===right.selectionMode&&left.disabled===right.disabled&&left.readonly===right.readonly&&left.orientation===right.orientation&&left.direction===right.direction&&left.textValue===right.textValue}function firstEnabledItem(props){if(props.disabledItems.length===0)return props.items[0];const disabled=new Set(props.disabledItems);return props.items.find(id=>!disabled.has(id))}function useListboxItemContext(part){const context=inject(listboxItemContextKey);if(context===void 0)throw new TypeError(`${part} must be used inside ListboxItem.`);return context}function createController(controlled,value,highlightedValue,props,emit){const result=createListboxControllerFromItems({items:props.items,selectionMode:props.selectionMode,disabledItems:props.disabledItems,disabled:props.disabled,readOnly:props.readonly,orientation:props.orientation,direction:props.direction,typeahead:{textValue:props.textValue??(id=>id)},...controlled?{value}:{defaultValue:value},defaultHighlightedValue:highlightedValue,onValueChange:change=>emit("update:modelValue",fromIDs(change.value,props.selectionMode)),onHighlightedValueChange:change=>emit("highlight",change.value)});if(!result.ok)throw new TypeError(result.error.message);return result.value}function applyEffects(effects,emit){for(const effect of effects){if(effect.type==="dispatch-activation")emit("activate",effect.id)}}function toIDs(value,mode){if(value===void 0||value==="")return[];if(Array.isArray(value))return mode==="single"?value.slice(0,1):value;return[value]}function fromIDs(value,mode){return mode==="single"?value[0]??"":value}export{ListboxItem,ListboxItemIndicator,ListboxItemText,ListboxRoot};
|
|
1
|
+
import{computed,defineComponent,h,inject,mergeProps,nextTick,provide,shallowRef,watch}from"vue";import{DEFAULT_LISTBOX_SELECTION_MODE,createListboxControllerFromItems,getListboxItemAttributes,getListboxRootAttributes}from"@sectile/dom/listbox";import{stableIDElementToken}from"@sectile/dom/identity";import{Primitive}from"./primitive.js";import{visuallyHiddenInputStyle}from"./internal/native-input.js";import{hiddenSelectSubmissionCapabilities,useCompositeFormControl}from"./internal/form-control.js";import{useHostDirection,useHostId}from"./host-provider.js";import{reconcileCollectionState,sameIDs}from"./internal/collection.js";import{useControlledStateInvariant}from"./internal/controlled-state.js";const listboxRootContextKey=Symbol("SectileListboxRoot");const listboxItemContextKey=Symbol("SectileListboxItem");const listboxPartProps={as:{type:[String,Object,Function],default:"span"},asChild:{type:Boolean,default:false}};const ListboxRoot=defineComponent({name:"SectileListboxRoot",inheritAttrs:false,props:{items:{type:Array,required:true},selectionMode:{type:String,default:DEFAULT_LISTBOX_SELECTION_MODE},modelValue:{type:[String,Array],default:void 0},defaultValue:{type:[String,Array],default:void 0},disabledItems:{type:Array,default:()=>[]},disabled:{type:Boolean,default:false},readonly:{type:Boolean,default:false},orientation:{type:String,default:"vertical"},name:{type:String,default:void 0},form:{type:String,default:void 0},required:{type:Boolean,default:false},textValue:{type:Function,default:void 0},as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},emits:{"update:modelValue":_value=>true,highlight:_value=>true,activate:_value=>true},slots:Object,setup(props,{attrs,emit,slots}){const direction=useHostDirection();const instanceID=useHostId();const itemID=id=>`sectile-listbox-${instanceID}-option-${stableIDElementToken(id)}`;const rootElement=shallowRef(null);const submissionElement=shallowRef(null);let controllerProps=snapshotListboxControllerProps({...props,direction:direction.value});const participation=useCompositeFormControl({root:rootElement,submissions:[{element:submissionElement,capabilities:hiddenSelectSubmissionCapabilities}],reset:()=>{queueMicrotask(()=>{const next=controlled?toIDs(props.modelValue,props.selectionMode):initialValue;controller.value=createController(controlled,next,next[0]??firstEnabledItem(controllerProps)??null,controllerProps,emit);snapshot.value=controller.value.getSnapshot()})}});const controlled=useControlledStateInvariant("ListboxRoot","modelValue",()=>props.modelValue);const initialValue=toIDs(controlled?props.modelValue:props.defaultValue,props.selectionMode);const controller=shallowRef(createController(controlled,initialValue,initialValue[0]??firstEnabledItem(controllerProps)??null,controllerProps,emit));const snapshot=shallowRef(controller.value.getSnapshot());const rebuild=()=>{const nextControllerProps=snapshotListboxControllerProps({...props,direction:direction.value});if(sameListboxControllerProps(controllerProps,nextControllerProps)){return}const requested=controlled?toIDs(props.modelValue,props.selectionMode):snapshot.value.state.selection.selected;const reconciled=reconcileCollectionState(nextControllerProps.items,requested,snapshot.value.state.cursor.current,nextControllerProps.disabledItems,nextControllerProps.selectionMode);controller.value=createController(controlled,reconciled.selected,reconciled.current,nextControllerProps,emit);controllerProps=nextControllerProps;snapshot.value=controller.value.getSnapshot();if(controlled&&!sameIDs(requested,reconciled.selected)){emit("update:modelValue",fromIDs(reconciled.selected,props.selectionMode))}};watch(()=>props.modelValue,value=>{if(!controlled||value===void 0)return;const result=controller.value.syncControlledValues({value:toIDs(value,props.selectionMode)});if(!result.ok)throw new TypeError(result.error.message);snapshot.value=result.value});watch([()=>props.items,()=>props.selectionMode,()=>props.disabledItems,()=>props.disabled,()=>props.readonly,()=>props.orientation,()=>props.textValue,direction],rebuild);const selectedIDs=computed(()=>snapshot.value.state.selection.selected);const selectedIDSet=computed(()=>new Set(selectedIDs.value));const highlightedValue=computed(()=>snapshot.value.state.cursor.current);const disabled=computed(()=>props.disabled);const readonly=computed(()=>props.readonly);const disabledItems=computed(()=>new Set(props.disabledItems));const slotProps=computed(()=>Object.freeze({value:fromIDs(selectedIDs.value,props.selectionMode),highlightedValue:highlightedValue.value,disabled:disabled.value,readonly:readonly.value}));const applyResult=(result,root)=>{if(!result.ok)return false;snapshot.value=result.snapshot;applyEffects(result.commands,emit);if(root!==void 0)void nextTick(()=>root.focus());return true};const select=(id,target)=>{const event=props.selectionMode==="multiple"?{type:"toggle",id}:{type:"activate",id};applyResult(controller.value.handleEvent(event),target.closest('[role="listbox"]'))};const handleKeydown=event=>{const result=controller.value.handleKeyboardInput(event);if(!applyResult(result,event.currentTarget))return;event.preventDefault()};provide(listboxRootContextKey,{selectedIDs,selectedIDSet,highlightedValue,disabled,readonly,disabledItems,itemID,select});const rootAttributes=computed(()=>getListboxRootAttributes({selectionMode:props.selectionMode,orientation:props.orientation,direction:direction.value,disabled:props.disabled,readOnly:props.readonly,...highlightedValue.value===null?{}:{activeDescendantID:itemID(highlightedValue.value)}}));return()=>{const root=h(Primitive,mergeProps(attrs,rootAttributes.value,{as:props.as,asChild:props.asChild,onKeydown:handleKeydown,elementRef:element=>{rootElement.value=element}},participation.controlProps.value),{default:()=>slots["default"]?.(slotProps.value)});if(!participation.participating&&props.name===void 0&&props.form===void 0&&!props.required)return root;return[root,h("select",{ref:submissionElement,name:props.name,form:props.form,required:props.required,multiple:props.selectionMode==="multiple",tabindex:-1,"aria-hidden":"true",style:visuallyHiddenInputStyle},props.items.map(id=>h("option",{value:id,selected:selectedIDSet.value.has(id)},id)))]}}});const ListboxItem=defineComponent({name:"SectileListboxItem",inheritAttrs:false,props:{value:{type:String,required:true},disabled:{type:Boolean,default:false},as:{type:[String,Object,Function],default:"div"},asChild:{type:Boolean,default:false}},slots:Object,setup(props,{attrs,slots}){const root=useListboxRootContext("ListboxItem");const slotProps=computed(()=>Object.freeze({value:props.value,selected:root.selectedIDSet.value.has(props.value),highlighted:root.highlightedValue.value===props.value,disabled:root.disabled.value||props.disabled||root.disabledItems.value.has(props.value)}));provide(listboxItemContextKey,{slotProps});const attributes=computed(()=>getListboxItemAttributes({cursor:{current:root.highlightedValue.value},selection:{has:id=>root.selectedIDSet.value.has(id)}},{id:props.value,disabled:props.disabled},{disabled:slotProps.value.disabled,elementID:root.itemID(props.value)}));const handleClick=event=>{if(!event.defaultPrevented&&!slotProps.value.disabled){root.select(props.value,event.currentTarget)}};return()=>h(Primitive,mergeProps(attrs,attributes.value,{as:props.as,asChild:props.asChild,onClick:handleClick}),{default:()=>slots["default"]?.(slotProps.value)})}});const ListboxItemText=defineComponent({name:"SectileListboxItemText",inheritAttrs:false,props:listboxPartProps,slots:Object,setup(props,{attrs,slots}){const item=useListboxItemContext("ListboxItemText");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,"data-scope":"listbox","data-part":"item-text","data-state":item.slotProps.value.selected?"checked":"unchecked"}),{default:()=>slots["default"]?.(item.slotProps.value)})}});const ListboxItemIndicator=defineComponent({name:"SectileListboxItemIndicator",inheritAttrs:false,props:listboxPartProps,slots:Object,setup(props,{attrs,slots}){const item=useListboxItemContext("ListboxItemIndicator");return()=>h(Primitive,mergeProps(attrs,{as:props.as,asChild:props.asChild,hidden:!item.slotProps.value.selected,"aria-hidden":"true","data-scope":"listbox","data-part":"item-indicator","data-state":item.slotProps.value.selected?"checked":"unchecked"}),{default:()=>slots["default"]?.(item.slotProps.value)})}});function useListboxRootContext(part){const context=inject(listboxRootContextKey);if(context===void 0)throw new TypeError(`${part} must be used inside ListboxRoot.`);return context}function snapshotListboxControllerProps(props){return Object.freeze({...props,items:Object.freeze([...props.items]),disabledItems:Object.freeze([...props.disabledItems])})}function sameListboxControllerProps(left,right){return sameIDs(left.items,right.items)&&sameIDs(left.disabledItems,right.disabledItems)&&left.selectionMode===right.selectionMode&&left.disabled===right.disabled&&left.readonly===right.readonly&&left.orientation===right.orientation&&left.direction===right.direction&&left.textValue===right.textValue}function firstEnabledItem(props){if(props.disabledItems.length===0)return props.items[0];const disabled=new Set(props.disabledItems);return props.items.find(id=>!disabled.has(id))}function useListboxItemContext(part){const context=inject(listboxItemContextKey);if(context===void 0)throw new TypeError(`${part} must be used inside ListboxItem.`);return context}function createController(controlled,value,highlightedValue,props,emit){const result=createListboxControllerFromItems({items:props.items,selectionMode:props.selectionMode,disabledItems:props.disabledItems,disabled:props.disabled,readOnly:props.readonly,orientation:props.orientation,direction:props.direction,typeahead:{textValue:props.textValue??(id=>id)},...controlled?{value}:{defaultValue:value},defaultHighlightedValue:highlightedValue,onValueChange:change=>emit("update:modelValue",fromIDs(change.value,props.selectionMode)),onHighlightedValueChange:change=>emit("highlight",change.value)});if(!result.ok)throw new TypeError(result.error.message);return result.value}function applyEffects(effects,emit){for(const effect of effects){if(effect.type==="dispatch-activation")emit("activate",effect.id)}}function toIDs(value,mode){if(value===void 0||value==="")return[];if(Array.isArray(value))return mode==="single"?value.slice(0,1):value;return[value]}function fromIDs(value,mode){return mode==="single"?value[0]??"":value}export{ListboxItem,ListboxItemIndicator,ListboxItemText,ListboxRoot};
|
|
2
2
|
//# sourceMappingURL=listbox.js.map
|
package/dist/listbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/listbox.ts"],"mappings":"AAAA,OACE,SACA,gBACA,EACA,OACA,WACA,SACA,QACA,WACA,UAKK,MACP,OACE,+BACA,iCACA,yBACA,6BAGK,uBACP,OAAS,cAAmC,iBAC5C,OAAS,6BAAgC,6BACzC,OAAS,mCAAoC,4BAA+B,6BAC5E,OAAS,iBAAkB,cAAqC,qBAChE,OAAS,yBAA0B,YAAe,2BA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Aa,OAAO,KAAK,EACrE,EACD,GAAI,CAAC,OAAO,GAAI,MAAM,IAAI,UAAU,OAAO,MAAM,OAAO,EACxD,OAAO,OAAO,KAChB,CAEA,SAAS,aAAa,QAA2C,KAAiB,CAChF,UAAW,UAAU,QAAS,CAC5B,GAAI,OAAO,OAAS,sBAAuB,KAAK,WAAY,OAAO,EAAE,CACvE,CACF,CAEA,SAAS,MAAM,MAAiC,KAA0B,CACxE,GAAI,QAAU,QAAa,QAAU,GAAI,MAAO,CAAA,EAChD,GAAI,MAAM,QAAQ,KAAK,EAAG,OAAO,OAAS,SAAW,MAAM,MAAM,EAAG,CAAC,EAAI,MACzE,MAAO,CAAC,KAAe,CACzB,CAEA,SAAS,QAAQ,MAA0B,KAA0B,CACnE,OAAO,OAAS,SAAW,MAAM,CAAC,GAAK,GAAK,KAC9C","names":[],"file":"listbox.js"}
|
package/dist/menu.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
2
|
import { type MenuItemDefinition, type MenuPolicies } from '@sectile/dom/menu';
|
|
3
|
+
import type { PositionBoundary, PositionOptions, PositionPadding, PositionStrategy, PositionTracking } from '@sectile/dom/position';
|
|
3
4
|
import { type PrimitiveAs } from './primitive.js';
|
|
4
5
|
export interface MenuRootProps {
|
|
5
6
|
readonly items: readonly MenuItemDefinition<string>[];
|
|
@@ -13,9 +14,10 @@ export interface MenuRootProps {
|
|
|
13
14
|
readonly asChild?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export type MenuTextValueResolver = NonNullable<MenuRootProps['textValue']>;
|
|
16
|
-
export interface MenuButtonRootProps extends MenuRootProps {
|
|
17
|
+
export interface MenuButtonRootProps extends MenuRootProps, Omit<PositionOptions, 'arrowPadding'> {
|
|
17
18
|
readonly open?: boolean;
|
|
18
19
|
readonly defaultOpen?: boolean;
|
|
20
|
+
readonly position?: boolean;
|
|
19
21
|
}
|
|
20
22
|
export interface MenuRootSlotProps {
|
|
21
23
|
readonly open: boolean;
|
|
@@ -365,6 +367,46 @@ export declare const MenuButtonRoot: import("vue").DefineComponent<import("vue")
|
|
|
365
367
|
readonly type: BooleanConstructor;
|
|
366
368
|
readonly default: false;
|
|
367
369
|
};
|
|
370
|
+
readonly position: {
|
|
371
|
+
readonly type: BooleanConstructor;
|
|
372
|
+
readonly default: true;
|
|
373
|
+
};
|
|
374
|
+
readonly side: {
|
|
375
|
+
readonly type: PropType<'top' | 'right' | 'bottom' | 'left'>;
|
|
376
|
+
readonly default: 'bottom';
|
|
377
|
+
};
|
|
378
|
+
readonly align: {
|
|
379
|
+
readonly type: PropType<'start' | 'center' | 'end'>;
|
|
380
|
+
readonly default: 'start';
|
|
381
|
+
};
|
|
382
|
+
readonly sideOffset: {
|
|
383
|
+
readonly type: NumberConstructor;
|
|
384
|
+
readonly default: 8;
|
|
385
|
+
};
|
|
386
|
+
readonly collisionPadding: {
|
|
387
|
+
readonly type: PropType<PositionPadding>;
|
|
388
|
+
readonly default: 8;
|
|
389
|
+
};
|
|
390
|
+
readonly collisionBoundary: {
|
|
391
|
+
readonly type: PropType<PositionBoundary>;
|
|
392
|
+
readonly default: undefined;
|
|
393
|
+
};
|
|
394
|
+
readonly avoidCollisions: {
|
|
395
|
+
readonly type: BooleanConstructor;
|
|
396
|
+
readonly default: true;
|
|
397
|
+
};
|
|
398
|
+
readonly hideWhenDetached: {
|
|
399
|
+
readonly type: BooleanConstructor;
|
|
400
|
+
readonly default: false;
|
|
401
|
+
};
|
|
402
|
+
readonly strategy: {
|
|
403
|
+
readonly type: PropType<PositionStrategy>;
|
|
404
|
+
readonly default: 'absolute';
|
|
405
|
+
};
|
|
406
|
+
readonly tracking: {
|
|
407
|
+
readonly type: PropType<PositionTracking>;
|
|
408
|
+
readonly default: 'events';
|
|
409
|
+
};
|
|
368
410
|
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
369
411
|
'update:open': (_value: boolean) => boolean;
|
|
370
412
|
invoke: (_value: string) => boolean;
|
|
@@ -413,6 +455,46 @@ export declare const MenuButtonRoot: import("vue").DefineComponent<import("vue")
|
|
|
413
455
|
readonly type: BooleanConstructor;
|
|
414
456
|
readonly default: false;
|
|
415
457
|
};
|
|
458
|
+
readonly position: {
|
|
459
|
+
readonly type: BooleanConstructor;
|
|
460
|
+
readonly default: true;
|
|
461
|
+
};
|
|
462
|
+
readonly side: {
|
|
463
|
+
readonly type: PropType<'top' | 'right' | 'bottom' | 'left'>;
|
|
464
|
+
readonly default: 'bottom';
|
|
465
|
+
};
|
|
466
|
+
readonly align: {
|
|
467
|
+
readonly type: PropType<'start' | 'center' | 'end'>;
|
|
468
|
+
readonly default: 'start';
|
|
469
|
+
};
|
|
470
|
+
readonly sideOffset: {
|
|
471
|
+
readonly type: NumberConstructor;
|
|
472
|
+
readonly default: 8;
|
|
473
|
+
};
|
|
474
|
+
readonly collisionPadding: {
|
|
475
|
+
readonly type: PropType<PositionPadding>;
|
|
476
|
+
readonly default: 8;
|
|
477
|
+
};
|
|
478
|
+
readonly collisionBoundary: {
|
|
479
|
+
readonly type: PropType<PositionBoundary>;
|
|
480
|
+
readonly default: undefined;
|
|
481
|
+
};
|
|
482
|
+
readonly avoidCollisions: {
|
|
483
|
+
readonly type: BooleanConstructor;
|
|
484
|
+
readonly default: true;
|
|
485
|
+
};
|
|
486
|
+
readonly hideWhenDetached: {
|
|
487
|
+
readonly type: BooleanConstructor;
|
|
488
|
+
readonly default: false;
|
|
489
|
+
};
|
|
490
|
+
readonly strategy: {
|
|
491
|
+
readonly type: PropType<PositionStrategy>;
|
|
492
|
+
readonly default: 'absolute';
|
|
493
|
+
};
|
|
494
|
+
readonly tracking: {
|
|
495
|
+
readonly type: PropType<PositionTracking>;
|
|
496
|
+
readonly default: 'events';
|
|
497
|
+
};
|
|
416
498
|
}>> & Readonly<{
|
|
417
499
|
onInvoke?: (_value: string) => any;
|
|
418
500
|
"onUpdate:open"?: (_value: boolean) => any;
|
|
@@ -427,6 +509,16 @@ export declare const MenuButtonRoot: import("vue").DefineComponent<import("vue")
|
|
|
427
509
|
readonly asChild: boolean;
|
|
428
510
|
readonly open: boolean;
|
|
429
511
|
readonly defaultOpen: boolean;
|
|
512
|
+
readonly position: boolean;
|
|
513
|
+
readonly side: "bottom" | "left" | "right" | "top";
|
|
514
|
+
readonly align: "center" | "end" | "start";
|
|
515
|
+
readonly sideOffset: number;
|
|
516
|
+
readonly collisionPadding: PositionPadding;
|
|
517
|
+
readonly collisionBoundary: PositionBoundary;
|
|
518
|
+
readonly avoidCollisions: boolean;
|
|
519
|
+
readonly hideWhenDetached: boolean;
|
|
520
|
+
readonly strategy: PositionStrategy;
|
|
521
|
+
readonly tracking: PositionTracking;
|
|
430
522
|
}, SlotsType<{
|
|
431
523
|
default: (props: MenuRootSlotProps) => VNodeChild;
|
|
432
524
|
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|