@commercelayer/react-components 4.15.7 → 4.15.8-beta.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=tslib_1.__importDefault(require("react")),Parent_1=tslib_1.__importDefault(require("./Parent")),
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=tslib_1.__importDefault(require("react")),Parent_1=tslib_1.__importDefault(require("./Parent")),BaseSelect=(props,ref)=>{const{options=[],children,placeholder={label:"Select an option",value:""},value=""}=props,p=tslib_1.__rest(props,["options","children","placeholder","value"]);placeholder!=null&&(options.some(option=>option.value===placeholder.value)||options.unshift(placeholder));const Options=options.map((o,k)=>{const{label}=o,option=tslib_1.__rest(o,["label"]);return(0,jsx_runtime_1.jsx)("option",Object.assign({},option,{children:label}),k)}),parentProps=Object.assign({options,ref},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("select",Object.assign({ref,defaultValue:value},p,{children:Options}))};exports.default=react_1.default.forwardRef(BaseSelect);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import Parent from"./Parent";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import Parent from"./Parent";const BaseSelect=(props,ref)=>{const{options=[],children,placeholder={label:"Select an option",value:""},value="",...p}=props;placeholder!=null&&(options.some(option=>option.value===placeholder.value)||options.unshift(placeholder));const Options=options.map((o,k)=>{const{label,...option}=o;return _jsx("option",{...option,children:label},k)}),parentProps={options,ref,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("select",{ref,defaultValue:value,...p,children:Options})};export default React.forwardRef(BaseSelect);
|