UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

60 lines (59 loc) 3.62 kB
"use client"; import { g as t } from "./helpers.CexwVao7.js"; import "react"; import "./index.D-sRdssb.js"; const r = 8, d = 5, I = ["medium", "small"], u = ["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"], T = ({ hideLabel: e, id: o, label: a, prefix: s, popoverContent: c, suffix: i, leadingIconName: m, leadingIconSource: p, actionButtonProps: n }) => { if (!o) 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?.iconName && !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.")); s && s.length > r && console.warn(t("DSInput", `Prefix length must not exceed ${r} characters.`)), i && i.length > d && console.warn(t("DSInput", `Suffix length must not exceed ${d} characters.`)), s && (m || p) && console.warn(t("DSInput", "Prefix and a leading Icon cannot be used at the same time.")), i && (n?.iconName || n?.iconSource) && console.warn(t("DSInput", "Suffix and an action button cannot be used at the same time.")), e && c && console.warn(t("DSInput", "Using a popover when hideLabel is set to true is not supported.")); }, D = (e, o) => { if (!u.includes(e) && !l.includes(e)) throw new Error(t("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(t("DSInput", a[e])); }, h = () => "showPicker" in HTMLInputElement.prototype && !!window.navigator.userAgent.match(/chrome|chromium|crios|edg/i), f = (e, o) => h() && (e || o), y = (e) => e === "date" || e === "datetime-local" || e === "month", U = (e) => e === "time"; export { I, r as M, u as S, l as U, d as a, D as b, U as c, h, y as i, f as s, T as v };