diff --git a/packages/cmsui/config/widgets.ts b/packages/cmsui/config/widgets.ts index d94d0c0316c..b397b64fb42 100644 --- a/packages/cmsui/config/widgets.ts +++ b/packages/cmsui/config/widgets.ts @@ -6,6 +6,7 @@ import { DateTimePicker, SizeWidget, WidthWidget, + SelectWidget, } from '@plone/components/quanta'; import { DateField } from '@plone/components'; @@ -30,5 +31,11 @@ export default function install(config: ConfigType) { definition: { width: WidthWidget }, }); + config.registerWidget({ + key: 'factory', + definition: { Choice: SelectWidget }, + }); + //console.log(config.widgets); + return config; } diff --git a/packages/components/news/7345.feature b/packages/components/news/7345.feature new file mode 100644 index 00000000000..c4e8166272c --- /dev/null +++ b/packages/components/news/7345.feature @@ -0,0 +1 @@ +Select widget for Plone 7 @dobri1408 diff --git a/packages/components/src/components/Select/Select.quanta.stories.tsx b/packages/components/src/components/Select/Select.quanta.stories.tsx new file mode 100644 index 00000000000..a7eb438170c --- /dev/null +++ b/packages/components/src/components/Select/Select.quanta.stories.tsx @@ -0,0 +1,141 @@ +import React, { useState } from 'react'; +import { SelectWidget, type Option, type SelectProps } from './Select.quanta'; +import { type Key } from 'react-aria-components'; + +const fruits: Option[] = [ + { id: 'apple', name: 'Apple' }, + { id: 'banana', name: 'Banana' }, + { id: 'orange', name: 'Orange' }, + { id: 'strawberry', name: 'Strawberry' }, + { id: 'blueberry', name: 'Blueberry' }, + { id: 'raspberry', name: 'Raspberry' }, + { id: 'grape', name: 'Grape' }, + { id: 'watermelon', name: 'Watermelon' }, + { id: 'pineapple', name: 'Pineapple' }, + { id: 'mango', name: 'Mango' }, +]; + +export default { + title: 'Quanta/Select', + component: SelectWidget, + parameters: { + layout: 'centered', + }, + tags: ['autodocs'], + argTypes: { + items: { + control: false, + description: 'The list of available options to display in the dropdown.', + }, + label: { control: 'text', description: 'The label of the select field' }, + placeholder: { + control: 'text', + description: 'Placeholder text displayed when no option is selected.', + }, + description: { + control: 'text', + description: 'Additional helper text displayed below the field.', + }, + errorMessage: { + control: 'text', + description: 'Error message to display below the field.', + }, + isDisabled: { + control: 'boolean', + description: 'Whether the field is disabled.', + }, + isRequired: { + control: 'boolean', + description: 'Whether the field is required.', + }, + onChange: { + action: 'selection-changed', + description: 'Callback fired when selection changes.', + }, + }, +}; + +export const Default = (args: SelectProps