-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,883 additions
and
1,207 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Stack trace: | ||
Frame Function Args | ||
000FFFFC108 00180063F7E (0018028EB18, 0018026DFBE, 00000000000, 000FFFFB010) | ||
000FFFFC108 0018004973A (00000000000, 00000000000, 00000000000, 0018028EBD0) | ||
000FFFFC108 00180049772 (0018028EC18, 000FFFFBFC8, 00000000000, 00000000000) | ||
000FFFFC108 001800CAA22 (00000000000, 00000000000, 00000000000, 00000000000) | ||
000FFFFC108 001800CABC0 (000FFFFC150, 00000000000, 00000000000, 00000000000) | ||
000FFFFC400 001800CC3D5 (000FFFFC150, 00000000000, 00000000000, 00000000000) | ||
End of stack trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "element-vir", | ||
"version": "20.0.9", | ||
"version": "20.1.0", | ||
"keywords": [ | ||
"custom", | ||
"web", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
packages/vira-book/src/element-book/entries/vira-dropdown.element.book.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import {getEnumTypedKeys} from '@augment-vir/common'; | ||
import {BookPageControlTypeEnum, defineBookPage, definePageControl} from 'element-book'; | ||
import {CSSResult, css, html, listen} from 'element-vir'; | ||
import {ViraDropdown, ViraDropdownDirectionEnum, ViraDropdownOption} from 'vira'; | ||
import {elementsBookPage} from '../elements.book'; | ||
import {Element24Icon} from './../../../../vira/src/icons/icon-svgs/element-24.icon'; | ||
|
||
const exampleDropdownOptions = [ | ||
{ | ||
label: 'Option 1', | ||
value: 1, | ||
}, | ||
{ | ||
label: 'Option 2', | ||
value: 2, | ||
}, | ||
{ | ||
label: 'Option 3', | ||
value: 3, | ||
}, | ||
{ | ||
label: 'Really really super duper long option', | ||
value: 4, | ||
}, | ||
] as const satisfies ReadonlyArray<ViraDropdownOption>; | ||
|
||
const exampleVariations: ReadonlyArray<{ | ||
title: string; | ||
inputs?: Partial<typeof ViraDropdown.inputsType>; | ||
customStyle?: CSSResult; | ||
}> = [ | ||
{ | ||
title: 'default', | ||
}, | ||
{ | ||
title: 'multi select', | ||
inputs: { | ||
isMultiSelect: true, | ||
}, | ||
}, | ||
{ | ||
title: 'disabled', | ||
inputs: { | ||
disabled: true, | ||
}, | ||
}, | ||
]; | ||
|
||
const innerVariations: ReadonlyArray<{ | ||
customStyle?: CSSResult; | ||
inputs?: Partial<typeof ViraDropdown.inputsType>; | ||
}> = [ | ||
{}, | ||
{ | ||
customStyle: css` | ||
width: 500px; | ||
height: 100px; | ||
`, | ||
}, | ||
{ | ||
customStyle: css` | ||
max-height: 30px; | ||
min-height: 30px; | ||
`, | ||
}, | ||
]; | ||
|
||
export const viraDropdownPage = defineBookPage({ | ||
title: ViraDropdown.tagName, | ||
parent: elementsBookPage, | ||
controls: { | ||
Selected: definePageControl({ | ||
controlType: BookPageControlTypeEnum.Dropdown, | ||
initValue: exampleDropdownOptions[0].label, | ||
options: exampleDropdownOptions.map((option) => option.label), | ||
}), | ||
Direction: definePageControl({ | ||
controlType: BookPageControlTypeEnum.Dropdown, | ||
initValue: 'Down', | ||
options: getEnumTypedKeys(ViraDropdownDirectionEnum), | ||
}), | ||
Prefix: definePageControl({ | ||
controlType: BookPageControlTypeEnum.Text, | ||
initValue: 'Sort by: ', | ||
}), | ||
'Force open': definePageControl({ | ||
controlType: BookPageControlTypeEnum.Checkbox, | ||
initValue: false, | ||
}), | ||
}, | ||
elementExamplesCallback({defineExample}) { | ||
exampleVariations.forEach((exampleVariation) => { | ||
defineExample({ | ||
title: exampleVariation.title, | ||
stateInitStatic: { | ||
selected: innerVariations.map((innerVariation) => innerVariation.inputs?.value), | ||
}, | ||
styles: css` | ||
:host { | ||
display: flex; | ||
gap: 16px; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
} | ||
`, | ||
renderCallback({state, updateState, controls}) { | ||
return innerVariations.map((innerVariation, variationIndex) => { | ||
const styles = css` | ||
${exampleVariation.customStyle ?? css``}; | ||
${innerVariation.customStyle ?? css``}; | ||
`; | ||
|
||
return html` | ||
<${ViraDropdown.assign({ | ||
...exampleVariation.inputs, | ||
...innerVariation.inputs, | ||
options: exampleDropdownOptions, | ||
value: state.selected[variationIndex] ?? [ | ||
exampleDropdownOptions.find( | ||
(option) => option.label === controls.Selected, | ||
) ?? exampleDropdownOptions[0], | ||
], | ||
icon: Element24Icon, | ||
selectedLabelPrefix: controls.Prefix, | ||
direction: | ||
ViraDropdownDirectionEnum[ | ||
controls.Direction as keyof typeof ViraDropdownDirectionEnum | ||
], | ||
_forceOpenState: controls['Force open'] || undefined, | ||
})} | ||
style=${styles} | ||
${listen(ViraDropdown.events.selectChange, (event) => { | ||
const newSelected = [...state.selected]; | ||
newSelected[variationIndex] = event.detail; | ||
updateState({selected: newSelected}); | ||
})} | ||
></${ViraDropdown}> | ||
`; | ||
}); | ||
}, | ||
}); | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {html} from 'element-vir'; | ||
import {defineViraElement} from './define-vira-element'; | ||
|
||
export const ViraDropdownItem = defineViraElement<{ | ||
value: string; | ||
label: string; | ||
}>()({ | ||
tagName: 'vira-dropdown-item', | ||
renderCallback({dispatch, events, state, inputs, updateState}) { | ||
return html` | ||
<span | ||
class="option ${selectedOptions | ||
.map((selectedItem) => selectedItem?.value) | ||
.includes(item.value) | ||
? 'selected' | ||
: ''}" | ||
@click=${(event: Event) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
if (!inputs.isMultiSelect) { | ||
updateState({dropdownOpen: false}); | ||
dispatch(new events.openChange(false)); | ||
} | ||
dispatch( | ||
new events.selectChange( | ||
inputs.isMultiSelect | ||
? inputs.value.includes(item.value) | ||
? inputs.value.filter((value) => value !== item.value) | ||
: [ | ||
...inputs.value, | ||
item.value, | ||
] | ||
: [item.value], | ||
), | ||
); | ||
}} | ||
role="option" | ||
> | ||
${item.label} | ||
</span> | ||
`; | ||
}, | ||
}); |
Oops, something went wrong.