= {
dateFormat: 'date-format',
showOnFocus: 'show-on-focus',
showIcon: 'show-icon',
manualInput: 'manual-input',
inputId: 'input-id',
ariaLabel: 'aria-label',
ariaLabelledby: 'aria-labelledby',
datePickerClass: 'date-picker-class',
nuiType: 'nui-type',
};
export const NUI_DATE_PICKER_DEFAULTS: PlaygroundProps = {
value: '',
placeholder: 'Select date',
dateFormat: 'yy-mm-dd',
disabled: false,
readonly: false,
invalid: false,
required: false,
fluid: false,
size: '',
variant: '',
showOnFocus: true,
showIcon: true,
icon: 'mdi:calendar',
manualInput: false,
name: '',
inputId: 'nui-date-picker-preview',
ariaLabel: '',
ariaLabelledby: '',
unstyled: false,
nuiType: '',
datePickerClass: '',
};
const CONTROLS: PlaygroundControl[] = [
{
key: 'value',
label: 'value',
type: 'text',
section: 'Content',
placeholder: '2026-06-22',
},
{
key: 'placeholder',
label: 'placeholder',
type: 'text',
section: 'Content',
placeholder: 'Select date',
},
{
key: 'dateFormat',
label: 'date-format',
type: 'text',
section: 'Content',
placeholder: 'yy-mm-dd',
},
{
key: 'datePickerClass',
label: 'date-picker-class',
type: 'text',
section: 'Content',
},
{
key: 'icon',
label: 'icon',
type: 'text',
section: 'Appearance',
placeholder: 'mdi:calendar',
},
{
key: 'size',
label: 'size',
type: 'select',
section: 'Appearance',
options: [
{ value: '', label: '(default)' },
{ value: 'small', label: 'small' },
{ value: 'large', label: 'large' },
],
},
{
key: 'variant',
label: 'variant',
type: 'select',
section: 'Appearance',
options: [
{ value: '', label: '(default)' },
{ value: 'filled', label: 'filled' },
{ value: 'outlined', label: 'outlined' },
],
},
{ key: 'nuiType', label: 'nui-type', type: 'text', section: 'Appearance' },
{
key: 'showOnFocus',
label: 'show-on-focus',
type: 'boolean',
section: 'Modifiers',
},
{
key: 'showIcon',
label: 'show-icon',
type: 'boolean',
section: 'Modifiers',
},
{
key: 'manualInput',
label: 'manual-input',
type: 'boolean',
section: 'Modifiers',
},
{
key: 'unstyled',
label: 'unstyled',
type: 'boolean',
section: 'Modifiers',
},
{
key: 'disabled',
label: 'disabled',
type: 'boolean',
section: 'State',
},
{
key: 'readonly',
label: 'readonly',
type: 'boolean',
section: 'State',
},
{
key: 'invalid',
label: 'invalid',
type: 'boolean',
section: 'State',
},
{
key: 'required',
label: 'required',
type: 'boolean',
section: 'State',
},
{
key: 'fluid',
label: 'fluid',
type: 'boolean',
section: 'Layout',
},
{
key: 'name',
label: 'name',
type: 'text',
section: 'HTML',
},
{
key: 'inputId',
label: 'input-id',
type: 'text',
section: 'HTML',
},
{
key: 'ariaLabel',
label: 'aria-label',
type: 'text',
section: 'HTML',
},
{
key: 'ariaLabelledby',
label: 'aria-labelledby',
type: 'text',
section: 'HTML',
},
];
function handleChange(
event: Event,
handlers?: PlaygroundPreviewHandlers,
): void {
if (!handlers) {
return;
}
const value = (event as CustomEvent<{ value: string }>).detail.value;
handlers.onPropChange('value', value);
}
function renderPreview(
props: PlaygroundProps,
handlers?: PlaygroundPreviewHandlers,
): TemplateResult {
return html`
handleChange(event, handlers)}
>
`;
}
export const nuiDatePickerPlayground: PlaygroundDefinition = {
tag: 'nui-date-picker',
label: 'Date Picker',
description:
'Single-date input with calendar overlay; value stored as YYYY-MM-DD.',
defaults: NUI_DATE_PICKER_DEFAULTS,
controls: CONTROLS,
renderPreview,
formatUsage: (props) =>
formatUsageFromDefaults(
'nui-date-picker',
props,
NUI_DATE_PICKER_DEFAULTS,
ATTRIBUTE_NAMES,
),
};