UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

58 lines (57 loc) 3.58 kB
"use client"; import { g as n } from "./helpers.CexwVao7.js"; const r = 8, d = 5, w = ["medium", "small"], p = ["color", "date", "datetime-local", "email", "month", "number", "range", "tel", "text", "time", "url"], l = ["week", "file", "hidden", "button", "checkbox", "password", "radio", "search", "reset", "submit", "image", "datetime"], b = ({ hideLabel: e, id: o, label: a, prefix: s, popoverContent: c, suffix: i, leadingIconName: m, leadingIconSource: u, actionButtonProps: t }) => { if (!o) throw new Error(n("DSInput", 'A unique "id" prop is required. Please add a unique "id" prop to the DSInput component.')); if (!a) throw new Error(n("DSInput", `A label is always required for a11y reasons. Please add a descriptive "label" prop to the DSInput component. If you don't want to display a label, set hideLabel={true}.`)); if (t && !t.label) throw new Error(n("DSInput", "The action button needs to have a label for a11y reasons. Please add a label to the actionButtonProps.")); if (t && !t?.iconName && !t?.iconSource) throw new Error(n("DSInput", "The action button needs to have an iconName or iconSource. Please add an iconName or iconSource to the actionButtonProps.")); s && s.length > r && console.warn(n("DSInput", `Prefix length must not exceed ${r} characters.`)), i && i.length > d && console.warn(n("DSInput", `Suffix length must not exceed ${d} characters.`)), s && (m || u) && console.warn(n("DSInput", "Prefix and a leading Icon cannot be used at the same time.")), i && (t?.iconName || t?.iconSource) && console.warn(n("DSInput", "Suffix and an action button cannot be used at the same time.")), e && c && console.warn(n("DSInput", "Using a popover when hideLabel is set to true is not supported.")); }, I = (e, o) => { if (!p.includes(e) && !l.includes(e)) throw new Error(n("DSInput", `The type "${e}" is not supported by the DSInput component.`)); if (o === "off" && e === "number") return; const a = { number: "Type number is not recommended. Use type text with inputmode numeric/decimal or DSInputNumber component instead.", button: "Type button is not recommended. Use DSButton component instead.", file: "Type file is not recommended. Use DSInputFile component instead.", checkbox: "Type checkbox is not recommended. Use DSCheckbox component instead.", password: "Type password is not recommended. Use DSInputPassword component instead.", radio: "Type radio is not recommended. Use DSRadioGroup component instead.", search: "Type search is not recommended. Use DSInputSearch component instead.", reset: "Type reset is not recommended. Use DSButton component with type reset instead.", submit: "Type submit is not recommended. Use DSButton component with type submit instead.", image: "Type image is not recommended. Use DSButton component instead.", datetime: "Type datetime is not recommended. Use type datetime-local instead.", week: "Type week is not recommended. Mobile safari does not support type week.", hidden: 'Type hidden is not supported by DSInput component. Use a default <input type="hidden" /> element instead.' }; a[e] && console.warn(n("DSInput", a[e])); }, h = () => "showPicker" in HTMLInputElement.prototype && !!window.navigator.userAgent.match(/chrome|chromium|crios|edg/i), T = (e, o) => h() && (e || o), D = (e) => e === "date" || e === "datetime-local" || e === "month", f = (e) => e === "time"; export { w as I, r as M, p as S, l as U, d as a, f as b, I as c, h, D as i, T as s, b as v };