@zappie/foundations 0.23.0 → 0.24.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +16 -6
- package/dist/internal/labelled-control.js +2 -0
- package/dist/internal/labelled-control.js.map +6 -0
- package/dist/item-form/option-group.js +1 -1
- package/dist/item-form/option-group.js.map +1 -1
- package/dist/payment/methods.js +1 -1
- package/dist/payment/methods.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @zappie/foundations
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6186e4f: Choice and PaymentMethods.Item are real form controls now. Each is a `<label>` around a native `<input type="radio">` or `<input type="checkbox">`, so the browser draws a round radio for a group that takes exactly one and a square checkbox for every other group, and owns the arrows, Tab and Space. The label keeps every data attribute it had as a button (`data-zappie-option`, `data-control`, `data-state`, `data-selected`, `data-disabled`, `data-sold-out`, `data-limit-reached`) and the template's `className`. The input carries `checked`, `disabled` for a sold-out choice or one the template passes `disabled`, `aria-disabled` for a choice held back by the group's limit, and `data-zappie-choice-input` for styling. A template that draws its own mark restyles or hides that input, styles its focus ring with `:has(> [data-zappie-choice-input]:focus-visible)` and its disabled look with `[data-disabled]`. Put quantity steppers beside a Choice, not inside it. The base theme draws its marks on the input. V05 skips sold-out choices by `data-disabled` as well as `aria-disabled`.
|
|
8
|
+
|
|
3
9
|
## 0.23.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -692,10 +692,15 @@ type ChoiceState = {
|
|
|
692
692
|
setQuantity: (quantity: number) => void;
|
|
693
693
|
};
|
|
694
694
|
/**
|
|
695
|
-
* Render a selectable option within an OptionGroup
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
695
|
+
* Render a selectable option within an OptionGroup as a `<label>` around a
|
|
696
|
+
* native `<input>`: radios for a required group of exactly one, checkboxes for
|
|
697
|
+
* every other group. The input comes first, so the browser draws a round radio
|
|
698
|
+
* or a square checkbox unless the template restyles it. Style the label through
|
|
699
|
+
* its data attributes and the input through `[data-zappie-choice-input]`.
|
|
700
|
+
* Unavailable choices are disabled, and so is a choice given `disabled`, which
|
|
701
|
+
* goes to the input. While the group is at its limit, unchosen
|
|
702
|
+
* choices are aria-disabled and data-limit-reached but stay focusable. Put
|
|
703
|
+
* quantity steppers beside the Choice, not inside it.
|
|
699
704
|
*/
|
|
700
705
|
declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
701
706
|
asChild?: boolean;
|
|
@@ -905,6 +910,8 @@ type PaymentState = {
|
|
|
905
910
|
methods: PaymentMethod[];
|
|
906
911
|
value: PaymentMethodKind | null;
|
|
907
912
|
setValue: (value: PaymentMethodKind) => void;
|
|
913
|
+
/** The name the methods' native radios share. */
|
|
914
|
+
name: string;
|
|
908
915
|
};
|
|
909
916
|
declare function Root$1({ methods, value, defaultValue, onValueChange, ...props }: PartProps<PaymentState> & {
|
|
910
917
|
methods: (PaymentMethod | PaymentMethodKind)[];
|
|
@@ -913,8 +920,11 @@ declare function Root$1({ methods, value, defaultValue, onValueChange, ...props
|
|
|
913
920
|
onValueChange?: (value: PaymentMethodKind | null) => void;
|
|
914
921
|
}): react.JSX.Element;
|
|
915
922
|
/**
|
|
916
|
-
* Composable payment-method
|
|
917
|
-
* Root manages the selection. Item renders each method
|
|
923
|
+
* Composable payment-method radios.
|
|
924
|
+
* Root manages the selection and is a radiogroup. Item renders each method as a
|
|
925
|
+
* `<label>` around a native radio, which the browser draws round unless the
|
|
926
|
+
* template restyles it through `[data-zappie-choice-input]`. A disabled method
|
|
927
|
+
* can't be selected.
|
|
918
928
|
*/
|
|
919
929
|
declare const PaymentMethods: {
|
|
920
930
|
Root: typeof Root$1;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Children,cloneElement,Fragment,isValidElement}from"react";import{part}from"./slot.js";import{jsxs}from"react/jsx-runtime";function labelledControl(props,state,defaults,control,ref){const{asChild,children,...dom}=props;const content=typeof children==="function"?children(state):children;if(asChild){const child=Children.only(content);if(!isValidElement(child)){throw new Error("asChild requires one React element")}return part("label",{...dom,asChild:true,children:cloneElement(child,void 0,control,child.props.children)},state,defaults,ref)}return part("label",{...dom,children:jsxs(Fragment,{children:[control,content]})},state,defaults,ref)}export{labelledControl};
|
|
2
|
+
//# sourceMappingURL=labelled-control.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/internal/labelled-control.tsx"],
|
|
4
|
+
"mappings": "AAAA,OACE,SACA,aACA,SACA,mBAIK,QACP,OAAS,SAA4B,YA0C7B,oCApCD,SAAS,gBACd,MACA,MACA,SACA,QACA,IACA,CACA,KAAM,CAAE,QAAS,SAAU,GAAG,GAAI,EAAI,MACtC,MAAM,QAAU,OAAO,WAAa,WAAa,SAAS,KAAK,EAAI,SACnE,GAAI,QAAS,CACX,MAAM,MAAQ,SAAS,KAAK,OAAO,EACnC,GAAI,CAAC,eAAyC,KAAK,EAAG,CACpD,MAAM,IAAI,MAAM,oCAAoC,CACtD,CACA,OAAO,KACL,QACA,CACE,GAAG,IACH,QAAS,KACT,SAAU,aACR,MACA,OACA,QACA,MAAM,MAAM,QACd,CACF,EACA,MACA,SACA,GACF,CACF,CACA,OAAO,KACL,QACA,CACE,GAAG,IACH,SACE,KAAC,UACE,kBACA,SACH,CAEJ,EACA,MACA,SACA,GACF,CACF",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{canChoose,choiceQuantityMax,atLimit as groupAtLimit,groupRoom,LIMIT_REACHED_HINT,selectionControl,selectionCount}from"@zappie/sdk/options";import{cloneElement,createContext,forwardRef,Fragment,isValidElement,memo,useContext,useMemo,useRef}from"react";import{flag}from"../internal/data-attrs.js";import{usePartId}from"../internal/ids.js";import{composeRefs,part}from"../internal/slot.js";import{GroupRegistry,useItemForm}from"./root.js";import{jsx,jsxs}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function useGroup(){const value=useContext(Context);if(!value){throw new Error("Choice and OptionGroup.Input require OptionGroup")}return value}var Group=/*@__PURE__ */forwardRef(function OptionGroup({group:supplied,requiredNote="Required",limitHint:hintText,"aria-describedby":describedBy,children,...props},ref){const ctx=useItemForm();const registry=useContext(GroupRegistry);const group=ctx.groups.find(candidate=>candidate.id===supplied.id)??supplied;const mine=ctx.value.choices?.filter(choice=>choice.groupId===group.id)??[];const selected=mine.map(choice=>choice.choiceId);const quantities=Object.fromEntries(mine.map(choice=>[choice.choiceId,choice.quantity??1]));const invalid=ctx.issues.some(issue=>issue.groupId===group.id);const input=ctx.value.inputs?.[group.id]??"";const latest=useRef({ctx,group});latest.current={ctx,group};const actions=useMemo(()=>{const write=(id,quantity)=>{const{ctx:ctx2,group:group2}=latest.current;const previous=ctx2.value.choices??[];const isThis=candidate=>candidate.groupId===group2.id&&candidate.choiceId===id;const choice=group2.choices.find(candidate=>candidate.id===id);if(!choice||!Number.isInteger(quantity)||quantity>0&&!canChoose(group2,previous,id)){return}const choices=previous.filter(candidate=>!isThis(candidate)&&(quantity<=0||candidate.groupId!==group2.id||group2.selection.max!==1));if(quantity>0){choices.push({groupId:group2.id,choiceId:id,quantity:Math.max(choice.quantity?.min??1,Math.min(choiceQuantityMax(group2,previous,id),quantity))})}const inputs={...ctx2.value.inputs};delete inputs[group2.id];ctx2.setValue({...ctx2.value,choices,inputs})};return{toggle:id=>{const{ctx:ctx2,group:group2}=latest.current;const chosen=ctx2.value.choices?.some(candidate=>candidate.groupId===group2.id&&candidate.choiceId===id);if(!chosen||selectionControl(group2)!=="radio"){write(id,chosen?0:group2.choices.find(candidate=>candidate.id===id)?.quantity?.min??1)}},setQuantity:write,setInput:value=>{const{ctx:ctx2,group:group2}=latest.current;ctx2.setValue({...ctx2.value,choices:(ctx2.value.choices??[]).filter(choice=>choice.groupId!==group2.id),inputs:{...ctx2.value.inputs,[group2.id]:value.slice(0,group2.input?.maxLength??500)}})}}},[]);const selectionKey=JSON.stringify(quantities);const control=selectionControl(group);const count=selectionCount(group,mine);const full=group.kind==="select"&&groupAtLimit(group,mine);const heldBack=full&&group.choices.some(choice=>choice.isAvailable&&!selected.includes(choice.id));const text=heldBack&&(hintText||LIMIT_REACHED_HINT)||void 0;const limitHint=hintText===false?void 0:text;const hintId=usePartId();const state=useMemo(()=>({group,selected,quantities,invalid,input,control,count,room:groupRoom(group,mine),atLimit:full,limitHint:text,hintId:limitHint&&hintId,mine,...actions}),[group,selectionKey,invalid,input,hintText,hintId,actions]);const radio=group.kind==="select"&&control==="radio";const noteId=usePartId();const note=group.required&&group.kind==="select"&&!radio&&requiredNote;const content=typeof children==="function"?children(state):children;const child=props.asChild&&isValidElement(content)?content:void 0;const own=describedBy??child?.props["aria-describedby"];const description=[note&¬eId,limitHint&&hintId,own].filter(Boolean).join(" ")||void 0;const hint=limitHint?jsx("p",{id:hintId,role:"status","data-zappie-limit-hint":"",children:limitHint}):null;return jsxs(Context.Provider,{value:state,children:[note&&jsx("span",{id:noteId,hidden:true,children:note}),part("div",child?{...props,children:cloneElement(child,{"aria-describedby":description},child.props.children,hint)}:{...props,children:jsxs(Fragment,{children:[content,hint]})},state,{role:radio?"radiogroup":"group",tabIndex:-1,"aria-label":group.name,"aria-required":radio?group.required:void 0,"aria-describedby":description,"data-zappie-required":group.required?"true":void 0,"aria-invalid":invalid||void 0,"data-invalid":flag(invalid),"data-state":invalid?"invalid":"valid","data-limit-reached":flag(full),"data-zappie-option-group":group.id
|
|
1
|
+
"use client";import{canChoose,choiceQuantityMax,atLimit as groupAtLimit,groupRoom,LIMIT_REACHED_HINT,selectionControl,selectionCount}from"@zappie/sdk/options";import{cloneElement,createContext,forwardRef,Fragment,isValidElement,memo,useContext,useMemo,useRef}from"react";import{flag}from"../internal/data-attrs.js";import{usePartId}from"../internal/ids.js";import{labelledControl}from"../internal/labelled-control.js";import{composeRefs,part}from"../internal/slot.js";import{GroupRegistry,useItemForm}from"./root.js";import{jsx,jsxs}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function useGroup(){const value=useContext(Context);if(!value){throw new Error("Choice and OptionGroup.Input require OptionGroup")}return value}var Group=/*@__PURE__ */forwardRef(function OptionGroup({group:supplied,requiredNote="Required",limitHint:hintText,"aria-describedby":describedBy,children,...props},ref){const ctx=useItemForm();const registry=useContext(GroupRegistry);const group=ctx.groups.find(candidate=>candidate.id===supplied.id)??supplied;const mine=ctx.value.choices?.filter(choice=>choice.groupId===group.id)??[];const selected=mine.map(choice=>choice.choiceId);const quantities=Object.fromEntries(mine.map(choice=>[choice.choiceId,choice.quantity??1]));const invalid=ctx.issues.some(issue=>issue.groupId===group.id);const input=ctx.value.inputs?.[group.id]??"";const latest=useRef({ctx,group});latest.current={ctx,group};const actions=useMemo(()=>{const write=(id,quantity)=>{const{ctx:ctx2,group:group2}=latest.current;const previous=ctx2.value.choices??[];const isThis=candidate=>candidate.groupId===group2.id&&candidate.choiceId===id;const choice=group2.choices.find(candidate=>candidate.id===id);if(!choice||!Number.isInteger(quantity)||quantity>0&&!canChoose(group2,previous,id)){return}const choices=previous.filter(candidate=>!isThis(candidate)&&(quantity<=0||candidate.groupId!==group2.id||group2.selection.max!==1));if(quantity>0){choices.push({groupId:group2.id,choiceId:id,quantity:Math.max(choice.quantity?.min??1,Math.min(choiceQuantityMax(group2,previous,id),quantity))})}const inputs={...ctx2.value.inputs};delete inputs[group2.id];ctx2.setValue({...ctx2.value,choices,inputs})};return{toggle:id=>{const{ctx:ctx2,group:group2}=latest.current;const chosen=ctx2.value.choices?.some(candidate=>candidate.groupId===group2.id&&candidate.choiceId===id);if(!chosen||selectionControl(group2)!=="radio"){write(id,chosen?0:group2.choices.find(candidate=>candidate.id===id)?.quantity?.min??1)}},setQuantity:write,setInput:value=>{const{ctx:ctx2,group:group2}=latest.current;ctx2.setValue({...ctx2.value,choices:(ctx2.value.choices??[]).filter(choice=>choice.groupId!==group2.id),inputs:{...ctx2.value.inputs,[group2.id]:value.slice(0,group2.input?.maxLength??500)}})}}},[]);const selectionKey=JSON.stringify(quantities);const control=selectionControl(group);const count=selectionCount(group,mine);const full=group.kind==="select"&&groupAtLimit(group,mine);const heldBack=full&&group.choices.some(choice=>choice.isAvailable&&!selected.includes(choice.id));const text=heldBack&&(hintText||LIMIT_REACHED_HINT)||void 0;const limitHint=hintText===false?void 0:text;const hintId=usePartId();const name=usePartId();const state=useMemo(()=>({group,selected,quantities,invalid,input,control,count,room:groupRoom(group,mine),atLimit:full,limitHint:text,hintId:limitHint&&hintId,mine,name,...actions}),[group,selectionKey,invalid,input,hintText,hintId,name,actions]);const radio=group.kind==="select"&&control==="radio";const noteId=usePartId();const note=group.required&&group.kind==="select"&&!radio&&requiredNote;const content=typeof children==="function"?children(state):children;const child=props.asChild&&isValidElement(content)?content:void 0;const own=describedBy??child?.props["aria-describedby"];const description=[note&¬eId,limitHint&&hintId,own].filter(Boolean).join(" ")||void 0;const hint=limitHint?jsx("p",{id:hintId,role:"status","data-zappie-limit-hint":"",children:limitHint}):null;return jsxs(Context.Provider,{value:state,children:[note&&jsx("span",{id:noteId,hidden:true,children:note}),part("div",child?{...props,children:cloneElement(child,{"aria-describedby":description},child.props.children,hint)}:{...props,children:jsxs(Fragment,{children:[content,hint]})},state,{role:radio?"radiogroup":"group",tabIndex:-1,"aria-label":group.name,"aria-required":radio?group.required:void 0,"aria-describedby":description,"data-zappie-required":group.required?"true":void 0,"aria-invalid":invalid||void 0,"data-invalid":flag(invalid),"data-state":invalid?"invalid":"valid","data-limit-reached":flag(full),"data-zappie-option-group":group.id},composeRefs(ref,node=>{if(node){registry.set(group.id,node)}else{registry.delete(group.id)}}))]})});var ChoiceView=/*@__PURE__ */memo(forwardRef(function ChoiceView2({choice,selected,control,limitReached,hintId,name,quantity,max,toggleChoice,setChoiceQuantity,disabled:held,...props},ref){const toggle=()=>toggleChoice(choice.id);const unavailable=!choice.isAvailable||Boolean(held);const state={choice,selected,disabled:unavailable||limitReached,limitReached,control,toggle,quantity,min:choice.quantity?.min??1,max,setQuantity:next=>setChoiceQuantity(choice.id,next)};const input=jsx("input",{type:control,name,value:choice.id,checked:selected,disabled:unavailable,"aria-disabled":limitReached||void 0,"aria-describedby":limitReached?hintId:void 0,"data-zappie-choice-input":"",onChange:toggle});return labelledControl(props,state,{"data-selected":flag(selected),"data-sold-out":flag(unavailable),"data-disabled":flag(unavailable||limitReached),"data-limit-reached":flag(limitReached),"data-control":control,"data-state":selected?"checked":"unchecked","data-zappie-option":choice.id},input,ref)}));var Choice=/*@__PURE__ */forwardRef(function Choice2(props,ref){const ctx=useGroup();const id=props.choice.id;const selected=ctx.selected.includes(id);const limitReached=props.choice.isAvailable&&!canChoose(ctx.group,ctx.mine,id);return jsx(ChoiceView,{...props,ref,selected,control:ctx.control,limitReached,hintId:ctx.hintId,name:ctx.name,quantity:ctx.quantities[id]??0,max:choiceQuantityMax(ctx.group,ctx.mine,id),toggleChoice:ctx.toggle,setChoiceQuantity:ctx.setQuantity})});var Input=/*@__PURE__ */forwardRef(function Input2(props,ref){const ctx=useGroup();const id=usePartId(props.id);const toggle=ctx.group.kind==="toggle";return part("input",props,ctx,{id,type:toggle?"checkbox":ctx.group.kind==="select"?"text":ctx.group.kind,value:toggle?void 0:ctx.input,checked:toggle?ctx.input==="true":void 0,required:ctx.group.required,"aria-label":ctx.group.name,"aria-invalid":ctx.invalid||void 0,"data-invalid":flag(ctx.invalid),maxLength:ctx.group.input?.maxLength??500,placeholder:ctx.group.input?.placeholder,onChange:event=>ctx.setInput(toggle?String(event.target.checked):event.target.value)},ref)});var OptionGroup2=/*@__PURE__ */Object.assign(Group,{Input});export{Choice,OptionGroup2 as OptionGroup};
|
|
2
2
|
//# sourceMappingURL=option-group.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/option-group.tsx"],
|
|
4
|
-
"mappings": "aAKA,OACE,UACA,kBACA,WAAW,aACX,UACA,mBACA,iBACA,mBAGK,sBACP,OACE,aACA,cACA,WACA,SACA,eACA,KACA,WACA,QACA,
|
|
4
|
+
"mappings": "aAKA,OACE,UACA,kBACA,WAAW,aACX,UACA,mBACA,iBACA,mBAGK,sBACP,OACE,aACA,cACA,WACA,SACA,eACA,KACA,WACA,QACA,WAIK,QACP,OAAS,SAAY,4BACrB,OAAS,cAAiB,qBAC1B,OAAS,oBAAuB,kCAChC,OAAS,YAAa,SAA4B,sBAClD,OAAS,cAAe,gBAAmB,YAgNvC,WA2BY,SA3BZ,oBArLJ,IAAM,QAAU,eAAgB,cAQ9B,IAAI,EACN,SAAS,UAAW,CAClB,MAAM,MAAQ,WAAW,OAAO,EAChC,GAAI,CAAC,MAAO,CACV,MAAM,IAAI,MAAM,kDAAkD,CACpE,CACA,OAAO,KACT,CACA,IAAM,MAAQ,eAAgB,WAiB5B,SAAS,YACT,CACE,MAAO,SACP,aAAe,WACf,UAAW,SACX,mBAAoB,YACpB,SACA,GAAG,KACL,EACA,IACA,CACA,MAAM,IAAM,YAAY,EACxB,MAAM,SAAW,WAAW,aAAa,EACzC,MAAM,MACJ,IAAI,OAAO,KAAM,WAAc,UAAU,KAAO,SAAS,EAAE,GAAK,SAClE,MAAM,KACJ,IAAI,MAAM,SAAS,OAAQ,QAAW,OAAO,UAAY,MAAM,EAAE,GAAK,CAAC,EACzE,MAAM,SAAW,KAAK,IAAK,QAAW,OAAO,QAAQ,EACrD,MAAM,WAAa,OAAO,YACxB,KAAK,IAAK,QAAW,CAAC,OAAO,SAAU,OAAO,UAAY,CAAC,CAAC,CAC9D,EACA,MAAM,QAAU,IAAI,OAAO,KAAM,OAAU,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,CACE,GACA,KAAM,OACF,WACA,IAAI,MAAM,OAAS,SACjB,OACA,IAAI,MAAM,KAChB,MAAO,OAAS,OAAY,IAAI,MAChC,QAAS,OAAS,IAAI,QAAU,OAAS,OACzC,SAAU,IAAI,MAAM,SACpB,aAAc,IAAI,MAAM,KACxB,eAAgB,IAAI,SAAW,OAC/B,eAAgB,KAAK,IAAI,OAAO,EAChC,UAAW,IAAI,MAAM,OAAO,WAAa,IACzC,YAAa,IAAI,MAAM,OAAO,YAC9B,SAAW,OACT,IAAI,SACF,OAAS,OAAO,MAAM,OAAO,OAAO,EAAI,MAAM,OAAO,KACvD,CACJ,EACA,GACF,CACF,CACF,EAKO,IAAMC,aAAc,eAAgB,OAAO,OAAO,MAAO,CAAE,KAAM,CAAC",
|
|
5
5
|
"names": ["ctx", "group", "ChoiceView", "Choice", "Input", "OptionGroup"]
|
|
6
6
|
}
|
package/dist/payment/methods.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{createContext,forwardRef,useContext}from"react";import{usePartId}from"../internal/ids.js";import{part}from"../internal/slot.js";import{useControllableState}from"../internal/use-controllable-state.js";import{jsx}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function Root({methods,value,defaultValue=null,onValueChange,...props}){const[selected,set]=useControllableState({value,defaultValue,onChange:onValueChange});const normalized=methods.map(method=>typeof method==="string"?{value:method}:method);const setValue=next=>{if(normalized.some(method=>method.value===next&&!method.disabled)){set(next)}};const state={methods:normalized,value:selected,setValue};return jsx(Context.Provider,{value:state,children:part("div",props,state,{role:"radiogroup"
|
|
1
|
+
"use client";import{createContext,forwardRef,Fragment,useContext}from"react";import{usePartId}from"../internal/ids.js";import{labelledControl}from"../internal/labelled-control.js";import{part}from"../internal/slot.js";import{useControllableState}from"../internal/use-controllable-state.js";import{jsx,jsxs}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function Root({methods,value,defaultValue=null,onValueChange,...props}){const[selected,set]=useControllableState({value,defaultValue,onChange:onValueChange});const normalized=methods.map(method=>typeof method==="string"?{value:method}:method);const setValue=next=>{if(normalized.some(method=>method.value===next&&!method.disabled)){set(next)}};const name=usePartId();const state={methods:normalized,value:selected,setValue,name};return jsx(Context.Provider,{value:state,children:part("div",props,state,{role:"radiogroup"})})}var Item=/*@__PURE__ */forwardRef(function Item2({value,...props},ref){const ctx=useContext(Context);const id=usePartId();if(!ctx){throw new Error("PaymentMethods.Item requires PaymentMethods.Root")}const method=ctx.methods.find(method2=>method2.value===value);if(!method){return null}const selected=ctx.value===value;const reasonId=`${id}-reason`;const input=jsxs(Fragment,{children:[jsx("input",{id,type:"radio",name:ctx.name,value,checked:selected,disabled:method.disabled,"aria-describedby":method.reason?reasonId:void 0,"data-zappie-choice-input":"",onChange:()=>ctx.setValue(value)}),method.reason?jsx("span",{id:reasonId,hidden:true,children:method.reason}):null]});return labelledControl(props,{...method,selected},{"data-disabled":method.disabled?"":void 0,"data-selected":selected?"":void 0,"data-state":selected?"checked":"unchecked","data-control":"radio"},input,ref)});var PaymentMethods={Root,Item};export{PaymentMethods};
|
|
2
2
|
//# sourceMappingURL=methods.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/payment/methods.tsx"],
|
|
4
|
-
"mappings": "aAEA,
|
|
4
|
+
"mappings": "aAEA,OAAS,cAAe,WAAY,SAAU,eAAkB,QAChE,OAAS,cAAiB,qBAC1B,OAAS,oBAAuB,kCAChC,OAAS,SAA4B,sBACrC,OAAS,yBAA4B,wCA+CjC,WAuBA,SAvBA,oBA/BJ,IAAM,QAAU,eAAgB,cAAmC,IAAI,EACvE,SAAS,KAAK,CACZ,QACA,MACA,aAAe,KACf,cACA,GAAG,KACL,EAKG,CACD,KAAM,CAAC,SAAU,GAAG,EAAI,qBAAqB,CAC3C,MACA,aACA,SAAU,aACZ,CAAC,EACD,MAAM,WAAa,QAAQ,IAAK,QAC9B,OAAO,SAAW,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
6
|
}
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var PACKAGE_VERSION=true?"0.
|
|
1
|
+
var PACKAGE_VERSION=true?"0.24.0":"0.0.0-development";export{PACKAGE_VERSION};
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED