UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

41 lines (40 loc) 2.62 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { accessibleHide, createSubcomponent } from '@workday/canvas-kit-react/common'; import { mergeStyles } from '@workday/canvas-kit-react/layout'; import { textStencil } from '@workday/canvas-kit-react/text'; import { createStencil, px2rem } from '@workday/canvas-kit-styling'; import { system } from '@workday/canvas-tokens-web'; import { useFormFieldLabel, useFormFieldModel } from './hooks'; export const formFieldLabelStencil = createStencil({ extends: textStencil, base: { name: "wq00l", styles: "box-sizing:border-box;font-weight:var(--cnvs-sys-font-weight-medium);color:var(--cnvs-sys-color-fg-default);padding-inline-start:0;display:flex;align-items:center;min-width:11.25rem;" }, modifiers: { isRequired: { true: { name: "3zvi5k", styles: "&::after{content:\"*\";font-size:var(--cnvs-sys-font-size-body-lg, var(--cnvs-sys-font-size-body-large, 1.25rem));font-weight:var(--cnvs-sys-font-weight-normal);color:var(--cnvs-sys-color-brand-fg-critical-default, var(--cnvs-brand-error-base, oklch(0.5342 0.2172 29.53 / 1)));text-decoration:unset;margin-inline-start:var(--cnvs-sys-gap-xs, var(--cnvs-sys-space-x1, 0.25rem));}" } }, orientation: { horizontalStart: { name: "35ii3k", styles: "justify-content:flex-start;float:left;max-height:var(--cnvs-sys-size-md, var(--cnvs-sys-space-x10, 2.5rem));" }, horizontalEnd: { name: "2xdeur", styles: "max-height:var(--cnvs-sys-size-md, var(--cnvs-sys-space-x10, 2.5rem));float:left;justify-content:flex-end;" }, vertical: { name: "1hz0np", styles: "width:100%;" } }, isHidden: { true: { name: "d6uff", styles: "clip:rect(1px, 1px, 1px, 1px);clip-path:polygon(0px 0px, 0px 0px, 0px 0px, 0px 0px);position:absolute;overflow:hidden;white-space:nowrap;height:1px;min-height:1px;width:1px;min-width:1px;margin:-1px;padding:0;border:0;" } } }, defaultModifiers: { typeLevel: 'subtext.large', } }, "form-field-label-6d3760"); export const FormFieldLabel = createSubcomponent('label')({ displayName: 'FormField.Label', modelHook: useFormFieldModel, elemPropsHook: useFormFieldLabel, })(({ children, typeLevel, variant, isHidden, ...elemProps }, Element, model) => { return (_jsx(Element, { ...mergeStyles(elemProps, formFieldLabelStencil({ typeLevel, variant, isHidden: isHidden ? 'true' : undefined, isRequired: model.state.isRequired, orientation: model.state.orientation, })), children: children })); });