@rededor/cura 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/assets/cura-assets.zip +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Black.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-BlackItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Bold.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-BoldItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Book.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-BookItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-ExtraLight.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-ExtraLightItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Light.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-LightItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Medium.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-MediumItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Thin.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-ThinItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-Ultra.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/Gotham-UltraItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Gotham/style.css +90 -0
- package/dist/assets/assets/fonts/HankenGrotesk/HankenGrotesk-Italic-VariableFont_wght.woff2 +0 -0
- package/dist/assets/assets/fonts/HankenGrotesk/HankenGrotesk-VariableFont_wght.woff2 +0 -0
- package/dist/assets/assets/fonts/HankenGrotesk/style-webfont.css +72 -0
- package/dist/assets/assets/fonts/HankenGrotesk/style.css +16 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Black.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-BlackItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Bold.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-BoldItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Italic.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Light.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-LightItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Medium.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-MediumItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Regular.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-Thin.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/Roboto-ThinItalic.woff2 +0 -0
- package/dist/assets/assets/fonts/Roboto/style-webfont.css +756 -0
- package/dist/assets/assets/fonts/Roboto/style.css +90 -0
- package/dist/assets/assets/images/avatar/doctor-default.svg +6 -7
- package/dist/assets/assets/images/avatar/doctor-default_old.svg +8 -0
- package/dist/assets/assets/images/avatar/dora-default.svg +3 -4
- package/dist/assets/assets/images/avatar/dora-default_old.svg +5 -0
- package/dist/assets/assets/images/avatar/patient-default.svg +16 -10
- package/dist/assets/assets/images/avatar/patient-default_old.svg +12 -0
- package/dist/assets/assets/images/avatar/unit-default.svg +7 -8
- package/dist/assets/assets/images/avatar/unit-default_old.svg +9 -0
- package/dist/cjs/{app-globals-b77d5b06.js → app-globals-4d07f363.js} +20 -4
- package/dist/cjs/app-globals-4d07f363.js.map +1 -0
- package/dist/cjs/cura-accordion_12.cjs.entry.js +8 -7
- package/dist/cjs/cura-accordion_12.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-button-outline.cjs.entry.js +1 -1
- package/dist/cjs/cura-button-outline.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-button-transparent.cjs.entry.js +1 -1
- package/dist/cjs/cura-button-transparent.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-calendar.cjs.entry.js +9 -4
- package/dist/cjs/cura-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/cura-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-dropdown-search.cjs.entry.js +5 -4
- package/dist/cjs/cura-dropdown-search.cjs.entry.js.map +1 -1
- package/dist/cjs/cura.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/api/theme-presets/theme-default.js +3 -3
- package/dist/collection/api/theme-presets/theme-default.js.map +1 -1
- package/dist/collection/api/theme-presets/theme-legacy-default.js +16 -0
- package/dist/collection/api/theme-presets/theme-legacy-default.js.map +1 -1
- package/dist/collection/assets/images/avatar/doctor-default.svg +6 -7
- package/dist/collection/assets/images/avatar/doctor-default_old.svg +8 -0
- package/dist/collection/assets/images/avatar/dora-default.svg +3 -4
- package/dist/collection/assets/images/avatar/dora-default_old.svg +5 -0
- package/dist/collection/assets/images/avatar/patient-default.svg +16 -10
- package/dist/collection/assets/images/avatar/patient-default_old.svg +12 -0
- package/dist/collection/assets/images/avatar/unit-default.svg +7 -8
- package/dist/collection/assets/images/avatar/unit-default_old.svg +9 -0
- package/dist/collection/components/buttons/cura-button/cura-button.js +1 -1
- package/dist/collection/components/buttons/cura-button/cura-button.js.map +1 -1
- package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.js +1 -1
- package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.js.map +1 -1
- package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.js +1 -1
- package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.js.map +1 -1
- package/dist/collection/components/cura-calendar/cura-calendar.css +13 -5
- package/dist/collection/components/cura-calendar/cura-calendar.js +61 -6
- package/dist/collection/components/cura-calendar/cura-calendar.js.map +1 -1
- package/dist/collection/components/cura-calendar/cura-calendar.stories.js +33 -3
- package/dist/collection/components/cura-calendar/cura-calendar.stories.js.map +1 -1
- package/dist/collection/components/forms/cura-checkbox/cura-checkbox.css +13 -5
- package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.js +23 -4
- package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.js.map +1 -1
- package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.stories.js +19 -6
- package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.stories.js.map +1 -1
- package/dist/collection/components/forms/cura-select/cura-select.css +1 -0
- package/dist/collection/components/forms/cura-select/cura-select.js +23 -4
- package/dist/collection/components/forms/cura-select/cura-select.js.map +1 -1
- package/dist/collection/components/forms/cura-select/cura-select.stories.js +11 -1
- package/dist/collection/components/forms/cura-select/cura-select.stories.js.map +1 -1
- package/dist/collection/components/text/cura-paragraph/cura-paragraph.css +3 -1
- package/dist/collection/stories/blocks/index.js +85 -0
- package/dist/components/cura-button-outline.js +1 -1
- package/dist/components/cura-button-outline.js.map +1 -1
- package/dist/components/cura-button-transparent2.js +1 -1
- package/dist/components/cura-button-transparent2.js.map +1 -1
- package/dist/components/cura-button.js +1 -1
- package/dist/components/cura-button.js.map +1 -1
- package/dist/components/cura-calendar.js +12 -4
- package/dist/components/cura-calendar.js.map +1 -1
- package/dist/components/cura-checkbox.js +1 -1
- package/dist/components/cura-checkbox.js.map +1 -1
- package/dist/components/cura-dropdown-search.js +6 -4
- package/dist/components/cura-dropdown-search.js.map +1 -1
- package/dist/components/cura-paragraph2.js +1 -1
- package/dist/components/cura-paragraph2.js.map +1 -1
- package/dist/components/cura-select2.js +7 -5
- package/dist/components/cura-select2.js.map +1 -1
- package/dist/components/index.js +19 -3
- package/dist/components/index.js.map +1 -1
- package/dist/cura/cura.esm.js +1 -1
- package/dist/cura/cura.esm.js.map +1 -1
- package/dist/cura/p-0b7a7306.js +2 -0
- package/dist/cura/p-0b7a7306.js.map +1 -0
- package/dist/cura/p-42dfa3a7.entry.js +2 -0
- package/dist/cura/p-42dfa3a7.entry.js.map +1 -0
- package/dist/cura/{p-599acc84.entry.js → p-5ac9d510.entry.js} +2 -2
- package/dist/cura/p-5ac9d510.entry.js.map +1 -0
- package/dist/cura/{p-b301a1ef.entry.js → p-9b658260.entry.js} +2 -2
- package/dist/cura/{p-b301a1ef.entry.js.map → p-9b658260.entry.js.map} +1 -1
- package/dist/cura/{p-4ef24fbd.entry.js → p-a9cda3b1.entry.js} +2 -2
- package/dist/cura/p-a9cda3b1.entry.js.map +1 -0
- package/dist/cura/{p-0a923806.entry.js → p-afd2c148.entry.js} +2 -2
- package/dist/cura/{p-0a923806.entry.js.map → p-afd2c148.entry.js.map} +1 -1
- package/dist/cura/p-fbf20e5a.entry.js +2 -0
- package/dist/cura/p-fbf20e5a.entry.js.map +1 -0
- package/dist/esm/{app-globals-488bf508.js → app-globals-6ca7103d.js} +20 -4
- package/dist/esm/app-globals-6ca7103d.js.map +1 -0
- package/dist/esm/cura-accordion_12.entry.js +8 -7
- package/dist/esm/cura-accordion_12.entry.js.map +1 -1
- package/dist/esm/cura-button-outline.entry.js +1 -1
- package/dist/esm/cura-button-outline.entry.js.map +1 -1
- package/dist/esm/cura-button-transparent.entry.js +1 -1
- package/dist/esm/cura-button-transparent.entry.js.map +1 -1
- package/dist/esm/cura-calendar.entry.js +9 -4
- package/dist/esm/cura-calendar.entry.js.map +1 -1
- package/dist/esm/cura-checkbox.entry.js +1 -1
- package/dist/esm/cura-checkbox.entry.js.map +1 -1
- package/dist/esm/cura-dropdown-search.entry.js +5 -4
- package/dist/esm/cura-dropdown-search.entry.js.map +1 -1
- package/dist/esm/cura.js +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/types/api/theme-presets/theme-legacy-default.d.ts +3 -3
- package/dist/types/api/theme-presets/theme-presets.d.ts +3 -3
- package/dist/types/components/cura-calendar/cura-calendar.d.ts +3 -0
- package/dist/types/components/cura-calendar/cura-calendar.stories.d.ts +33 -0
- package/dist/types/components/forms/cura-dropdown-search/cura-dropdown-search.d.ts +7 -3
- package/dist/types/components/forms/cura-dropdown-search/cura-dropdown-search.stories.d.ts +14 -0
- package/dist/types/components/forms/cura-select/cura-select.d.ts +5 -0
- package/dist/types/components/forms/cura-select/cura-select.stories.d.ts +11 -0
- package/dist/types/components.d.ts +22 -0
- package/package.json +5 -3
- package/dist/cjs/app-globals-b77d5b06.js.map +0 -1
- package/dist/cura/p-0dd837cf.entry.js +0 -2
- package/dist/cura/p-0dd837cf.entry.js.map +0 -1
- package/dist/cura/p-4ef24fbd.entry.js.map +0 -1
- package/dist/cura/p-599acc84.entry.js.map +0 -1
- package/dist/cura/p-a6c3c0ea.js +0 -2
- package/dist/cura/p-a6c3c0ea.js.map +0 -1
- package/dist/cura/p-dc5d0c29.entry.js +0 -2
- package/dist/cura/p-dc5d0c29.entry.js.map +0 -1
- package/dist/esm/app-globals-488bf508.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cura-dropdown-search.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-dropdown-search/cura-dropdown-search.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAOrG,MAAM,OAAO,kBAAkB;;QA8GrB,mBAAc,GAA0B,IAAI,CAAC;QAkE7C,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,CAAC,CAAC;YACrF,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAClC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC5B,CAAC,CAAC;QAiBM,sBAAiB,GAAG,CAAC,KAAY,EAAE,EAAE;YAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, State, Event, EventEmitter, Element, Watch, h } from '@stencil/core';\n\n@Component({\n tag: 'cura-dropdown-search',\n styleUrl: 'cura-dropdown-search.scss',\n shadow: true,\n})\nexport class CuraDropdownSearch {\n /**\n * Define the status of the dropdown search.\n */\n @Prop({ reflect: true }) status: 'error' | 'default' = 'default';\n\n /**\n * Whether the select component is disabled.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * The name of the dropdown search component.\n */\n @Prop({ reflect: true }) name: string;\n\n /**\n * Indicates if the dropdown search is required.\n */\n @Prop({ reflect: true, mutable: true }) required: boolean = false;\n\n /**\n * Indicates if the dropdown search is selected.\n */\n @Prop({ reflect: true, mutable: true }) selected: boolean = false;\n\n /**\n * The value of the dropdown search.\n */\n @Prop({ reflect: true, mutable: true }) value: string = '';\n\n /**\n * The placeholder text for the dropdown search.\n */\n @Prop({ reflect: true, mutable: true }) placeholder: string = '';\n\n /**\n * The label for the dropdown search.\n */\n @Prop({ reflect: true, mutable: true }) label: string = '';\n\n /**\n * Custom icon name. Default: search.\n */\n @Prop({reflect: true}) iconName = 'search';\n\n /**\n * CSS max-height property for dropdown item.\n * Default to 630px\n */\n @Prop({reflect: true}) dropdownMaxHeight = '630px';\n\n /**\n * Reference to the host element.\n */\n @Element() host: HTMLElement;\n\n /**\n * Indicates if the overlay is visible.\n */\n @State() overlayVisible: boolean = false;\n\n /**\n * Event emitted when the value changes.\n */\n @Event() valueChanged: EventEmitter<string>;\n\n /**\n * Indicates if the dropdown is open.\n */\n @State() isDropdownOpen: boolean = false;\n\n /**\n * Styles for the component.\n\n */\n @State() styles = {};\n\n /**\n * Indicates if the component is being viewed on a mobile device.\n */\n @State() isMobile: boolean = window.innerWidth < 768;\n\n /**\n * The mode of the dropdown search.\n */\n @State() mode: 'default' | 'transparent' = 'default';\n\n @Event() onselect: EventEmitter;\n\n @State() inputTextRef!: HTMLCuraInputTextElement;\n\n /**\n * Indicates if the input is on blur.\n */\n @State() isOnBlurInput: boolean = true;\n\n /**\n * The index of the currently hovered option.\n */\n @State() hoveredIndex: number = -1;\n\n /**\n * The options for the dropdown search.\n * @type {HTMLCuraDropdownSearchOptionElement[]}\n */\n\n weights;\n\n private overlayElement: HTMLDivElement | null = null;\n\n @State() options: HTMLCuraDropdownSearchOptionElement[] = [];\n\n connectedCallback() {\n this.weights = window.CuraAPI.theme.fonts.getWeights();\n this.styles['--info-base'] = window.CuraAPI.theme.colors.getColor('info-base');\n this.styles['--neutral-purewhite'] = window.CuraAPI.theme.colors.getColor('neutral-purewhite');\n this.styles['--neutral-light'] = window.CuraAPI.theme.colors.getColor('neutral-light');\n this.styles['--neutral-dark'] = window.CuraAPI.theme.colors.getColor('neutral-dark');\n this.styles['--neutral-black-shadow'] = window.CuraAPI.theme.colors.getColor(`neutral-black`, 0.16);\n this.styles['--error-dark'] = window.CuraAPI.theme.colors.getColor('error-dark');\n this.styles['--error-lighter'] = window.CuraAPI.theme.colors.getColor('error-lighter');\n this.styles['--breakpoints'] = window.CuraAPI.theme.breakpoints.get();\n this.styles['--font-size'] = window.CuraAPI.theme.fonts.getSize();\n this.styles['--font-family'] = window.CuraAPI.theme.fonts.getFamily();\n this.styles['--font-weight-medium'] = this.weights.medium;\n }\n\n @Watch('value')\n onValueChange(newValue: string) {\n this.updateSelectedOption(newValue);\n this.valueChanged.emit(newValue);\n }\n\n componentWillLoad() {\n this.updateSelectedOption(this.value);\n }\n\n componentDidRender() {\n if (this.isDropdownOpen && this.isMobile) {\n this.showOverlay();\n } else {\n this.removeOverlay();\n }\n }\n componentDidLoad() {\n window.addEventListener('resize', this.handleResize);\n }\n\n disconnectedCallback() {\n window.removeEventListener('resize', this.handleResize);\n }\n\n private showOverlay() {\n if (!this.overlayElement) {\n this.overlayElement = document.createElement('div');\n this.overlayElement.className = 'dropdown-overlay';\n this.overlayElement.style.position = 'fixed';\n this.overlayElement.style.top = '0';\n this.overlayElement.style.left = '0';\n this.overlayElement.style.width = '100%';\n this.overlayElement.style.height = '100%';\n this.overlayElement.style.zIndex = '9999';\n this.overlayElement.style.backgroundColor = 'white';\n document.body.appendChild(this.overlayElement);\n }\n }\n\n private removeOverlay() {\n if (this.overlayElement && this.overlayElement.parentNode === document.body) {\n document.body.removeChild(this.overlayElement);\n this.overlayElement = null;\n }\n }\n\n private handleSlotChange = () => {\n this.options = Array.from(this.host.querySelectorAll('cura-dropdown-search-option'));\n this.addClickListenersToOptions();\n this.updateHoveredIndex();\n };\n\n private addClickListenersToOptions() {\n this.options.forEach((option, index) => {\n option.addEventListener('optionSelected', () => this.onSelectedOption(index));\n });\n }\n\n private updateSelectedOption(value: string) {\n const selectedOptionIndex = this.options.findIndex(option => option.getAttribute('value') === value);\n this.hoveredIndex = selectedOptionIndex;\n this.updateOptionAttribute('hovered', this.hoveredIndex);\n this.updateOptionAttribute('selected', this.hoveredIndex);\n\n this.scrollIntoView();\n }\n\n private handleInputChange = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.value = input.value;\n this.onValueChange(this.value);\n // this.valueChanged.emit(this.value);\n };\n\n private onSelectedOption(index: number) {\n const selectedOption = this.options[index];\n if(selectedOption.selectable) {\n const selectedValue = selectedOption.getAttribute('value') || selectedOption.textContent;\n\n this.value = selectedValue || '';\n this.updateSelectedOption(this.value);\n\n this.isDropdownOpen = false;\n this.isOnBlurInput = true;\n this.removeOverlay();\n }\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n this.moveHighlight(1);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n this.moveHighlight(-1);\n } else if (event.key === 'Enter') {\n event.preventDefault();\n if (this.hoveredIndex > -1) {\n this.handleOnBlur();\n this.onSelectedOption(this.hoveredIndex);\n }\n }\n };\n\n private moveHighlight(direction: number) {\n const visibleOptions = this.options;\n const newIndex = (this.hoveredIndex + direction + visibleOptions.length) % visibleOptions.length;\n this.hoveredIndex = newIndex;\n this.updateOptionAttribute('hovered', this.hoveredIndex);\n this.scrollIntoView();\n }\n\n private updateOptionAttribute(attribute: string, indexToUpdate: number) {\n this.options.forEach((option, index) => {\n (option as any)[attribute] = index === indexToUpdate;\n });\n }\n\n private updateHoveredIndex() {\n const visibleOptions = this.options;\n const currentValue = this.value;\n this.hoveredIndex = visibleOptions.findIndex(option => option.getAttribute('value') === currentValue);\n }\n\n private scrollIntoView() {\n const container = this.host.shadowRoot?.querySelector('.dropdown-search-list');\n const hoveredOption = this.options[this.hoveredIndex];\n\n if (container && hoveredOption) {\n const optionRect = hoveredOption.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n\n if (optionRect.bottom > containerRect.bottom) {\n container.scrollTop += optionRect.bottom - containerRect.bottom;\n }\n\n if (optionRect.top < containerRect.top) {\n container.scrollTop -= containerRect.top - optionRect.top;\n }\n }\n }\n\n private handleResize = () => {\n this.isMobile = window.innerWidth < 768;\n if (this.isDropdownOpen) {\n if (this.isMobile) {\n this.showOverlay();\n } else {\n this.removeOverlay();\n }\n }\n };\n\n handleOnBlur() {\n if (this.isOnBlurInput === true) {\n setTimeout(() => {\n this.isDropdownOpen = false;\n this.removeOverlay();\n }, 200);\n }\n }\n getClasses() {\n return {\n 'dropdown-input-search': true,\n 'dropdown-open': this.isDropdownOpen,\n disabled: this.disabled,\n [this.status]: true,\n };\n }\n\n getDropdownClasses() {\n return {\n 'dropdown-search-list': true,\n 'visible': this.options.length && this.isDropdownOpen ? true : false\n };\n }\n\n hostCSSProperties() {\n return {\n '--dropdown-max-height': this.dropdownMaxHeight,\n };\n }\n\n render() {\n const isMobileDropdown = this.isMobile && this.isDropdownOpen;\n return (\n <Host style={this.hostCSSProperties()} class=\"dropdown-overlay\">\n <div class={`dropdown ${isMobileDropdown ? 'dropdown-mobile' : ''}`} style={this.styles}>\n <div class={this.getClasses()}>\n {this.isMobile && this.isDropdownOpen && (\n <cura-button-transparent\n fontColor=\"dark\"\n onClick={() => (this.isMobile = false)}\n iconName=\"arrowLeft\"\n size=\"medium\"\n iconOnly\n color=\"primary\"\n ></cura-button-transparent>\n )}\n <cura-input-text\n disabled={this.disabled}\n label={this.label}\n part=\"cura-input-field\"\n mode={isMobileDropdown ? 'transparent' : 'default'}\n required={this.required}\n hideErrorIcon={this.status === 'error'}\n iconName={this.iconName || 'search'}\n value={this.value}\n status={this.status}\n onValueChange={e => this.onValueChange(e.target.value as string)}\n onInput={e => this.handleInputChange(e)}\n onFocus={() => (this.isDropdownOpen = true)}\n onClick={() => (window.innerWidth < 768 ? (this.isMobile = true) : null)}\n onBlur={() => {\n this.handleOnBlur();\n }}\n placeholder={this.placeholder}\n size=\"large\"\n onKeyDown={this.handleKeyDown}\n >\n <slot name=\"helperText\"></slot>\n </cura-input-text>\n </div>\n <div id=\"dropdown-search-list\" class={this.getDropdownClasses()}>\n <slot name=\"dropdown-search-option\" onSlotchange={this.handleSlotChange}></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cura-dropdown-search.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-dropdown-search/cura-dropdown-search.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAOrG,MAAM,OAAO,kBAAkB;;QAmHrB,mBAAc,GAA0B,IAAI,CAAC;QAkE7C,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IA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C,YAAY,GAAQ,CACf,CACd;gBACN,4DAAK,EAAE,EAAC,sBAAsB,EAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE;oBAC7D,6DAAM,IAAI,EAAC,wBAAwB,EAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,GAAS,CAC5E,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, State, Event, EventEmitter, Element, Watch, h } from '@stencil/core';\n\n@Component({\n tag: 'cura-dropdown-search',\n styleUrl: 'cura-dropdown-search.scss',\n shadow: true,\n})\nexport class CuraDropdownSearch {\n /**\n * Size of the dropdown search mode default: 'small', 'medium', or 'large' (default: 'large')\n */\n @Prop({ reflect: true, mutable: true }) size: 'small' | 'medium' | 'large' = 'large';\n\n /**\n * Define the status of the dropdown search.\n */\n @Prop({ reflect: true }) status: 'error' | 'default' = 'default';\n\n /**\n * Whether the select component is disabled.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * The name of the dropdown search component.\n */\n @Prop({ reflect: true }) name: string;\n\n /**\n * Indicates if the dropdown search is required.\n */\n @Prop({ reflect: true, mutable: true }) required: boolean = false;\n\n /**\n * Indicates if the dropdown search is selected.\n */\n @Prop({ reflect: true, mutable: true }) selected: boolean = false;\n\n /**\n * The value of the dropdown search.\n */\n @Prop({ reflect: true, mutable: true }) value: string = '';\n\n /**\n * The placeholder text for the dropdown search.\n */\n @Prop({ reflect: true, mutable: true }) placeholder: string = '';\n\n /**\n * The label for the dropdown search.\n */\n @Prop({ reflect: true, mutable: true }) label: string = '';\n\n /**\n * Custom icon name. Default: search.\n */\n @Prop({ reflect: true }) iconName = 'search';\n\n /**\n * CSS max-height property for dropdown item.\n * Default to 630px\n */\n @Prop({ reflect: true }) dropdownMaxHeight = '630px';\n\n /**\n * Reference to the host element.\n */\n @Element() host: HTMLElement;\n\n /**\n * Indicates if the overlay is visible.\n */\n @State() overlayVisible: boolean = false;\n\n /**\n * Event emitted when the value changes.\n */\n @Event() valueChanged: EventEmitter<string>;\n\n /**\n * Indicates if the dropdown is open.\n */\n @State() isDropdownOpen: boolean = false;\n\n /**\n * Styles for the component.\n\n */\n @State() styles = {};\n\n /**\n * Indicates if the component is being viewed on a mobile device.\n */\n @State() isMobile: boolean = window.innerWidth < 768;\n\n /**\n * The mode of the dropdown search.\n */\n @State() mode: 'default' | 'transparent' = 'default';\n\n @Event() onselect: EventEmitter;\n\n @State() inputTextRef!: HTMLCuraInputTextElement;\n\n /**\n * Indicates if the input is on blur.\n */\n @State() isOnBlurInput: boolean = true;\n\n /**\n * The index of the currently hovered option.\n */\n @State() hoveredIndex: number = -1;\n\n /**\n * The options for the dropdown search.\n * @type {HTMLCuraDropdownSearchOptionElement[]}\n */\n\n weights;\n\n private overlayElement: HTMLDivElement | null = null;\n\n @State() options: HTMLCuraDropdownSearchOptionElement[] = [];\n\n connectedCallback() {\n this.weights = window.CuraAPI.theme.fonts.getWeights();\n this.styles['--info-base'] = window.CuraAPI.theme.colors.getColor('info-base');\n this.styles['--neutral-purewhite'] = window.CuraAPI.theme.colors.getColor('neutral-purewhite');\n this.styles['--neutral-light'] = window.CuraAPI.theme.colors.getColor('neutral-light');\n this.styles['--neutral-dark'] = window.CuraAPI.theme.colors.getColor('neutral-dark');\n this.styles['--neutral-black-shadow'] = window.CuraAPI.theme.colors.getColor(`neutral-black`, 0.16);\n this.styles['--error-dark'] = window.CuraAPI.theme.colors.getColor('error-dark');\n this.styles['--error-lighter'] = window.CuraAPI.theme.colors.getColor('error-lighter');\n this.styles['--breakpoints'] = window.CuraAPI.theme.breakpoints.get();\n this.styles['--font-size'] = window.CuraAPI.theme.fonts.getSize();\n this.styles['--font-family'] = window.CuraAPI.theme.fonts.getFamily();\n this.styles['--font-weight-medium'] = this.weights.medium;\n }\n\n @Watch('value')\n onValueChange(newValue: string) {\n this.updateSelectedOption(newValue);\n this.valueChanged.emit(newValue);\n }\n\n componentWillLoad() {\n this.updateSelectedOption(this.value);\n }\n\n componentDidRender() {\n if (this.isDropdownOpen && this.isMobile) {\n this.showOverlay();\n } else {\n this.removeOverlay();\n }\n }\n componentDidLoad() {\n window.addEventListener('resize', this.handleResize);\n }\n\n disconnectedCallback() {\n window.removeEventListener('resize', this.handleResize);\n }\n\n private showOverlay() {\n if (!this.overlayElement) {\n this.overlayElement = document.createElement('div');\n this.overlayElement.className = 'dropdown-overlay';\n this.overlayElement.style.position = 'fixed';\n this.overlayElement.style.top = '0';\n this.overlayElement.style.left = '0';\n this.overlayElement.style.width = '100%';\n this.overlayElement.style.height = '100%';\n this.overlayElement.style.zIndex = '9999';\n this.overlayElement.style.backgroundColor = 'white';\n document.body.appendChild(this.overlayElement);\n }\n }\n\n private removeOverlay() {\n if (this.overlayElement && this.overlayElement.parentNode === document.body) {\n document.body.removeChild(this.overlayElement);\n this.overlayElement = null;\n }\n }\n\n private handleSlotChange = () => {\n this.options = Array.from(this.host.querySelectorAll('cura-dropdown-search-option'));\n this.addClickListenersToOptions();\n this.updateHoveredIndex();\n };\n\n private addClickListenersToOptions() {\n this.options.forEach((option, index) => {\n option.addEventListener('optionSelected', () => this.onSelectedOption(index));\n });\n }\n\n private updateSelectedOption(value: string) {\n const selectedOptionIndex = this.options.findIndex(option => option.getAttribute('value') === value);\n this.hoveredIndex = selectedOptionIndex;\n this.updateOptionAttribute('hovered', this.hoveredIndex);\n this.updateOptionAttribute('selected', this.hoveredIndex);\n\n this.scrollIntoView();\n }\n\n private handleInputChange = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.value = input.value;\n this.onValueChange(this.value);\n // this.valueChanged.emit(this.value);\n };\n\n private onSelectedOption(index: number) {\n const selectedOption = this.options[index];\n if (selectedOption.selectable) {\n const selectedValue = selectedOption.getAttribute('value') || selectedOption.textContent;\n\n this.value = selectedValue || '';\n this.updateSelectedOption(this.value);\n\n this.isDropdownOpen = false;\n this.isOnBlurInput = true;\n this.removeOverlay();\n }\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n this.moveHighlight(1);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n this.moveHighlight(-1);\n } else if (event.key === 'Enter') {\n event.preventDefault();\n if (this.hoveredIndex > -1) {\n this.handleOnBlur();\n this.onSelectedOption(this.hoveredIndex);\n }\n }\n };\n\n private moveHighlight(direction: number) {\n const visibleOptions = this.options;\n const newIndex = (this.hoveredIndex + direction + visibleOptions.length) % visibleOptions.length;\n this.hoveredIndex = newIndex;\n this.updateOptionAttribute('hovered', this.hoveredIndex);\n this.scrollIntoView();\n }\n\n private updateOptionAttribute(attribute: string, indexToUpdate: number) {\n this.options.forEach((option, index) => {\n (option as any)[attribute] = index === indexToUpdate;\n });\n }\n\n private updateHoveredIndex() {\n const visibleOptions = this.options;\n const currentValue = this.value;\n this.hoveredIndex = visibleOptions.findIndex(option => option.getAttribute('value') === currentValue);\n }\n\n private scrollIntoView() {\n const container = this.host.shadowRoot?.querySelector('.dropdown-search-list');\n const hoveredOption = this.options[this.hoveredIndex];\n\n if (container && hoveredOption) {\n const optionRect = hoveredOption.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n\n if (optionRect.bottom > containerRect.bottom) {\n container.scrollTop += optionRect.bottom - containerRect.bottom;\n }\n\n if (optionRect.top < containerRect.top) {\n container.scrollTop -= containerRect.top - optionRect.top;\n }\n }\n }\n\n private handleResize = () => {\n this.isMobile = window.innerWidth < 768;\n if (this.isDropdownOpen) {\n if (this.isMobile) {\n this.showOverlay();\n } else {\n this.removeOverlay();\n }\n }\n };\n\n handleOnBlur() {\n if (this.isOnBlurInput === true) {\n setTimeout(() => {\n this.isDropdownOpen = false;\n this.removeOverlay();\n }, 200);\n }\n }\n getClasses() {\n return {\n 'dropdown-input-search': true,\n 'dropdown-open': this.isDropdownOpen,\n 'disabled': this.disabled,\n [this.status]: true,\n };\n }\n\n getDropdownClasses() {\n return {\n 'dropdown-search-list': true,\n 'visible': this.options.length && this.isDropdownOpen ? true : false,\n };\n }\n\n hostCSSProperties() {\n return {\n '--dropdown-max-height': this.dropdownMaxHeight,\n };\n }\n\n render() {\n const isMobileDropdown = this.isMobile && this.isDropdownOpen;\n return (\n <Host style={this.hostCSSProperties()} class=\"dropdown-overlay\">\n <div class={`dropdown ${isMobileDropdown ? 'dropdown-mobile' : ''}`} style={this.styles}>\n <div class={this.getClasses()}>\n {this.isMobile && this.isDropdownOpen && (\n <cura-button-transparent\n fontColor=\"dark\"\n onClick={() => (this.isMobile = false)}\n iconName=\"arrowLeft\"\n size=\"medium\"\n iconOnly\n color=\"primary\"\n ></cura-button-transparent>\n )}\n <cura-input-text\n disabled={this.disabled}\n label={this.label}\n part=\"cura-input-field\"\n mode={isMobileDropdown ? 'transparent' : 'default'}\n required={this.required}\n hideErrorIcon={this.status === 'error'}\n iconName={this.iconName || 'search'}\n value={this.value}\n status={this.status}\n onValueChange={e => this.onValueChange(e.target.value as string)}\n onInput={e => this.handleInputChange(e)}\n onFocus={() => (this.isDropdownOpen = true)}\n onClick={() => (window.innerWidth < 768 ? (this.isMobile = true) : null)}\n onBlur={() => {\n this.handleOnBlur();\n }}\n placeholder={this.placeholder}\n size={this.size}\n onKeyDown={this.handleKeyDown}\n >\n <slot name=\"helperText\"></slot>\n </cura-input-text>\n </div>\n <div id=\"dropdown-search-list\" class={this.getDropdownClasses()}>\n <slot name=\"dropdown-search-option\" onSlotchange={this.handleSlotChange}></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.stories.js
CHANGED
|
@@ -3,6 +3,7 @@ const storybookUrl = `${window.location.origin}`;
|
|
|
3
3
|
const renderCuraDropdownSearch = (args) => {
|
|
4
4
|
return `<cura-dropdown-search
|
|
5
5
|
style="height: 400px;"
|
|
6
|
+
size="${args.size}"
|
|
6
7
|
status="${args.status}"
|
|
7
8
|
name="${args.name}"
|
|
8
9
|
icon-name="${args.iconName}"
|
|
@@ -10,8 +11,10 @@ const renderCuraDropdownSearch = (args) => {
|
|
|
10
11
|
selected="${args.selected}"
|
|
11
12
|
value="${args.value}"
|
|
12
13
|
placeholder="${args.placeholder}"
|
|
13
|
-
label="${args.label}"${args.dropdownMaxHeight && args.dropdownMaxHeight !== '630px'
|
|
14
|
-
|
|
14
|
+
label="${args.label}"${args.dropdownMaxHeight && args.dropdownMaxHeight !== '630px'
|
|
15
|
+
? `
|
|
16
|
+
dropdown-max-height="${args.dropdownMaxHeight}"`
|
|
17
|
+
: ''}>
|
|
15
18
|
${args.helperText ? `<span slot="helperText">${args.helperText}</span>` : ''}
|
|
16
19
|
<cura-dropdown-search-option-title>Mais Buscados</cura-dropdown-search-option-title>
|
|
17
20
|
${args.options
|
|
@@ -67,14 +70,23 @@ export default {
|
|
|
67
70
|
category: 'Properties',
|
|
68
71
|
},
|
|
69
72
|
},
|
|
73
|
+
size: {
|
|
74
|
+
control: { type: 'inline-radio' },
|
|
75
|
+
options: ['small', 'medium', 'large'],
|
|
76
|
+
description: "Tamanho do componente. Pode ser 'small', 'medium' ou 'large'.",
|
|
77
|
+
table: {
|
|
78
|
+
category: 'Properties',
|
|
79
|
+
defaultValue: { summary: 'large' },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
70
82
|
iconName: {
|
|
71
83
|
control: { type: 'select' },
|
|
72
84
|
options: ['', ...iconNames],
|
|
73
85
|
description: 'Nome do ícone no iconset a ser utilizado.',
|
|
74
86
|
table: {
|
|
75
|
-
category: 'Icons'
|
|
87
|
+
category: 'Icons',
|
|
76
88
|
},
|
|
77
|
-
name: 'icon-name'
|
|
89
|
+
name: 'icon-name',
|
|
78
90
|
},
|
|
79
91
|
required: {
|
|
80
92
|
control: 'boolean',
|
|
@@ -114,7 +126,7 @@ export default {
|
|
|
114
126
|
category: 'Properties',
|
|
115
127
|
defaultValue: { summary: '630px' },
|
|
116
128
|
},
|
|
117
|
-
name: 'dropdown-max-height'
|
|
129
|
+
name: 'dropdown-max-height',
|
|
118
130
|
},
|
|
119
131
|
helperText: {
|
|
120
132
|
control: 'text',
|
|
@@ -142,6 +154,7 @@ export default {
|
|
|
142
154
|
};
|
|
143
155
|
export const DropdownSearch = {
|
|
144
156
|
args: {
|
|
157
|
+
size: 'large',
|
|
145
158
|
status: 'default',
|
|
146
159
|
name: 'cura-dropdown',
|
|
147
160
|
iconName: '',
|
|
@@ -164,7 +177,7 @@ export const DropdownSearch = {
|
|
|
164
177
|
content: `Not Selectable Dora Martins de Souza
|
|
165
178
|
<cura-paragraph color="neutral-dark" margin-block="0" size="xsmall">Ortopedista Cirúrgico</cura-paragraph>`,
|
|
166
179
|
action: '',
|
|
167
|
-
selectable: false
|
|
180
|
+
selectable: false,
|
|
168
181
|
},
|
|
169
182
|
{
|
|
170
183
|
value: 'Copa D’Or - Centro Cardiológico',
|
package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.stories.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cura-dropdown-search.stories.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-dropdown-search/cura-dropdown-search.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,4CAA4C,CAAC;AAEnE,MAAM,YAAY,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;AACjD,MAAM,wBAAwB,GAAG,CAAC,IAAS,EAAE,EAAE;IAC7C,OAAO;;cAEK,IAAI,CAAC,MAAM;YACb,IAAI,C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A;gBACT,MAAM,EAAE,EAAE;aACX;SACF;KACF;CACF,CAAC","sourcesContent":["import iconNames from '../../../assets/icons/iconset-default-list';\n\nconst storybookUrl = `${window.location.origin}`;\nconst renderCuraDropdownSearch = (args: any) => {\n return `<cura-dropdown-search\n style=\"height: 400px;\"\n status=\"${args.status}\"\n name=\"${args.name}\"\n icon-name=\"${args.iconName}\"\n required=\"${args.required}\"\n selected=\"${args.selected}\"\n value=\"${args.value}\"\n placeholder=\"${args.placeholder}\"\n label=\"${args.label}\"${args.dropdownMaxHeight && args.dropdownMaxHeight !== '630px' ? `\n dropdown-max-height=\"${args.dropdownMaxHeight}\"` : ''}>\n ${args.helperText ? `<span slot=\"helperText\">${args.helperText}</span>` : ''}\n <cura-dropdown-search-option-title>Mais Buscados</cura-dropdown-search-option-title>\n ${args.options\n .map(\n option => `<cura-dropdown-search-option value=\"${option.value}\"${option.selectable === false ? ` selectable=\"false\"` : ''}>\n ${option.image ? ` <div slot=\"image\">${option.image}</div>` : ''}\n ${option.content}\n ${\n option.action\n ? ` <div slot=\"action\">\n ${option.action}\n </div>`\n : ''\n }\n </cura-dropdown-search-option>\n `,\n )\n .join('')}\n </cura-dropdown-search>`;\n};\n\nexport default {\n title: 'Componentes/DropdownSearch/DropDownSearch',\n tags: ['autodocs'],\n parameters: {\n docs: {\n description: {\n component: `<cura-paragraph size=\"small\">\n\n O \\`cura-dropdown-search\\` é um componente para busca rápida entre opções, com suporte a ícones, avatares, e ações customizáveis. Ele é responsivo e seu layout é ajustado dependendo do tamanho da tela.\n <br/><br/>\n\n Em dispositivos móveis, o componente abre em modo full-screen, facilitando a navegação e seleção de opções. Você pode visualizar esse comportamento abrindo o story dele\n [aqui](${storybookUrl}/?path=/story/componentes-dropdownsearch-dropdownsearch--dropdown-search) e ajustando o tamanho da sua tela.\n\n </cura-paragraph>`,\n },\n },\n },\n render: args => {\n return renderCuraDropdownSearch(args);\n },\n argTypes: {\n status: {\n control: { type: 'inline-radio' },\n options: ['default', 'error'],\n description: 'Status do dropdown.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 'default' },\n },\n },\n name: {\n control: 'text',\n description: 'Nome do dropdown.',\n required: false,\n table: {\n category: 'Properties',\n },\n },\n iconName: {\n control: { type: 'select' },\n options: ['', ...iconNames],\n description: 'Nome do ícone no iconset a ser utilizado.',\n table: {\n category: 'Icons'\n },\n name: 'icon-name'\n },\n required: {\n control: 'boolean',\n description: 'Define se o campo é obrigatório.',\n table: {\n category: 'Properties',\n defaultValue: { summary: false },\n },\n },\n value: {\n control: 'text',\n description: 'Valor atual do campo de busca.',\n table: {\n category: 'Properties',\n },\n },\n placeholder: {\n control: 'text',\n description: 'Texto do placeholder.',\n required: false,\n table: {\n category: 'Properties',\n },\n },\n label: {\n control: 'text',\n description: 'Texto da label do input.',\n required: false,\n table: {\n category: 'Properties',\n },\n },\n dropdownMaxHeight: {\n control: 'text',\n description: 'Altura máxima para o dropdown.',\n table: {\n category: 'Properties',\n defaultValue: { summary: '630px' },\n },\n name: 'dropdown-max-height'\n },\n helperText: {\n control: 'text',\n description: 'Texto de ajuda para o dropdown.',\n table: {\n category: 'Slots',\n },\n },\n oninput: {\n control: 'none',\n description: 'Evento via Listener quando o estado do value do dropdown é alterado',\n table: {\n category: 'Events',\n },\n },\n options: {\n control: { type: 'object' },\n description: 'Um slot name=dropdown-search-option para herdar as opções do dropdown. Pensado para usar o componente `<cura-dropdown-search-option>`',\n table: {\n category: 'Slots',\n defaultValue: { summary: [] },\n },\n },\n },\n};\n\nexport const DropdownSearch = {\n args: {\n status: 'default',\n name: 'cura-dropdown',\n iconName: '',\n required: false,\n value: '',\n placeholder: 'Faça a sua busca',\n label: 'Busca',\n dropdownMaxHeight: '630px',\n helperText: 'Digite o que você deseja buscar.',\n options: [\n {\n value: 'Clinica Médica Geral',\n image: '<cura-icon size=\"24\" name=\"medical\"></cura-icon>',\n content: 'Clinica Médica Geral',\n action: `<cura-button-transparent font-color=\"dark\" color='primary' icon-name='delete' size='small' icon-only={true}></cura-button-transparent>`,\n },\n {\n value: 'Dora Martins de Souza',\n image: '<cura-avatar size=\"32\" imageSrc=\"\"></cura-avatar>',\n content: `Not Selectable Dora Martins de Souza\n <cura-paragraph color=\"neutral-dark\" margin-block=\"0\" size=\"xsmall\">Ortopedista Cirúrgico</cura-paragraph>`,\n action: '',\n selectable: false\n },\n {\n value: 'Copa D’Or - Centro Cardiológico',\n image: `\n <div slot=\"image\">\n <div\n style=\"\n display: flex;\n align-content: center;\n align-items: center;\n justify-content: center;\n text-align: center;\n letter-spacing: 0.72px;\n width: 32px;\n height: 32px;\n border-radius: 4px;\n background-color: #E9E9E9;\n \"\n >\n <cura-label size=\"xsmall\" margin-block=\"0\" lineHeight=\"0\" color=\"neutral-black\" weight=\"bold\">\n 1 <br />\n KM\n </cura-label>\n </div>\n </div>\n `,\n content: `<div style=\"line-height='0';\">\n Copa D’Or - Centro Cardiológico\n <cura-paragraph color=\"neutral-dark\" margin-block=\"0\" size=\"xsmall\">\n Rua Siqueira Campos, 93 Copacabana, Rio de Janeiro\n </cura-paragraph>\n </div>`,\n action: '',\n },\n ],\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"cura-dropdown-search.stories.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-dropdown-search/cura-dropdown-search.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,4CAA4C,CAAC;AAEnE,MAAM,YAAY,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;AACjD,MAAM,wBAAwB,GAAG,CAAC,IAAS,EAAE,EAAE;IAC7C,OAAO;;YAEG,IAAI,CAAC,IAAI;cACP,IAAI,CAAC,MAAM;YACb,IAAI,CAAC,IAAI;iBACJ,IAAI,CAAC,QAAQ;gBACd,IAAI,CAAC,QAAQ;gBACb,IAAI,CAAC,QAAQ;aAChB,IAAI,CAAC,KAAK;mBACJ,IAAI,CAAC,WAAW;aACtB,IAAI,CAAC,KAAK,IACnB,IAAI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;gBACE,KAAK,EAAE,iCAAiC;gBACxC,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;;OAsBR;gBACC,OAAO,EAAE;;;;;iBAKA;gBACT,MAAM,EAAE,EAAE;aACX;SACF;KACF;CACF,CAAC","sourcesContent":["import iconNames from '../../../assets/icons/iconset-default-list';\n\nconst storybookUrl = `${window.location.origin}`;\nconst renderCuraDropdownSearch = (args: any) => {\n return `<cura-dropdown-search\n style=\"height: 400px;\"\n size=\"${args.size}\"\n status=\"${args.status}\"\n name=\"${args.name}\"\n icon-name=\"${args.iconName}\"\n required=\"${args.required}\"\n selected=\"${args.selected}\"\n value=\"${args.value}\"\n placeholder=\"${args.placeholder}\"\n label=\"${args.label}\"${\n args.dropdownMaxHeight && args.dropdownMaxHeight !== '630px'\n ? `\n dropdown-max-height=\"${args.dropdownMaxHeight}\"`\n : ''\n }>\n ${args.helperText ? `<span slot=\"helperText\">${args.helperText}</span>` : ''}\n <cura-dropdown-search-option-title>Mais Buscados</cura-dropdown-search-option-title>\n ${args.options\n .map(\n option => `<cura-dropdown-search-option value=\"${option.value}\"${option.selectable === false ? ` selectable=\"false\"` : ''}>\n ${option.image ? ` <div slot=\"image\">${option.image}</div>` : ''}\n ${option.content}\n ${\n option.action\n ? ` <div slot=\"action\">\n ${option.action}\n </div>`\n : ''\n }\n </cura-dropdown-search-option>\n `,\n )\n .join('')}\n </cura-dropdown-search>`;\n};\n\nexport default {\n title: 'Componentes/DropdownSearch/DropDownSearch',\n tags: ['autodocs'],\n parameters: {\n docs: {\n description: {\n component: `<cura-paragraph size=\"small\">\n\n O \\`cura-dropdown-search\\` é um componente para busca rápida entre opções, com suporte a ícones, avatares, e ações customizáveis. Ele é responsivo e seu layout é ajustado dependendo do tamanho da tela.\n <br/><br/>\n\n Em dispositivos móveis, o componente abre em modo full-screen, facilitando a navegação e seleção de opções. Você pode visualizar esse comportamento abrindo o story dele\n [aqui](${storybookUrl}/?path=/story/componentes-dropdownsearch-dropdownsearch--dropdown-search) e ajustando o tamanho da sua tela.\n\n </cura-paragraph>`,\n },\n },\n },\n render: args => {\n return renderCuraDropdownSearch(args);\n },\n argTypes: {\n status: {\n control: { type: 'inline-radio' },\n options: ['default', 'error'],\n description: 'Status do dropdown.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 'default' },\n },\n },\n name: {\n control: 'text',\n description: 'Nome do dropdown.',\n required: false,\n table: {\n category: 'Properties',\n },\n },\n size: {\n control: { type: 'inline-radio' },\n options: ['small', 'medium', 'large'],\n description: \"Tamanho do componente. Pode ser 'small', 'medium' ou 'large'.\",\n table: {\n category: 'Properties',\n defaultValue: { summary: 'large' },\n },\n },\n iconName: {\n control: { type: 'select' },\n options: ['', ...iconNames],\n description: 'Nome do ícone no iconset a ser utilizado.',\n table: {\n category: 'Icons',\n },\n name: 'icon-name',\n },\n required: {\n control: 'boolean',\n description: 'Define se o campo é obrigatório.',\n table: {\n category: 'Properties',\n defaultValue: { summary: false },\n },\n },\n value: {\n control: 'text',\n description: 'Valor atual do campo de busca.',\n table: {\n category: 'Properties',\n },\n },\n placeholder: {\n control: 'text',\n description: 'Texto do placeholder.',\n required: false,\n table: {\n category: 'Properties',\n },\n },\n label: {\n control: 'text',\n description: 'Texto da label do input.',\n required: false,\n table: {\n category: 'Properties',\n },\n },\n dropdownMaxHeight: {\n control: 'text',\n description: 'Altura máxima para o dropdown.',\n table: {\n category: 'Properties',\n defaultValue: { summary: '630px' },\n },\n name: 'dropdown-max-height',\n },\n helperText: {\n control: 'text',\n description: 'Texto de ajuda para o dropdown.',\n table: {\n category: 'Slots',\n },\n },\n oninput: {\n control: 'none',\n description: 'Evento via Listener quando o estado do value do dropdown é alterado',\n table: {\n category: 'Events',\n },\n },\n options: {\n control: { type: 'object' },\n description: 'Um slot name=dropdown-search-option para herdar as opções do dropdown. Pensado para usar o componente `<cura-dropdown-search-option>`',\n table: {\n category: 'Slots',\n defaultValue: { summary: [] },\n },\n },\n },\n};\n\nexport const DropdownSearch = {\n args: {\n size: 'large',\n status: 'default',\n name: 'cura-dropdown',\n iconName: '',\n required: false,\n value: '',\n placeholder: 'Faça a sua busca',\n label: 'Busca',\n dropdownMaxHeight: '630px',\n helperText: 'Digite o que você deseja buscar.',\n options: [\n {\n value: 'Clinica Médica Geral',\n image: '<cura-icon size=\"24\" name=\"medical\"></cura-icon>',\n content: 'Clinica Médica Geral',\n action: `<cura-button-transparent font-color=\"dark\" color='primary' icon-name='delete' size='small' icon-only={true}></cura-button-transparent>`,\n },\n {\n value: 'Dora Martins de Souza',\n image: '<cura-avatar size=\"32\" imageSrc=\"\"></cura-avatar>',\n content: `Not Selectable Dora Martins de Souza\n <cura-paragraph color=\"neutral-dark\" margin-block=\"0\" size=\"xsmall\">Ortopedista Cirúrgico</cura-paragraph>`,\n action: '',\n selectable: false,\n },\n {\n value: 'Copa D’Or - Centro Cardiológico',\n image: `\n <div slot=\"image\">\n <div\n style=\"\n display: flex;\n align-content: center;\n align-items: center;\n justify-content: center;\n text-align: center;\n letter-spacing: 0.72px;\n width: 32px;\n height: 32px;\n border-radius: 4px;\n background-color: #E9E9E9;\n \"\n >\n <cura-label size=\"xsmall\" margin-block=\"0\" lineHeight=\"0\" color=\"neutral-black\" weight=\"bold\">\n 1 <br />\n KM\n </cura-label>\n </div>\n </div>\n `,\n content: `<div style=\"line-height='0';\">\n Copa D’Or - Centro Cardiológico\n <cura-paragraph color=\"neutral-dark\" margin-block=\"0\" size=\"xsmall\">\n Rua Siqueira Campos, 93 Copacabana, Rio de Janeiro\n </cura-paragraph>\n </div>`,\n action: '',\n },\n ],\n },\n};\n"]}
|
|
@@ -73,6 +73,7 @@ export class CuraSelect {
|
|
|
73
73
|
this.status = 'default';
|
|
74
74
|
this.disabled = false;
|
|
75
75
|
this.required = false;
|
|
76
|
+
this.searchBehavior = false;
|
|
76
77
|
this.isHovered = false;
|
|
77
78
|
this.isFocused = false;
|
|
78
79
|
this.isOpen = false;
|
|
@@ -87,7 +88,7 @@ export class CuraSelect {
|
|
|
87
88
|
* Filters the options based on the current input value.
|
|
88
89
|
*/
|
|
89
90
|
filterOptions(newText) {
|
|
90
|
-
if (!this.isOpen) {
|
|
91
|
+
if (!this.isOpen || !this.searchBehavior) {
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
94
|
this.options.forEach(option => {
|
|
@@ -264,13 +265,13 @@ export class CuraSelect {
|
|
|
264
265
|
return (h("cura-icon", { class: 'feedback-icon', name: icon, iconset: 'default', size: this.size === 'large' ? 20 : 16, color: this.getColor('icon'), style: this.styles }));
|
|
265
266
|
}
|
|
266
267
|
render() {
|
|
267
|
-
return (h(Host, { key: '
|
|
268
|
+
return (h(Host, { key: 'f6447e417389cc714eeee6ace4cf8493c1f8eac6', style: this.styles }, h("div", { key: 'e12e26480be1c5c3065f2934268936075283a162', class: this.getClasses(), onMouseEnter: () => (this.isHovered = true), onMouseLeave: () => (this.isHovered = false), onClick: this.handleClick }, this.label && (h("cura-label", { key: 'bbcf482d764f67371f736d74317059cb6ef9155a', class: 'label', weight: 'bold', size: this.size === 'large' ? 'small' : 'xsmall', color: this.getColor('label') }, this.label, " ", this.required && h("span", { key: 'b38876233f76c11037dfa4f2e0847acfce9c855c', class: 'required' }, "* "))), h("div", { key: '1b56deba7ad5b7d263ffbf9f5e666a882efa30bf', class: {
|
|
268
269
|
'cura-input-field': true,
|
|
269
270
|
'open': this.isOpen
|
|
270
|
-
} }, this.renderIcon(), h("input", { key: '
|
|
271
|
+
} }, this.renderIcon(), h("input", { key: 'dba0c9ed720cdde8679b05df09b8957b15651df2', type: "text", autocomplete: 'off', onFocus: () => (this.isFocused = true), onBlur: () => (this.isFocused = false), onKeyDown: this.handleKeyNavigation, "aria-required": String(this.required), "aria-disabled": String(this.disabled), "aria-invalid": String(this.status === 'error'), onInput: this.handleInputChange, style: this.styles, placeholder: this.placeholder, disabled: this.disabled, required: this.required, value: this.textInput, readonly: this.searchBehavior ? null : true }), h("cura-icon", { key: 'b6a6dda0bfe4a66d80bf3cff1630456495614c17', name: this.isOpen ? 'up' : 'down', class: "up-down-icon", color: this.disabled ? 'neutral-dark' : 'primary-base', size: 16, iconset: 'default' })), h("cura-label", { key: '8bcb1e2903e00926b7f99b44a3f179160a8f10da', class: "helper-text", size: 'xsmall', color: this.getColor('text'), weight: this.mode === 'transparent' ? 'bold' : 'regular' }, h("slot", { key: '65c9ebcedaaad1131ba14962da9240ff8784c4f6' })), this.isOpen && (h("div", { key: 'e25fd607d58aa8ff812c9b41a242867bc0d3ecf7', class: {
|
|
271
272
|
'menu': true,
|
|
272
273
|
'open': this.isOpen
|
|
273
|
-
} }, h("slot", { key: '
|
|
274
|
+
} }, h("slot", { key: '59eed2c893fa1201950611e234a137bf8a5dc7d4', name: 'option' }))))));
|
|
274
275
|
}
|
|
275
276
|
static get is() { return "cura-select"; }
|
|
276
277
|
static get encapsulation() { return "shadow"; }
|
|
@@ -430,6 +431,24 @@ export class CuraSelect {
|
|
|
430
431
|
"attribute": "required",
|
|
431
432
|
"reflect": true,
|
|
432
433
|
"defaultValue": "false"
|
|
434
|
+
},
|
|
435
|
+
"searchBehavior": {
|
|
436
|
+
"type": "boolean",
|
|
437
|
+
"mutable": false,
|
|
438
|
+
"complexType": {
|
|
439
|
+
"original": "boolean",
|
|
440
|
+
"resolved": "boolean",
|
|
441
|
+
"references": {}
|
|
442
|
+
},
|
|
443
|
+
"required": false,
|
|
444
|
+
"optional": false,
|
|
445
|
+
"docs": {
|
|
446
|
+
"tags": [],
|
|
447
|
+
"text": "Enable / Disable search at options by term.\nDefault: false"
|
|
448
|
+
},
|
|
449
|
+
"attribute": "search-behavior",
|
|
450
|
+
"reflect": true,
|
|
451
|
+
"defaultValue": "false"
|
|
433
452
|
}
|
|
434
453
|
};
|
|
435
454
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cura-select.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-select/cura-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,E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;;;;;;;;CACF","sourcesContent":["import { Component, Element, Host, Prop, State, h, Event, EventEmitter, AttachInternals, Watch } from '@stencil/core';\n\n@Component({\n tag: 'cura-select',\n styleUrl: 'cura-select.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CuraSelect {\n /**\n * The label text for the select component.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) label: string = '';\n\n /**\n * Placeholder text for the input field.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) placeholder: string = '';\n\n /**\n * Current value of the select component.\n * Reflects as an attribute in the DOM and is mutable.\n */\n @Prop({ reflect: true, mutable: true }) value: string = '';\n\n /**\n * Display mode of the select component.\n * Can be 'default' or 'transparent'.\n */\n @Prop({ reflect: true }) mode: 'default' | 'transparent' = 'default';\n\n /**\n * Size of the select component.\n * Can be 'small', 'medium', or 'large'.\n */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /**\n * Status of the select component.\n * Can be 'success', 'error', or 'default'.\n */\n @Prop({ reflect: true, mutable: true }) status: 'success' | 'error' | 'default' = 'default';\n\n /**\n * Whether the select component is disabled.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * Whether the select component is required.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) required: boolean = false;\n\n /**\n * Internal state: Whether the input is hovered.\n * Default: false\n */\n @State() isHovered: boolean = false;\n\n /**\n * Internal state: Whether the input is focused.\n * Default: false\n */\n @State() isFocused: boolean = false;\n\n /**\n * Internal state: Whether the dropdown menu is open.\n * Default: false\n */\n @State() isOpen: boolean = false;\n\n /**\n * Internal state: Collection of options for the select component.\n */\n @State() options: NodeListOf<HTMLCuraSelectOptionElement>;\n\n\n @State() activeIndex = -1\n\n @Watch('activeIndex')\n updateOptionHighlights(newActiveINdex: number) {\n this.options.forEach((option, index) => (option as any).active = index === newActiveINdex);\n }\n\n @State() textInput = ''\n\n @Watch('textInput')\n /**\n * Filters the options based on the current input value.\n */\n filterOptions(newText) {\n if (!this.isOpen) {\n return\n }\n \n this.options.forEach(option => {\n const optionValue = option.textContent?.toLowerCase() || '';\n const isVisible = optionValue.includes(newText.toLocaleLowerCase())\n option.style.display = isVisible ? 'block' : 'none';\n });\n }\n\n /**\n * Reference to the host element of the component.\n */\n @Element() host: HTMLElement;\n\n /**\n * Event emitted when an option is selected.\n */\n @Event() selected: EventEmitter;\n\n /**\n * MutationObserver to watch changes in the component.\n */\n mutationObserver: MutationObserver;\n\n /**\n * Styles to be applied to the component.\n */\n styles = {};\n\n /**\n * Theme object containing font and color information.\n */\n theme = window.CuraAPI.theme;\n\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Callback for form association.\n */\n formAssociatedCallback(form: { ariaLabel: string; }) {\n form.ariaLabel = this.label;\n }\n\n /**\n * Callback to restore the switch state from the form.\n */\n formStateRestoreCallback(state: { value: string }) {\n this.textInput = state.value;\n this.updateSelectedOption();\n }\n\n /**\n * Callback to reset the switch state when the form is reset.\n */\n formResetCallback() {\n this.textInput = '';\n this.clearSelectedAttributes()\n this.internals.setFormValue('');\n this.internals.setValidity({});\n }\n\n /**\n * Callback to update the switch's disabled state when the form's disabled state changes.\n */\n formDisabledCallback(disabled: boolean) {\n this.disabled = disabled;\n }\n\n /**\n * Lifecycle method called before the component is rendered.\n * Initializes the options for the select component.\n */\n componentWillLoad() {\n this.initializeOptions();\n }\n /**\n * Lifecycle method called after the component is rendered.\n * Initializes select-related functionality.\n */\n componentDidLoad() {\n this.setupMutationObserver();\n }\n /**\n * Lifecycle method called when the component is connected to the DOM.\n * Applies styles based on the theme.\n */\n connectedCallback() {\n this.applyStyles();\n }\n /**\n * Lifecycle method called when the component is disconnected from the DOM.\n * Disconnects the MutationObserver if it exists.\n */\n disconnectedCallback() {\n this.mutationObserver?.disconnect();\n }\n\n initializeOptions() {\n this.options = this.host.querySelectorAll<HTMLCuraSelectOptionElement>('cura-select-option');\n this.options.forEach(option => {\n option.setAttribute('size', this.size);\n\n const isSelected = this.value === option.value\n option.setAttribute('selected', JSON.stringify(isSelected));\n\n if (isSelected) {\n this.value = option.value\n this.internals.setFormValue(option.value)\n }\n });\n\n this.textInput = Array.from(this.options).find(option => option.value === this.value)?.textContent || this.textInput\n }\n /**\n * Applies styles to the component based on the theme.\n */\n applyStyles() {\n const { fonts, colors } = this.theme;\n const fontWeights = fonts.getWeights();\n\n this.styles = {\n ...this.styles,\n '--font-weight-medium': fontWeights.medium,\n '--font-weight-bold': fontWeights.bold,\n '--font-weight-regular': fontWeights.regular,\n '--font-color': fonts.getColor(),\n '--font-family': fonts.getFamily(),\n '--font-size': fonts.getSize(),\n };\n\n const colorKeys = [\n 'primary-base', 'neutral-purewhite', 'neutral-white', 'neutral-black', 'neutral-medium', 'neutral-light',\n 'neutral-base', 'neutral-dark', 'success-dark', 'success-darker', 'success-lighter',\n 'error-lighter', 'error-dark', 'error-darker', 'error-base', 'info-base'\n ];\n\n colorKeys.forEach(key => {\n this.styles[`--${key}`] = colors.getColor(key);\n });\n }\n /**\n * Sets up a MutationObserver to watch for changes in the component.\n */\n setupMutationObserver() {\n this.mutationObserver = new MutationObserver(this.handleMutations);\n this.mutationObserver.observe(this.host, { attributes: true, subtree: true, attributeFilter: ['selected', 'value'] });\n }\n /**\n * Handles mutations observed by the MutationObserver.\n * Updates the selected option or filters options based on the mutation type.\n */\n handleMutations = (mutations: MutationRecord[]) => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes') {\n if (mutation.attributeName === 'selected') this.updateSelectedOption();\n }\n });\n };\n /**\n * Handles the selection of an option.\n */\n onOptiselected = (event: Event) => {\n const selectedOption = event.target as HTMLElement;\n this.clearSelectedAttributes();\n selectedOption.setAttribute('selected', 'true');\n };\n\n @Watch('value') \n handleValueChange(newValue: string) {\n this.clearSelectedAttributes(); \n\n const selectedOption = this.host.querySelector(`cura-select-option[value=\"${newValue}\"]`); \n\n if(!selectedOption) {\n return\n }\n\n selectedOption.setAttribute('selected', 'true');\n }\n\n updateSelectedOption() {\n const selectedOptionElement = this.host.querySelector<HTMLCuraSelectOptionElement>('cura-select-option[selected]');\n\n if (!selectedOptionElement) {\n return\n }\n\n this.value = selectedOptionElement.value\n this.internals.setFormValue(this.value)\n\n if (this.textInput !== selectedOptionElement.textContent) {\n this.textInput = selectedOptionElement.textContent ;\n this.isOpen = false;\n this.selected.emit(selectedOptionElement.value);\n }\n }\n\n /**\n * Clears the 'selected' attribute from all options.\n */\n clearSelectedAttributes() {\n this.options.forEach(option => option.removeAttribute('selected'));\n }\n\n handleKeyNavigation = (event: KeyboardEvent) => {\n const { code: keyCode } = event\n \n if (!this.isOpen && keyCode === 'ArrowDown') {\n this.isOpen = true\n this.activeIndex = 0\n\n return\n }\n\n if (keyCode === 'ArrowDown') {\n event.preventDefault();\n this.updateActiveIndex(1);\n }\n\n if (keyCode === 'ArrowUp') {\n event.preventDefault();\n this.updateActiveIndex(-1);\n }\n\n if (keyCode === 'Enter' || keyCode === 'Space') {\n this.options[this.activeIndex]?.click();\n }\n\n if (keyCode === 'Escape') {\n this.isOpen = false\n }\n }\n\n updateActiveIndex(direction: number) {\n if (this.options.length === 0) return;\n this.activeIndex = (this.activeIndex + direction + this.options.length) % this.options.length;\n }\n\n handleInputChange = (e: Event) => {\n this.textInput = (e.target as HTMLInputElement).value;\n this.isOpen = this.textInput.length > 0;\n this.internals.setFormValue(this.textInput);\n };\n\n\n getClasses() {\n return {\n wrapper: true,\n label: !!this.label,\n disabled: this.disabled,\n transparent: this.mode === 'transparent',\n [this.size.toLowerCase()]: true,\n [this.status.toLowerCase()]: true,\n };\n }\n\n /**\n * Determines the color based on the item type and component state.\n */\n getColor(item: 'label' | 'text' | 'icon') {\n if (this.disabled) return 'neutral-medium';\n\n const isStatusDefault = this.status === 'default';\n const isHoveredOrFocused = this.isFocused || this.isHovered;\n\n if (item === 'label') {\n if (!isStatusDefault || isHoveredOrFocused) return 'neutral-black';\n return 'neutral-dark';\n }\n\n if (isHoveredOrFocused && isStatusDefault) return 'neutral-black';\n if (this.status === 'success') return 'success-dark';\n if (this.status === 'error') return 'error-dark';\n\n return 'neutral-dark';\n }\n\n /**\n * Renders the icon based on the component's status.\n */\n renderIcon() {\n if (this.status === 'default') return null;\n const icon = { success: 'checkCircle', error: 'alertCircle' }[this.status];\n return (\n <cura-icon\n class='feedback-icon'\n name={icon}\n iconset='default'\n size={this.size === 'large' ? 20 : 16}\n color={this.getColor('icon')}\n style={this.styles}\n />\n );\n }\n\n handleClick = (event: MouseEvent) => {\n if (this.disabled) return event.preventDefault();\n const target = event.target as HTMLElement;\n\n if (target.tagName === 'CURA-SELECT-OPTION') return this.onOptiselected(event);\n this.isOpen = !this.isOpen;\n };\n\n\n render() {\n return (\n <Host style={this.styles}>\n <div\n class={this.getClasses()}\n onMouseEnter={() => (this.isHovered = true)}\n onMouseLeave={() => (this.isHovered = false)}\n onClick={this.handleClick}\n >\n {this.label && (\n <cura-label\n class='label'\n weight='bold'\n size={this.size === 'large' ? 'small' : 'xsmall'}\n color={this.getColor('label')}\n >\n {this.label} {this.required && <span class='required'>* </span>}\n </cura-label>\n )}\n\n <div class={{\n 'cura-input-field': true,\n 'open': this.isOpen\n }}>\n {this.renderIcon()}\n <input\n type=\"text\"\n autocomplete='off'\n onFocus={() => (this.isFocused = true)}\n onBlur={() => (this.isFocused = false)}\n onKeyDown={this.handleKeyNavigation}\n aria-required={String(this.required)}\n aria-disabled={String(this.disabled)}\n aria-invalid={String(this.status === 'error')}\n onInput={this.handleInputChange}\n style={this.styles}\n placeholder={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n value={this.textInput}\n />\n <cura-icon\n name={this.isOpen ? 'up' : 'down'}\n class=\"up-down-icon\"\n color={this.disabled ? 'neutral-dark' : 'primary-base'}\n size={16}\n iconset='default'\n />\n </div>\n <cura-label\n class=\"helper-text\"\n size='xsmall'\n color={this.getColor('text')}\n weight={this.mode === 'transparent' ? 'bold' : 'regular'} >\n <slot></slot>\n </cura-label>\n {this.isOpen && (\n <div class={{\n 'menu': true,\n 'open': this.isOpen\n }}>\n <slot name='option'></slot>\n </div>\n )}\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cura-select.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-select/cura-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAgB,eAAe,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAQtH,MAAM,OAAO,UAAU;;QAuHrB;;WAEG;QACH,WAAM,GAAG,EAAE,CAAC;QAEZ;;WAEG;QACH,UAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAmH7B;;;WAGG;QACH,oBAAe,GAAG,CAAC,SAA2B,EAAE,EAAE;YAChD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAC3B,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBACnC,IAAI,QAAQ,CAAC,aAAa,KAAK,UAAU;wBAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBACzE,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QACF;;WAEG;QACH,mBAAc,GAAG,CAAC,KAAY,EAAE,EAAE;YAChC,MAAM,cAAc,GAAG,KAAK,CAAC,MAAqB,CAAC;YACnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC/B,cAAc,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClD,CAAC,CAAC;QAuCF,wBAAmB,GAAG,CAAC,KAAoB,EAAE,EAAE;;YAC7C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;YAE/B,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;gBAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CA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MAAM,EAAE,IAAI;wBACZ,MAAM,EAAE,IAAI,CAAC,MAAM;qBACpB;oBACC,6DAAM,IAAI,EAAC,QAAQ,GAAQ,CACvB,CACP,CACG,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Host, Prop, State, h, Event, EventEmitter, AttachInternals, Watch } from '@stencil/core';\n\n@Component({\n tag: 'cura-select',\n styleUrl: 'cura-select.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CuraSelect {\n /**\n * The label text for the select component.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) label: string = '';\n\n /**\n * Placeholder text for the input field.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) placeholder: string = '';\n\n /**\n * Current value of the select component.\n * Reflects as an attribute in the DOM and is mutable.\n */\n @Prop({ reflect: true, mutable: true }) value: string = '';\n\n /**\n * Display mode of the select component.\n * Can be 'default' or 'transparent'.\n */\n @Prop({ reflect: true }) mode: 'default' | 'transparent' = 'default';\n\n /**\n * Size of the select component.\n * Can be 'small', 'medium', or 'large'.\n */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /**\n * Status of the select component.\n * Can be 'success', 'error', or 'default'.\n */\n @Prop({ reflect: true, mutable: true }) status: 'success' | 'error' | 'default' = 'default';\n\n /**\n * Whether the select component is disabled.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * Whether the select component is required.\n * Reflects as an attribute in the DOM.\n */\n @Prop({ reflect: true }) required: boolean = false;\n\n /**\n * Enable / Disable search at options by term.\n * Default: false\n */\n @Prop({ reflect: true}) searchBehavior: boolean = false;\n\n /**\n * Internal state: Whether the input is hovered.\n * Default: false\n */\n @State() isHovered: boolean = false;\n\n /**\n * Internal state: Whether the input is focused.\n * Default: false\n */\n @State() isFocused: boolean = false;\n\n /**\n * Internal state: Whether the dropdown menu is open.\n * Default: false\n */\n @State() isOpen: boolean = false;\n\n /**\n * Internal state: Collection of options for the select component.\n */\n @State() options: NodeListOf<HTMLCuraSelectOptionElement>;\n\n\n @State() activeIndex = -1\n\n @Watch('activeIndex')\n updateOptionHighlights(newActiveINdex: number) {\n this.options.forEach((option, index) => (option as any).active = index === newActiveINdex);\n }\n\n @State() textInput = ''\n\n @Watch('textInput')\n /**\n * Filters the options based on the current input value.\n */\n filterOptions(newText) {\n if (!this.isOpen || !this.searchBehavior) {\n return\n }\n\n this.options.forEach(option => {\n const optionValue = option.textContent?.toLowerCase() || '';\n const isVisible = optionValue.includes(newText.toLocaleLowerCase())\n option.style.display = isVisible ? 'block' : 'none';\n });\n }\n\n /**\n * Reference to the host element of the component.\n */\n @Element() host: HTMLElement;\n\n /**\n * Event emitted when an option is selected.\n */\n @Event() selected: EventEmitter;\n\n /**\n * MutationObserver to watch changes in the component.\n */\n mutationObserver: MutationObserver;\n\n /**\n * Styles to be applied to the component.\n */\n styles = {};\n\n /**\n * Theme object containing font and color information.\n */\n theme = window.CuraAPI.theme;\n\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Callback for form association.\n */\n formAssociatedCallback(form: { ariaLabel: string; }) {\n form.ariaLabel = this.label;\n }\n\n /**\n * Callback to restore the switch state from the form.\n */\n formStateRestoreCallback(state: { value: string }) {\n this.textInput = state.value;\n this.updateSelectedOption();\n }\n\n /**\n * Callback to reset the switch state when the form is reset.\n */\n formResetCallback() {\n this.textInput = '';\n this.clearSelectedAttributes()\n this.internals.setFormValue('');\n this.internals.setValidity({});\n }\n\n /**\n * Callback to update the switch's disabled state when the form's disabled state changes.\n */\n formDisabledCallback(disabled: boolean) {\n this.disabled = disabled;\n }\n\n /**\n * Lifecycle method called before the component is rendered.\n * Initializes the options for the select component.\n */\n componentWillLoad() {\n this.initializeOptions();\n }\n /**\n * Lifecycle method called after the component is rendered.\n * Initializes select-related functionality.\n */\n componentDidLoad() {\n this.setupMutationObserver();\n }\n /**\n * Lifecycle method called when the component is connected to the DOM.\n * Applies styles based on the theme.\n */\n connectedCallback() {\n this.applyStyles();\n }\n /**\n * Lifecycle method called when the component is disconnected from the DOM.\n * Disconnects the MutationObserver if it exists.\n */\n disconnectedCallback() {\n this.mutationObserver?.disconnect();\n }\n\n initializeOptions() {\n this.options = this.host.querySelectorAll<HTMLCuraSelectOptionElement>('cura-select-option');\n this.options.forEach(option => {\n option.setAttribute('size', this.size);\n\n const isSelected = this.value === option.value\n option.setAttribute('selected', JSON.stringify(isSelected));\n\n if (isSelected) {\n this.value = option.value\n this.internals.setFormValue(option.value)\n }\n });\n\n this.textInput = Array.from(this.options).find(option => option.value === this.value)?.textContent || this.textInput\n }\n /**\n * Applies styles to the component based on the theme.\n */\n applyStyles() {\n const { fonts, colors } = this.theme;\n const fontWeights = fonts.getWeights();\n\n this.styles = {\n ...this.styles,\n '--font-weight-medium': fontWeights.medium,\n '--font-weight-bold': fontWeights.bold,\n '--font-weight-regular': fontWeights.regular,\n '--font-color': fonts.getColor(),\n '--font-family': fonts.getFamily(),\n '--font-size': fonts.getSize(),\n };\n\n const colorKeys = [\n 'primary-base', 'neutral-purewhite', 'neutral-white', 'neutral-black', 'neutral-medium', 'neutral-light',\n 'neutral-base', 'neutral-dark', 'success-dark', 'success-darker', 'success-lighter',\n 'error-lighter', 'error-dark', 'error-darker', 'error-base', 'info-base'\n ];\n\n colorKeys.forEach(key => {\n this.styles[`--${key}`] = colors.getColor(key);\n });\n }\n /**\n * Sets up a MutationObserver to watch for changes in the component.\n */\n setupMutationObserver() {\n this.mutationObserver = new MutationObserver(this.handleMutations);\n this.mutationObserver.observe(this.host, { attributes: true, subtree: true, attributeFilter: ['selected', 'value'] });\n }\n /**\n * Handles mutations observed by the MutationObserver.\n * Updates the selected option or filters options based on the mutation type.\n */\n handleMutations = (mutations: MutationRecord[]) => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes') {\n if (mutation.attributeName === 'selected') this.updateSelectedOption();\n }\n });\n };\n /**\n * Handles the selection of an option.\n */\n onOptiselected = (event: Event) => {\n const selectedOption = event.target as HTMLElement;\n this.clearSelectedAttributes();\n selectedOption.setAttribute('selected', 'true');\n };\n\n @Watch('value')\n handleValueChange(newValue: string) {\n this.clearSelectedAttributes();\n\n const selectedOption = this.host.querySelector(`cura-select-option[value=\"${newValue}\"]`);\n\n if(!selectedOption) {\n return\n }\n\n selectedOption.setAttribute('selected', 'true');\n }\n\n updateSelectedOption() {\n const selectedOptionElement = this.host.querySelector<HTMLCuraSelectOptionElement>('cura-select-option[selected]');\n\n if (!selectedOptionElement) {\n return\n }\n\n this.value = selectedOptionElement.value\n this.internals.setFormValue(this.value)\n\n if (this.textInput !== selectedOptionElement.textContent) {\n this.textInput = selectedOptionElement.textContent ;\n this.isOpen = false;\n this.selected.emit(selectedOptionElement.value);\n }\n }\n\n /**\n * Clears the 'selected' attribute from all options.\n */\n clearSelectedAttributes() {\n this.options.forEach(option => option.removeAttribute('selected'));\n }\n\n handleKeyNavigation = (event: KeyboardEvent) => {\n const { code: keyCode } = event\n\n if (!this.isOpen && keyCode === 'ArrowDown') {\n this.isOpen = true\n this.activeIndex = 0\n\n return\n }\n\n if (keyCode === 'ArrowDown') {\n event.preventDefault();\n this.updateActiveIndex(1);\n }\n\n if (keyCode === 'ArrowUp') {\n event.preventDefault();\n this.updateActiveIndex(-1);\n }\n\n if (keyCode === 'Enter' || keyCode === 'Space') {\n this.options[this.activeIndex]?.click();\n }\n\n if (keyCode === 'Escape') {\n this.isOpen = false\n }\n }\n\n updateActiveIndex(direction: number) {\n if (this.options.length === 0) return;\n this.activeIndex = (this.activeIndex + direction + this.options.length) % this.options.length;\n }\n\n handleInputChange = (e: Event) => {\n this.textInput = (e.target as HTMLInputElement).value;\n this.isOpen = this.textInput.length > 0;\n this.internals.setFormValue(this.textInput);\n };\n\n\n getClasses() {\n return {\n wrapper: true,\n label: !!this.label,\n disabled: this.disabled,\n transparent: this.mode === 'transparent',\n [this.size.toLowerCase()]: true,\n [this.status.toLowerCase()]: true,\n };\n }\n\n /**\n * Determines the color based on the item type and component state.\n */\n getColor(item: 'label' | 'text' | 'icon') {\n if (this.disabled) return 'neutral-medium';\n\n const isStatusDefault = this.status === 'default';\n const isHoveredOrFocused = this.isFocused || this.isHovered;\n\n if (item === 'label') {\n if (!isStatusDefault || isHoveredOrFocused) return 'neutral-black';\n return 'neutral-dark';\n }\n\n if (isHoveredOrFocused && isStatusDefault) return 'neutral-black';\n if (this.status === 'success') return 'success-dark';\n if (this.status === 'error') return 'error-dark';\n\n return 'neutral-dark';\n }\n\n /**\n * Renders the icon based on the component's status.\n */\n renderIcon() {\n if (this.status === 'default') return null;\n const icon = { success: 'checkCircle', error: 'alertCircle' }[this.status];\n return (\n <cura-icon\n class='feedback-icon'\n name={icon}\n iconset='default'\n size={this.size === 'large' ? 20 : 16}\n color={this.getColor('icon')}\n style={this.styles}\n />\n );\n }\n\n handleClick = (event: MouseEvent) => {\n if (this.disabled) return event.preventDefault();\n const target = event.target as HTMLElement;\n\n if (target.tagName === 'CURA-SELECT-OPTION') return this.onOptiselected(event);\n this.isOpen = !this.isOpen;\n };\n\n\n render() {\n return (\n <Host style={this.styles}>\n <div\n class={this.getClasses()}\n onMouseEnter={() => (this.isHovered = true)}\n onMouseLeave={() => (this.isHovered = false)}\n onClick={this.handleClick}\n >\n {this.label && (\n <cura-label\n class='label'\n weight='bold'\n size={this.size === 'large' ? 'small' : 'xsmall'}\n color={this.getColor('label')}\n >\n {this.label} {this.required && <span class='required'>* </span>}\n </cura-label>\n )}\n\n <div class={{\n 'cura-input-field': true,\n 'open': this.isOpen\n }}>\n {this.renderIcon()}\n <input\n type=\"text\"\n autocomplete='off'\n onFocus={() => (this.isFocused = true)}\n onBlur={() => (this.isFocused = false)}\n onKeyDown={this.handleKeyNavigation}\n aria-required={String(this.required)}\n aria-disabled={String(this.disabled)}\n aria-invalid={String(this.status === 'error')}\n onInput={this.handleInputChange}\n style={this.styles}\n placeholder={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n value={this.textInput}\n readonly={this.searchBehavior ? null : true}\n />\n <cura-icon\n name={this.isOpen ? 'up' : 'down'}\n class=\"up-down-icon\"\n color={this.disabled ? 'neutral-dark' : 'primary-base'}\n size={16}\n iconset='default'\n />\n </div>\n <cura-label\n class=\"helper-text\"\n size='xsmall'\n color={this.getColor('text')}\n weight={this.mode === 'transparent' ? 'bold' : 'regular'} >\n <slot></slot>\n </cura-label>\n {this.isOpen && (\n <div class={{\n 'menu': true,\n 'open': this.isOpen\n }}>\n <slot name='option'></slot>\n </div>\n )}\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -9,7 +9,8 @@ const renderCuraSelect = (args) => {
|
|
|
9
9
|
size="${args.size}"` : ''}${args.status ? `
|
|
10
10
|
status="${args.status}"` : ''}${args.disabled ? `
|
|
11
11
|
disabled` : ''}${args.required ? `
|
|
12
|
-
required` : ''}
|
|
12
|
+
required` : ''}${args.searchBehavior ? `
|
|
13
|
+
search-behavior="${args.searchBehavior}"` : ''}>
|
|
13
14
|
${args.helperText}
|
|
14
15
|
${optionsMarkup}
|
|
15
16
|
</cura-select>`;
|
|
@@ -96,6 +97,14 @@ export default {
|
|
|
96
97
|
defaultValue: { summary: 'false' },
|
|
97
98
|
},
|
|
98
99
|
},
|
|
100
|
+
searchBehavior: {
|
|
101
|
+
control: 'boolean',
|
|
102
|
+
description: 'Habilita o modo de digitação e busca nas opções a partir do termo.',
|
|
103
|
+
table: {
|
|
104
|
+
category: 'states',
|
|
105
|
+
defaultValue: { summary: 'false' },
|
|
106
|
+
}
|
|
107
|
+
},
|
|
99
108
|
helperText: {
|
|
100
109
|
name: 'content',
|
|
101
110
|
control: 'text',
|
|
@@ -138,6 +147,7 @@ export const CuraSelect = {
|
|
|
138
147
|
status: 'default',
|
|
139
148
|
disabled: false,
|
|
140
149
|
required: false,
|
|
150
|
+
searchBehavior: false,
|
|
141
151
|
helperText: 'Texto de ajuda'
|
|
142
152
|
},
|
|
143
153
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cura-select.stories.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-select/cura-select.stories.tsx"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,EAAE;IAChC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAC9C,8BAA8B,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,uBAAuB,CACnF,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEX,MAAM,KAAK,GAAG,eAAe,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;WACjC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;iBAClC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;mBAC7C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;WACjD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;UAClC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;UAChC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAChC,IAAI,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AE,OAAO,EAAE;aACnC;SACF;QACD,UAAU,EAAE;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,2GAA2G;YACxH,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;gBACjB,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAC9B;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,mGAAmG;YAChH,KAAK,EAAE;gBACL,QAAQ,EAAE,QAAQ;gBAClB,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAC9B;SACF;QACD,OAAO,EAAE;YACP,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,kEAAkE;YAC/E,KAAK,EAAE;gBACL,QAAQ,EAAE,YAAY;gBACtB,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;aAChC;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE;YAChC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;YAClC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;SACnC;QACD,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,cAAc;QAC3B,YAAY,EAAE,EAAE;QAChB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,KAAK;QACf,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,gBAAgB;KAC7B;CACF,CAAC","sourcesContent":["const renderCuraSelect = (args) => {\n const optionsMarkup = args.options.map(option =>\n `<cura-select-option value=\"${option.value}\">${option.label}</cura-select-option>`\n ).join('');\n\n const block = `<cura-select${args.label ? `\n label=\"${args.label}\"` : ''}${args.placeholder ? `\n placeholder=\"${args.placeholder}\"` : ''}${args.defaultValue ? `\n default-value=\"${args.defaultValue}\"` : ''}${args.value ? `\n value=\"${args.value}\"` : ''}${args.mode ? `\n mode=\"${args.mode}\"` : ''}${args.size ? `\n size=\"${args.size}\"` : ''}${args.status ? `\n status=\"${args.status}\"` : ''}${args.disabled ? `\n disabled` : ''}${args.required ? `\n required` : ''}${args.searchBehavior ? `\n search-behavior=\"${args.searchBehavior}\"` : ''}>\n ${args.helperText}\n ${optionsMarkup}\n</cura-select>`;\n\n return `<div style=\"height: 200px; padding: 20px;\">${block}</div>`;\n};\n\n\n\nexport default {\n title: 'Componentes/Forms/Select',\n component: 'cura-select',\n tags: ['autodocs'],\n render: (args) => renderCuraSelect(args),\n argTypes: {\n label: {\n control: 'text',\n description: 'Texto do rótulo para o componente select.',\n table: {\n category: 'Propriedades',\n defaultValue: { summary: '' },\n },\n },\n placeholder: {\n control: 'text',\n description: 'Texto de espaço reservado para o campo de entrada.',\n table: {\n category: 'Propriedades',\n defaultValue: { summary: '' },\n },\n },\n defaultValue: {\n control: 'text',\n description: 'Valor padrão para o componente select.',\n table: {\n category: 'Propriedades',\n defaultValue: { summary: '' },\n },\n },\n value: {\n control: 'text',\n description: 'Valor atual do componente select. Ao inicar a busca o mesmo se refere ao option relacionado',\n table: {\n category: 'Propriedades',\n defaultValue: { summary: '' },\n },\n },\n mode: {\n control: { type: 'inline-radio' },\n options: ['default', 'transparent'],\n description: \"Modo de exibição do componente select. Pode ser 'default' ou 'transparent'.\",\n table: {\n category: 'Propriedades',\n defaultValue: { summary: 'default' },\n },\n },\n size: {\n control: { type: 'inline-radio' },\n options: ['small', 'medium', 'large'],\n description: \"Tamanho do componente select. Pode ser 'small', 'medium' ou 'large'.\",\n table: {\n category: 'Propriedades',\n defaultValue: { summary: 'medium' },\n },\n },\n status: {\n control: { type: 'inline-radio' },\n options: ['default', 'success', 'error'],\n description: \"Status do componente select. Pode ser 'success', 'error' ou 'default'.\",\n table: {\n category: 'Propriedades',\n defaultValue: { summary: 'default' },\n },\n },\n disabled: {\n control: 'boolean',\n description: 'Indica se o componente select está desabilitado.',\n table: {\n category: 'states',\n defaultValue: { summary: 'false' },\n },\n },\n required: {\n control: 'boolean',\n description: 'Indica se o componente select é obrigatório.',\n table: {\n category: 'states',\n defaultValue: { summary: 'false' },\n },\n },\n searchBehavior: {\n control: 'boolean',\n description: 'Habilita o modo de digitação e busca nas opções a partir do termo.',\n table: {\n category: 'states',\n defaultValue: { summary: 'false' },\n }\n },\n helperText: {\n name: 'content',\n control: 'text',\n description: 'Define o texto de ajuda do input, renderizado dentro do slot num elemento <cura-label>. Aceita tags HTML.',\n table: {\n category: 'Slots',\n defaultValue: { summary: '' },\n },\n },\n onselect: {\n description: 'Emite um evento via Listener quando um valor é selecionado. { value: string , selected: boolean }',\n table: {\n category: 'Evento',\n defaultValue: { summary: '' },\n },\n },\n options: {\n control: 'array',\n description: 'Lista de opções definido pela aplicação para cura-select-option.',\n table: {\n category: 'aplication',\n defaultValue: { summary: '[]' },\n },\n },\n },\n};\n\nexport const CuraSelect = {\n args: {\n options: [\n { value: '1', label: 'Opção 1' },\n { value: '2', label: 'Escolha 2' },\n { value: '3', label: 'Exemplo 3' },\n ],\n label: 'Escolha uma opção',\n placeholder: 'Selecione...',\n defaultValue: '',\n value: '',\n mode: 'default',\n size: 'medium',\n status: 'default',\n disabled: false,\n required: false,\n searchBehavior: false,\n helperText: 'Texto de ajuda'\n },\n};\n"]}
|
|
@@ -97,7 +97,9 @@
|
|
|
97
97
|
:host ::slotted(b), :host ::slotted(strong) {
|
|
98
98
|
font-weight: var(--font-weight-bold);
|
|
99
99
|
}
|
|
100
|
-
:host ::slotted(a)
|
|
100
|
+
:host ::slotted(a),
|
|
101
|
+
:host ::slotted(span a),
|
|
102
|
+
:host ::slotted(a:-webkit-any-link), :host p a {
|
|
101
103
|
font-weight: var(--font-weight-medium);
|
|
102
104
|
color: var(--color-link);
|
|
103
105
|
text-underline-offset: 10%;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useOf } from "@storybook/blocks";
|
|
2
|
+
import { CuraHeading, CuraParagraph, CuraAlert } from "../../../../component-lib-react/dist/index.js";
|
|
3
|
+
import { Source, Unstyled } from '@storybook/blocks';
|
|
4
|
+
import Markdown from 'react-markdown';
|
|
5
|
+
import rehypeRaw from 'rehype-raw';
|
|
6
|
+
|
|
7
|
+
const MarkdownSbUnstyled = {
|
|
8
|
+
p(props) {
|
|
9
|
+
const {children} = props;
|
|
10
|
+
return <span>{children}</span>
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const Block = ({options}, key) => {
|
|
16
|
+
switch(options.type) {
|
|
17
|
+
case 'subtitle': {
|
|
18
|
+
return (
|
|
19
|
+
<Unstyled>
|
|
20
|
+
<CuraHeading size="small" level="2" weight="bold" key={key}>{options.content}</CuraHeading>
|
|
21
|
+
</Unstyled>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
case 'text': {
|
|
25
|
+
return (
|
|
26
|
+
<Unstyled>
|
|
27
|
+
<CuraParagraph key={key}>
|
|
28
|
+
<Markdown rehypePlugins={[rehypeRaw]} components={MarkdownSbUnstyled}>{ options.content }</Markdown>
|
|
29
|
+
</CuraParagraph>
|
|
30
|
+
</Unstyled>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
case 'alert': {
|
|
34
|
+
return (
|
|
35
|
+
<Unstyled>
|
|
36
|
+
<CuraAlert key={key} closeable="false" floating="false" label={options.title} type={options.mode} style={{maxWidth: "640px", marginBlock: "2rem"}}>
|
|
37
|
+
<Markdown rehypePlugins={[rehypeRaw]} components={MarkdownSbUnstyled}>{ options.content }</Markdown>
|
|
38
|
+
</CuraAlert>
|
|
39
|
+
</Unstyled>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
case 'code': {
|
|
43
|
+
return (
|
|
44
|
+
<Source language={options.lang} code={options.content} key={key}/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
case 'list': {
|
|
48
|
+
const listItems = options.items.map((item, i) => {
|
|
49
|
+
return (
|
|
50
|
+
<li key={`${key}-${i}`}>
|
|
51
|
+
<Markdown rehypePlugins={[rehypeRaw]} components={MarkdownSbUnstyled}>{ item }</Markdown>
|
|
52
|
+
</li>
|
|
53
|
+
)
|
|
54
|
+
});
|
|
55
|
+
return options.listType === 'ol'
|
|
56
|
+
? ( <ol key={key}>{ listItems }</ol> )
|
|
57
|
+
: ( <ul key={key}>{ listItems }</ul> );
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
console.log(options);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const Sections = (docsJson) => {
|
|
64
|
+
const resolveOf = useOf(docsJson.sections || 'component', ['component']);
|
|
65
|
+
const sections = resolveOf.component;
|
|
66
|
+
return (
|
|
67
|
+
sections.map(section => {
|
|
68
|
+
return (
|
|
69
|
+
<section key={section.id} id={section.id}>
|
|
70
|
+
<Unstyled>
|
|
71
|
+
<CuraHeading size="large" weight="bold">{section.title}</CuraHeading>
|
|
72
|
+
</Unstyled>
|
|
73
|
+
{
|
|
74
|
+
section.blocks.map((block, i) => {
|
|
75
|
+
const key = `${section.id}${i}`;
|
|
76
|
+
return (
|
|
77
|
+
<Block options={block} key={key}/>
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
</section>
|
|
82
|
+
)
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|