UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

58 lines (57 loc) 3.54 kB
"use client"; import { g as t } from "./helpers.BbWkXTr3.js"; import "./index.CgTHIF3K.js"; import "react"; const i = 8, d = 5, w = ["medium", "small"], c = ["color", "date", "datetime-local", "email", "month", "number", "range", "tel", "text", "time", "url"], p = ["week", "file", "hidden", "button", "checkbox", "password", "radio", "search", "reset", "submit", "image", "datetime"], I = ({ id: e, label: a, prefix: o, suffix: s, leadingIconName: r, leadingIconSource: m, actionButtonProps: n }) => { if (!e) throw new Error(t("DSInput", 'A unique "id" prop is required. Please add a unique "id" prop to the DSInput component.')); if (!a) throw new Error(t("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 (n && !n.label) throw new Error(t("DSInput", "The action button needs to have a label for a11y reasons. Please add a label to the actionButtonProps.")); if (n && !(n != null && n.iconName) && !(n != null && n.iconSource)) throw new Error(t("DSInput", "The action button needs to have an iconName or iconSource. Please add an iconName or iconSource to the actionButtonProps.")); o && o.length > i && console.warn(t("DSInput", `Prefix length must not exceed ${i} characters.`)), s && s.length > d && console.warn(t("DSInput", `Suffix length must not exceed ${d} characters.`)), o && (r || m) && console.warn(t("DSInput", "Prefix and a leading Icon cannot be used at the same time.")), s && (n != null && n.iconName || n != null && n.iconSource) && console.warn(t("DSInput", "Suffix and an action button cannot be used at the same time.")); }, b = (e, a) => { if (!c.includes(e) && !p.includes(e)) throw new Error(t("DSInput", `The type "${e}" is not supported by the DSInput component.`)); if (a === "off" && e === "number") return; const o = { number: "Type number is not recommended. Use type text with inputmode numeric/decimal or DSInputStepper 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.' }; o[e] && console.warn(t("DSInput", o[e])); }, u = () => "showPicker" in HTMLInputElement.prototype && !!window.navigator.userAgent.match(/chrome|chromium|crios|edg/i), T = (e, a) => u() && (e || a), D = (e) => e === "date" || e === "datetime-local" || e === "month", y = (e) => e === "time"; export { w as I, i as M, c as S, p as U, d as a, b, y as c, u as h, D as i, T as s, I as v };