@stackshift-ui/select 6.0.12 → 7.0.0-beta.1
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/chunk-PPOLDV3F.mjs +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/select.d.ts +14 -19
- package/dist/select.js +1 -1
- package/dist/select.mjs +1 -1
- package/package.json +9 -7
- package/src/select.test.tsx +14 -8
- package/src/select.tsx +217 -76
- package/dist/chunk-VCJRWWZ5.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@radix-ui/react-select";import{Check as x,ChevronDown as f,ChevronUp as I}from"lucide-react";import*as n from"react";import{cn as l,DefaultComponent as c,useStackShiftUIComponents as s}from"@stackshift-ui/system";import{jsx as i,jsxs as p}from"react/jsx-runtime";var d="Select",u="SelectTrigger",S="SelectValue",R="SelectContent",y="SelectItem",P="SelectGroup",v="SelectLabel",g="SelectSeparator",C="SelectScrollUpButton",h="SelectScrollDownButton",B=n.forwardRef(({...o},a)=>{let{[d]:t=c}=s();return i(t,{as:e.Root,ref:a,...o})});B.displayName=d;var E=n.forwardRef(({className:o,...a},t)=>{let{[P]:r=c}=s();return i(r,{as:e.Group,ref:t,className:l("p-1",o),...a})});E.displayName=P;var W=n.forwardRef(({className:o,...a},t)=>{let{[S]:r=c}=s();return i(r,{as:e.Value,ref:t,className:l("text-sm outline-none",o),...a})});W.displayName=S;var D=n.forwardRef(({className:o,children:a,...t},r)=>{let{[u]:m=c}=s();return p(m,{as:e.Trigger,ref:r,className:l("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",o),...t,children:[a,i(e.Icon,{asChild:!0,children:i(f,{className:"h-4 w-4 opacity-50"})})]})});D.displayName=u;var w=n.forwardRef(({className:o,...a},t)=>{let{[C]:r=c}=s();return i(r,{as:e.ScrollUpButton,ref:t,className:l("flex cursor-default items-center justify-center py-1",o),...a,children:i(I,{className:"h-4 w-4"})})});w.displayName=C;var N=n.forwardRef(({className:o,...a},t)=>{let{[h]:r=c}=s();return i(r,{as:e.ScrollDownButton,ref:t,className:l("flex cursor-default items-center justify-center py-1",o),...a,children:i(f,{className:"h-4 w-4"})})});N.displayName=h;var T=n.forwardRef(({className:o,children:a,position:t="popper",...r},m)=>{let{[R]:b=c}=s();return i(e.Portal,{children:p(b,{as:e.Content,ref:m,className:l("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),position:t,...r,children:[i(w,{}),i(e.Viewport,{className:l("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),i(N,{})]})})});T.displayName=R;var U=n.forwardRef(({className:o,...a},t)=>{let{[v]:r=c}=s();return i(r,{as:e.Label,ref:t,className:l("py-1.5 pl-8 pr-2 text-sm font-semibold",o),...a})});U.displayName=v;var V=n.forwardRef(({className:o,children:a,...t},r)=>{let{[y]:m=c}=s();return p(m,{as:e.Item,ref:r,className:l("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o),...t,children:[i("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i(e.ItemIndicator,{children:i(x,{className:"h-4 w-4"})})}),i(e.ItemText,{children:a})]})});V.displayName=y;var G=n.forwardRef(({className:o,...a},t)=>{let{[g]:r=c}=s();return i(r,{as:e.Separator,ref:t,className:l("-mx-1 my-1 h-px bg-muted",o),...a})});G.displayName=g;export{B as a,E as b,W as c,D as d,w as e,N as f,T as g,U as h,V as i,G as j};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var V=Object.create;var m=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var z=(e,o)=>{for(var a in o)m(e,a,{get:o[a],enumerable:!0})},d=(e,o,a,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of L(o))!j.call(e,l)&&l!==a&&m(e,l,{get:()=>o[l],enumerable:!(n=G(o,l))||n.enumerable});return e};var u=(e,o,a)=>(a=e!=null?V(k(e)):{},d(o||!e||!e.__esModule?m(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>d(m({},"__esModule",{value:!0}),e);var A={};z(A,{Select:()=>x,SelectContent:()=>E,SelectGroup:()=>b,SelectItem:()=>D,SelectLabel:()=>W,SelectScrollDownButton:()=>f,SelectScrollUpButton:()=>p,SelectSeparator:()=>T,SelectTrigger:()=>B,SelectValue:()=>I});module.exports=q(A);var r=u(require("@radix-ui/react-select")),s=require("lucide-react"),c=u(require("react")),t=require("@stackshift-ui/system"),i=require("react/jsx-runtime"),S="Select",R="SelectTrigger",y="SelectValue",P="SelectContent",v="SelectItem",g="SelectGroup",C="SelectLabel",h="SelectSeparator",w="SelectScrollUpButton",N="SelectScrollDownButton",x=c.forwardRef(({...e},o)=>{let{[S]:a=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(a,{as:r.Root,ref:o,...e})});x.displayName=S;var b=c.forwardRef(({className:e,...o},a)=>{let{[g]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(n,{as:r.Group,ref:a,className:(0,t.cn)("p-1",e),...o})});b.displayName=g;var I=c.forwardRef(({className:e,...o},a)=>{let{[y]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(n,{as:r.Value,ref:a,className:(0,t.cn)("text-sm outline-none",e),...o})});I.displayName=y;var B=c.forwardRef(({className:e,children:o,...a},n)=>{let{[R]:l=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsxs)(l,{as:r.Trigger,ref:n,className:(0,t.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...a,children:[o,(0,i.jsx)(r.Icon,{asChild:!0,children:(0,i.jsx)(s.ChevronDown,{className:"h-4 w-4 opacity-50"})})]})});B.displayName=R;var p=c.forwardRef(({className:e,...o},a)=>{let{[w]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(n,{as:r.ScrollUpButton,ref:a,className:(0,t.cn)("flex cursor-default items-center justify-center py-1",e),...o,children:(0,i.jsx)(s.ChevronUp,{className:"h-4 w-4"})})});p.displayName=w;var f=c.forwardRef(({className:e,...o},a)=>{let{[N]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(n,{as:r.ScrollDownButton,ref:a,className:(0,t.cn)("flex cursor-default items-center justify-center py-1",e),...o,children:(0,i.jsx)(s.ChevronDown,{className:"h-4 w-4"})})});f.displayName=N;var E=c.forwardRef(({className:e,children:o,position:a="popper",...n},l)=>{let{[P]:U=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(r.Portal,{children:(0,i.jsxs)(U,{as:r.Content,ref:l,className:(0,t.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,...n,children:[(0,i.jsx)(p,{}),(0,i.jsx)(r.Viewport,{className:(0,t.cn)("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:o}),(0,i.jsx)(f,{})]})})});E.displayName=P;var W=c.forwardRef(({className:e,...o},a)=>{let{[C]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(n,{as:r.Label,ref:a,className:(0,t.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...o})});W.displayName=C;var D=c.forwardRef(({className:e,children:o,...a},n)=>{let{[v]:l=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsxs)(l,{as:r.Item,ref:n,className:(0,t.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...a,children:[(0,i.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,i.jsx)(r.ItemIndicator,{children:(0,i.jsx)(s.Check,{className:"h-4 w-4"})})}),(0,i.jsx)(r.ItemText,{children:o})]})});D.displayName=v;var T=c.forwardRef(({className:e,...o},a)=>{let{[h]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,i.jsx)(n,{as:r.Separator,ref:a,className:(0,t.cn)("-mx-1 my-1 h-px bg-muted",e),...o})});T.displayName=h;0&&(module.exports={Select,SelectContent,SelectGroup,SelectItem,SelectLabel,SelectScrollDownButton,SelectScrollUpButton,SelectSeparator,SelectTrigger,SelectValue});
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";import{a as e}from"./chunk-
|
|
2
|
+
"use strict";import{a as e,b as o,c as r,d as t,e as c,f,g as i,h as l,i as m,j as n}from"./chunk-PPOLDV3F.mjs";export{e as Select,i as SelectContent,o as SelectGroup,m as SelectItem,l as SelectLabel,f as SelectScrollDownButton,c as SelectScrollUpButton,n as SelectSeparator,t as SelectTrigger,r as SelectValue};
|
package/dist/select.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defaultValue?: string;
|
|
5
|
-
variant?: Variant;
|
|
6
|
-
label?: string;
|
|
7
|
-
labelClass?: string;
|
|
8
|
-
onChange?: () => void;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
name: string;
|
|
11
|
-
items: string[];
|
|
12
|
-
ariaLabel: string;
|
|
13
|
-
noLabel?: boolean;
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
className?: string;
|
|
17
|
-
as?: ElementType;
|
|
1
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface SelectProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root> {
|
|
18
4
|
}
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<never>>;
|
|
6
|
+
declare const SelectGroup: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
declare const SelectValue: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
8
|
+
declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
declare const SelectItem: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
declare const SelectSeparator: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, };
|
package/dist/select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var V=Object.create;var m=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var z=(e,o)=>{for(var a in o)m(e,a,{get:o[a],enumerable:!0})},d=(e,o,a,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of L(o))!j.call(e,l)&&l!==a&&m(e,l,{get:()=>o[l],enumerable:!(n=G(o,l))||n.enumerable});return e};var u=(e,o,a)=>(a=e!=null?V(k(e)):{},d(o||!e||!e.__esModule?m(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>d(m({},"__esModule",{value:!0}),e);var A={};z(A,{Select:()=>b,SelectContent:()=>E,SelectGroup:()=>x,SelectItem:()=>D,SelectLabel:()=>W,SelectScrollDownButton:()=>f,SelectScrollUpButton:()=>p,SelectSeparator:()=>T,SelectTrigger:()=>B,SelectValue:()=>I});module.exports=q(A);var i=u(require("@radix-ui/react-select")),s=require("lucide-react"),c=u(require("react")),t=require("@stackshift-ui/system"),r=require("react/jsx-runtime"),S="Select",R="SelectTrigger",y="SelectValue",P="SelectContent",v="SelectItem",g="SelectGroup",C="SelectLabel",h="SelectSeparator",w="SelectScrollUpButton",N="SelectScrollDownButton",b=c.forwardRef(({...e},o)=>{let{[S]:a=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(a,{as:i.Root,ref:o,...e})});b.displayName=S;var x=c.forwardRef(({className:e,...o},a)=>{let{[g]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(n,{as:i.Group,ref:a,className:(0,t.cn)("p-1",e),...o})});x.displayName=g;var I=c.forwardRef(({className:e,...o},a)=>{let{[y]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(n,{as:i.Value,ref:a,className:(0,t.cn)("text-sm outline-none",e),...o})});I.displayName=y;var B=c.forwardRef(({className:e,children:o,...a},n)=>{let{[R]:l=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsxs)(l,{as:i.Trigger,ref:n,className:(0,t.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...a,children:[o,(0,r.jsx)(i.Icon,{asChild:!0,children:(0,r.jsx)(s.ChevronDown,{className:"h-4 w-4 opacity-50"})})]})});B.displayName=R;var p=c.forwardRef(({className:e,...o},a)=>{let{[w]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(n,{as:i.ScrollUpButton,ref:a,className:(0,t.cn)("flex cursor-default items-center justify-center py-1",e),...o,children:(0,r.jsx)(s.ChevronUp,{className:"h-4 w-4"})})});p.displayName=w;var f=c.forwardRef(({className:e,...o},a)=>{let{[N]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(n,{as:i.ScrollDownButton,ref:a,className:(0,t.cn)("flex cursor-default items-center justify-center py-1",e),...o,children:(0,r.jsx)(s.ChevronDown,{className:"h-4 w-4"})})});f.displayName=N;var E=c.forwardRef(({className:e,children:o,position:a="popper",...n},l)=>{let{[P]:U=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(i.Portal,{children:(0,r.jsxs)(U,{as:i.Content,ref:l,className:(0,t.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,...n,children:[(0,r.jsx)(p,{}),(0,r.jsx)(i.Viewport,{className:(0,t.cn)("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:o}),(0,r.jsx)(f,{})]})})});E.displayName=P;var W=c.forwardRef(({className:e,...o},a)=>{let{[C]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(n,{as:i.Label,ref:a,className:(0,t.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...o})});W.displayName=C;var D=c.forwardRef(({className:e,children:o,...a},n)=>{let{[v]:l=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsxs)(l,{as:i.Item,ref:n,className:(0,t.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...a,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(i.ItemIndicator,{children:(0,r.jsx)(s.Check,{className:"h-4 w-4"})})}),(0,r.jsx)(i.ItemText,{children:o})]})});D.displayName=v;var T=c.forwardRef(({className:e,...o},a)=>{let{[h]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,r.jsx)(n,{as:i.Separator,ref:a,className:(0,t.cn)("-mx-1 my-1 h-px bg-muted",e),...o})});T.displayName=h;0&&(module.exports={Select,SelectContent,SelectGroup,SelectItem,SelectLabel,SelectScrollDownButton,SelectScrollUpButton,SelectSeparator,SelectTrigger,SelectValue});
|
package/dist/select.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-PPOLDV3F.mjs";export{a as Select,g as SelectContent,b as SelectGroup,i as SelectItem,h as SelectLabel,f as SelectScrollDownButton,e as SelectScrollUpButton,j as SelectSeparator,d as SelectTrigger,c as SelectValue};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/select",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -29,20 +29,22 @@
|
|
|
29
29
|
"typescript": "^5.6.2",
|
|
30
30
|
"vite-tsconfig-paths": "^5.0.1",
|
|
31
31
|
"vitest": "^2.1.1",
|
|
32
|
-
"@stackshift-ui/
|
|
33
|
-
"@stackshift-ui/
|
|
32
|
+
"@stackshift-ui/eslint-config": "6.0.10",
|
|
33
|
+
"@stackshift-ui/typescript-config": "6.0.10"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@radix-ui/react-select": "^2.2.5",
|
|
36
37
|
"classnames": "^2.5.1",
|
|
37
|
-
"
|
|
38
|
-
"@stackshift-ui/scripts": "6.0.
|
|
38
|
+
"lucide-react": "^0.468.0",
|
|
39
|
+
"@stackshift-ui/scripts": "6.1.0-beta.0",
|
|
40
|
+
"@stackshift-ui/system": "6.1.0-beta.1"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
43
|
+
"@stackshift-ui/system": ">=6.1.0-beta.1",
|
|
41
44
|
"@types/react": "16.8 - 19",
|
|
42
45
|
"next": "10 - 14",
|
|
43
46
|
"react": "16.8 - 19",
|
|
44
|
-
"react-dom": "16.8 - 19"
|
|
45
|
-
"@stackshift-ui/system": ">=6.0.11"
|
|
47
|
+
"react-dom": "16.8 - 19"
|
|
46
48
|
},
|
|
47
49
|
"peerDependenciesMeta": {
|
|
48
50
|
"next": {
|
package/src/select.test.tsx
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { cleanup, render, screen } from "@testing-library/react";
|
|
2
2
|
import { afterEach, describe, test } from "vitest";
|
|
3
|
-
import { Select } from "./select";
|
|
3
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select";
|
|
4
4
|
|
|
5
5
|
describe.concurrent("select", () => {
|
|
6
6
|
afterEach(cleanup);
|
|
7
7
|
|
|
8
8
|
test("Common: Select - test if renders without errors", ({ expect }) => {
|
|
9
9
|
const clx = "select-class";
|
|
10
|
-
render(
|
|
11
|
-
<Select
|
|
12
|
-
className={clx}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const { unmount } = render(
|
|
11
|
+
<Select data-testid="select-container">
|
|
12
|
+
<SelectTrigger data-testid="select" className={clx}>
|
|
13
|
+
<SelectValue placeholder="Select an option" />
|
|
14
|
+
</SelectTrigger>
|
|
15
|
+
<SelectContent data-testid="select-content" className={clx}>
|
|
16
|
+
<SelectItem value="option1">Option 1</SelectItem>
|
|
17
|
+
<SelectItem value="option2">Option 2</SelectItem>
|
|
18
|
+
<SelectItem value="option3">Option 3</SelectItem>
|
|
19
|
+
</SelectContent>
|
|
20
|
+
</Select>,
|
|
17
21
|
);
|
|
22
|
+
|
|
18
23
|
expect(screen.getByTestId("select").classList).toContain(clx);
|
|
24
|
+
unmount();
|
|
19
25
|
});
|
|
20
26
|
});
|
package/src/select.tsx
CHANGED
|
@@ -1,86 +1,227 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type Variant = "primary" | "outline";
|
|
7
|
-
|
|
8
|
-
export interface SelectProps extends Omit<HTMLProps<HTMLSelectElement>, "as"> {
|
|
9
|
-
defaultValue?: string;
|
|
10
|
-
variant?: Variant;
|
|
11
|
-
label?: string;
|
|
12
|
-
labelClass?: string;
|
|
13
|
-
onChange?: () => void;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
name: string;
|
|
16
|
-
items: string[];
|
|
17
|
-
ariaLabel: string;
|
|
18
|
-
noLabel?: boolean;
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
children?: ReactNode;
|
|
21
|
-
className?: string;
|
|
22
|
-
as?: ElementType;
|
|
23
|
-
}
|
|
1
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
2
|
+
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
24
6
|
|
|
25
7
|
const displayName = "Select";
|
|
8
|
+
const displayNameTrigger = "SelectTrigger";
|
|
9
|
+
const displayNameValue = "SelectValue";
|
|
10
|
+
const displayNameContent = "SelectContent";
|
|
11
|
+
const displayNameItem = "SelectItem";
|
|
12
|
+
const displayNameGroup = "SelectGroup";
|
|
13
|
+
const displayNameLabel = "SelectLabel";
|
|
14
|
+
const displayNameSeparator = "SelectSeparator";
|
|
15
|
+
const displayNameScrollUpButton = "SelectScrollUpButton";
|
|
16
|
+
const displayNameScrollDownButton = "SelectScrollDownButton";
|
|
17
|
+
|
|
18
|
+
// bypass typescript "SelectSharedProps" error
|
|
19
|
+
interface SelectProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root> {}
|
|
20
|
+
|
|
21
|
+
const Select = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Root>, SelectProps>(
|
|
22
|
+
({ ...props }, ref) => {
|
|
23
|
+
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
noLabel = false,
|
|
38
|
-
children,
|
|
39
|
-
className,
|
|
40
|
-
as = "select",
|
|
41
|
-
...props
|
|
42
|
-
}) => {
|
|
43
|
-
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
44
|
-
|
|
45
|
-
const commonStyle =
|
|
46
|
-
"w-full rounded-global bg-white p-4 text-xs font-semibold leading-none outline-none";
|
|
47
|
-
const primary = `${commonStyle}`;
|
|
48
|
-
const outline = `${commonStyle} border border-solid border-primary-foreground`;
|
|
49
|
-
|
|
50
|
-
const variants: StyleVariants<Variant> = {
|
|
51
|
-
primary,
|
|
52
|
-
outline,
|
|
53
|
-
};
|
|
54
|
-
const variantClass = variants[variant] ?? primary;
|
|
25
|
+
return <Component as={SelectPrimitive.Root} ref={ref} {...props} />;
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
Select.displayName = displayName;
|
|
29
|
+
|
|
30
|
+
const SelectGroup = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof SelectPrimitive.Group>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Group>
|
|
33
|
+
>(({ className, ...props }, ref) => {
|
|
34
|
+
const { [displayNameGroup]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
55
35
|
|
|
56
36
|
return (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
<Component as={SelectPrimitive.Group} ref={ref} className={cn("p-1", className)} {...props} />
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
SelectGroup.displayName = displayNameGroup;
|
|
41
|
+
|
|
42
|
+
const SelectValue = React.forwardRef<
|
|
43
|
+
React.ElementRef<typeof SelectPrimitive.Value>,
|
|
44
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Value>
|
|
45
|
+
>(({ className, ...props }, ref) => {
|
|
46
|
+
const { [displayNameValue]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Component
|
|
50
|
+
as={SelectPrimitive.Value}
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={cn("text-sm outline-none", className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
SelectValue.displayName = displayNameValue;
|
|
58
|
+
|
|
59
|
+
const SelectTrigger = React.forwardRef<
|
|
60
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
61
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
62
|
+
>(({ className, children, ...props }, ref) => {
|
|
63
|
+
const { [displayNameTrigger]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Component
|
|
67
|
+
as={SelectPrimitive.Trigger}
|
|
68
|
+
ref={ref}
|
|
69
|
+
className={cn(
|
|
70
|
+
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
71
|
+
className,
|
|
62
72
|
)}
|
|
73
|
+
{...props}>
|
|
74
|
+
{children}
|
|
75
|
+
<SelectPrimitive.Icon asChild>
|
|
76
|
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
|
77
|
+
</SelectPrimitive.Icon>
|
|
78
|
+
</Component>
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
SelectTrigger.displayName = displayNameTrigger;
|
|
82
|
+
|
|
83
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
84
|
+
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
85
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
86
|
+
>(({ className, ...props }, ref) => {
|
|
87
|
+
const { [displayNameScrollUpButton]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<Component
|
|
91
|
+
as={SelectPrimitive.ScrollUpButton}
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={cn("flex cursor-default items-center justify-center py-1", className)}
|
|
94
|
+
{...props}>
|
|
95
|
+
<ChevronUp className="h-4 w-4" />
|
|
96
|
+
</Component>
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
SelectScrollUpButton.displayName = displayNameScrollUpButton;
|
|
100
|
+
|
|
101
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
102
|
+
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
103
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
104
|
+
>(({ className, ...props }, ref) => {
|
|
105
|
+
const { [displayNameScrollDownButton]: Component = DefaultComponent } =
|
|
106
|
+
useStackShiftUIComponents();
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Component
|
|
110
|
+
as={SelectPrimitive.ScrollDownButton}
|
|
111
|
+
ref={ref}
|
|
112
|
+
className={cn("flex cursor-default items-center justify-center py-1", className)}
|
|
113
|
+
{...props}>
|
|
114
|
+
<ChevronDown className="h-4 w-4" />
|
|
115
|
+
</Component>
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
SelectScrollDownButton.displayName = displayNameScrollDownButton;
|
|
119
|
+
|
|
120
|
+
const SelectContent = React.forwardRef<
|
|
121
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
122
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
123
|
+
>(({ className, children, position = "popper", ...props }, ref) => {
|
|
124
|
+
const { [displayNameContent]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<SelectPrimitive.Portal>
|
|
63
128
|
<Component
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
129
|
+
as={SelectPrimitive.Content}
|
|
130
|
+
ref={ref}
|
|
131
|
+
className={cn(
|
|
132
|
+
"relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",
|
|
133
|
+
position === "popper" &&
|
|
134
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
135
|
+
className,
|
|
136
|
+
)}
|
|
137
|
+
position={position}
|
|
138
|
+
{...props}>
|
|
139
|
+
<SelectScrollUpButton />
|
|
140
|
+
<SelectPrimitive.Viewport
|
|
141
|
+
className={cn(
|
|
142
|
+
"p-1",
|
|
143
|
+
position === "popper" &&
|
|
144
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
145
|
+
)}>
|
|
146
|
+
{children}
|
|
147
|
+
</SelectPrimitive.Viewport>
|
|
148
|
+
<SelectScrollDownButton />
|
|
81
149
|
</Component>
|
|
82
|
-
|
|
150
|
+
</SelectPrimitive.Portal>
|
|
83
151
|
);
|
|
84
|
-
};
|
|
152
|
+
});
|
|
153
|
+
SelectContent.displayName = displayNameContent;
|
|
85
154
|
|
|
86
|
-
|
|
155
|
+
const SelectLabel = React.forwardRef<
|
|
156
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
157
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
158
|
+
>(({ className, ...props }, ref) => {
|
|
159
|
+
const { [displayNameLabel]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<Component
|
|
163
|
+
as={SelectPrimitive.Label}
|
|
164
|
+
ref={ref}
|
|
165
|
+
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
|
|
166
|
+
{...props}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
SelectLabel.displayName = displayNameLabel;
|
|
171
|
+
|
|
172
|
+
const SelectItem = React.forwardRef<
|
|
173
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
174
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
175
|
+
>(({ className, children, ...props }, ref) => {
|
|
176
|
+
const { [displayNameItem]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<Component
|
|
180
|
+
as={SelectPrimitive.Item}
|
|
181
|
+
ref={ref}
|
|
182
|
+
className={cn(
|
|
183
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
184
|
+
className,
|
|
185
|
+
)}
|
|
186
|
+
{...props}>
|
|
187
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
188
|
+
<SelectPrimitive.ItemIndicator>
|
|
189
|
+
<Check className="h-4 w-4" />
|
|
190
|
+
</SelectPrimitive.ItemIndicator>
|
|
191
|
+
</span>
|
|
192
|
+
|
|
193
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
194
|
+
</Component>
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
SelectItem.displayName = displayNameItem;
|
|
198
|
+
|
|
199
|
+
const SelectSeparator = React.forwardRef<
|
|
200
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
201
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
202
|
+
>(({ className, ...props }, ref) => {
|
|
203
|
+
const { [displayNameSeparator]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<Component
|
|
207
|
+
as={SelectPrimitive.Separator}
|
|
208
|
+
ref={ref}
|
|
209
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
210
|
+
{...props}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
SelectSeparator.displayName = displayNameSeparator;
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
Select,
|
|
218
|
+
SelectContent,
|
|
219
|
+
SelectGroup,
|
|
220
|
+
SelectItem,
|
|
221
|
+
SelectLabel,
|
|
222
|
+
SelectScrollDownButton,
|
|
223
|
+
SelectScrollUpButton,
|
|
224
|
+
SelectSeparator,
|
|
225
|
+
SelectTrigger,
|
|
226
|
+
SelectValue,
|
|
227
|
+
};
|
package/dist/chunk-VCJRWWZ5.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{DefaultComponent as N,useStackShiftUIComponents as T}from"@stackshift-ui/system";import V from"classnames";import{Fragment as L,jsx as n,jsxs as x}from"react/jsx-runtime";var r="Select",v=({defaultValue:i,variant:c="primary",label:m,labelClass:p,onChange:d,required:g=!1,name:e,items:t,ariaLabel:P,noLabel:y=!1,children:R,className:u,as:b="select",...f})=>{var s;let{[r]:S=N}=T(),o="w-full rounded-global bg-white p-4 text-xs font-semibold leading-none outline-none",l=`${o}`,C=`${o} border border-solid border-primary-foreground`,h=(s={primary:l,outline:C}[c])!=null?s:l;return x(L,{children:[!y&&n("label",{htmlFor:e,className:p,children:m||e}),n(S,{onChange:d,name:e,defaultValue:i,required:g,as:b,className:V(h,u),...f,"data-testid":r,children:t&&t.length>0&&t.map(a=>n("option",{value:a,children:a},a))})]})};v.displayName=r;export{v as a};
|