UNPKG

@trimble-oss/moduswebcomponents

Version:

Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust

118 lines (112 loc) 4.29 kB
import { withActions } from "@storybook/addon-actions/decorator"; import { html } from "lit"; import { ifDefined } from "lit/directives/if-defined.js"; import { createShadowHostClass } from "../../providers/shadow-dom/shadow-host-helper"; const meta = { title: 'Components/Forms/Slider', component: 'modus-wc-slider', args: { 'custom-class': '', disabled: false, label: 'Label', name: '', required: false, size: 'md', value: true, }, argTypes: { size: { control: { type: 'select' }, options: ['sm', 'md', 'lg'], }, }, decorators: [withActions], parameters: { actions: { handles: ['inputBlur', 'inputChange', 'inputFocus'], }, }, }; export default meta; export const Default = { render: (args) => { return html ` <modus-wc-slider aria-label="Slider" custom-class=${ifDefined(args['custom-class'])} ?disabled=${args.disabled} input-id=${ifDefined(args['input-id'])} input-tab-index=${ifDefined(args['input-tab-index'])} label=${ifDefined(args.label)} max=${ifDefined(args.max)} min=${ifDefined(args.min)} name=${ifDefined(args.name)} ?required=${args.required} size=${ifDefined(args.size)} step=${ifDefined(args.step)} .value=${args.value} ></modus-wc-slider> `; }, }; export const ShadowDomParent = { render: (args) => { // Create a unique shadow host for slider component if (!customElements.get('slider-shadow-host')) { const SliderShadowHost = createShadowHostClass({ componentTag: 'modus-wc-slider', propsMapper: (v, el) => { var _a, _b, _c, _d, _e, _f, _g, _h; const sliderEl = el; sliderEl.customClass = v['custom-class'] || ''; sliderEl.disabled = Boolean(v.disabled); sliderEl.inputId = (_a = v['input-id']) !== null && _a !== void 0 ? _a : ''; sliderEl.inputTabIndex = (_b = v['input-tab-index']) !== null && _b !== void 0 ? _b : 0; sliderEl.label = (_c = v.label) !== null && _c !== void 0 ? _c : ''; sliderEl.max = (_d = v.max) !== null && _d !== void 0 ? _d : 100; sliderEl.min = (_e = v.min) !== null && _e !== void 0 ? _e : 0; sliderEl.name = (_f = v.name) !== null && _f !== void 0 ? _f : ''; sliderEl.required = Boolean(v.required); sliderEl.size = (_g = v.size) !== null && _g !== void 0 ? _g : 'md'; sliderEl.step = (_h = v.step) !== null && _h !== void 0 ? _h : 1; sliderEl.value = typeof v.value === 'number' ? v.value : 0; }, }); customElements.define('slider-shadow-host', SliderShadowHost); } return html `<slider-shadow-host .props=${Object.assign({}, args)} ></slider-shadow-host>`; }, }; export const Migration = { parameters: { docs: { description: { story: ` #### Breaking Changes - In 1.0 input state was maintained by the component. 2.0 components encourage users to follow a controlled input model. See the Form Inputs [documentation](/docs/documentation-form-inputs--docs) for additional info and examples. - Property names have changed: \`max-value\` → \`max\`, \`min-value\` → \`min\`. #### Prop Mapping | 1.0 Prop | 2.0 Prop | Notes | |-------------|--------------|-------| | aria-label | aria-label | | | disabled | disabled | | | label | label | | | max-value | max | | | min-value | min | | | value | value | | #### Event Mapping | 1.0 Event | 2.0 Event | Notes | |-------------|-------------|------------------| | valueChange | | Not carried over | | valueInput | inputChange | | `, }, }, controls: { disable: true }, canvas: { disable: true }, }, render: () => html `<div></div>`, };