Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/components/src/components/date-picker/date-picker.css
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,14 @@ scale-date-picker .has-helper-text scale-helper-text {
max-width: none;
}
}
.date-picker__label--visually-hidden {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment in textarea.cssyou should use a descendant selector (if you follow my proposal).

position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
12 changes: 11 additions & 1 deletion packages/components/src/components/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export class DatePicker {
/** (optional) id or space separated list of ids of elements that provide or link to additional related information. */
@Prop() ariaDetailsId?: string;

/** (optional) Visually hide the label (remains accessible to screen readers) */
@Prop() hideLabelVisually?: boolean = false;

/** Whether the input element has focus */
@State() hasFocus: boolean = false;

Expand Down Expand Up @@ -424,9 +427,16 @@ export class DatePicker {
this.helperText && 'has-helper-text'
)}
>
<label class="date-picker__label" htmlFor={this.identifier}>
<label
class={classNames(
'date-picker__label',
this.hideLabelVisually && 'date-picker__label--visually-hidden'
)}
htmlFor={this.identifier}
>
{this.label}
</label>

<duet-date-picker
onDuetChange={(e) => {
emitEvent(this, 'scale-change', e.detail);
Expand Down
49 changes: 25 additions & 24 deletions packages/components/src/components/date-picker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,31 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ---------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----------------- |
| `ariaDetailsId` | `aria-details-id` | (optional) id or space separated list of ids of elements that provide or link to additional related information. | `string` | `undefined` |
| `dateAdapter` | `date-adapter` | Date adapter, for custom parsing/formatting. Must be object with a `parse` function which accepts a `string` and returns a `Date`, and a `format` function which accepts a `Date` and returns a `string`. Default is IS0-8601 parsing and formatting. | `any` | `undefined` |
| `direction` | `direction` | Forces the opening direction of the calendar modal to be always left or right. This setting can be useful when the input is smaller than the opening date picker would be as by default the picker always opens towards right. | `"left" \| "right"` | `'right'` |
| `disabled` | `disabled` | Makes the date picker input component disabled. This prevents users from being able to interact with the input, and conveys its inactive state to assistive technologies. | `boolean` | `false` |
| `firstDayOfWeek` | `first-day-of-week` | Which day is considered first day of the week? `0` for Sunday, `1` for Monday, etc. Default is Monday. | `any` | `undefined` |
| `helperText` | `helper-text` | (optional) Helper text | `string` | `''` |
| `identifier` | `identifier` | Adds a unique identifier for the date picker input. Use this instead of html `id` attribute. | `string` | `undefined` |
| `innerRole` | `inner-role` | Defines a specific role attribute for the date picker input. | `string` | `undefined` |
| `invalid` | `invalid` | (optional) invalid status | `boolean` | `undefined` |
| `label` | `label` | (optional) Label | `string` | `''` |
| `localization` | `localization` | Button labels, day names, month names, etc, used for localization. Default is English. | `DuetLocalizedText & { today: string; }` | `undefined` |
| `max` | `max` | Maximum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. This setting can be used alone or together with the min property. | `string` | `''` |
| `min` | `min` | Minimum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. This setting can be used alone or together with the max property. | `string` | `''` |
| `name` | `name` | Name of the date picker input. | `string` | `'date'` |
| `placeholder` | `placeholder` | (optional) Input place holder | `string` | `''` |
| `popupTitle` | `popup-title` | <span style="color:red">**[DEPRECATED]**</span> in v3 in favor of localization.calendarHeading<br/><br/> | `string` | `'Pick a date'` |
| `required` | `required` | Should the input be marked as required? | `boolean` | `false` |
| `size` | `size` | <span style="color:red">**[DEPRECATED]**</span> <br/><br/> | `string` | `undefined` |
| `status` | `status` | <span style="color:red">**[DEPRECATED]**</span> - invalid should replace status<br/><br/> | `string` | `''` |
| `styles` | `styles` | (optional) Injected CSS styles | `string` | `undefined` |
| `value` | `value` | Date value. Must be in IS0-8601 format: YYYY-MM-DD. | `string` | `''` |
| `variant` | `variant` | | `"danger" \| "informational" \| "success" \| "warning"` | `'informational'` |
| Property | Attribute | Description | Type | Default |
| ------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----------------- |
| `ariaDetailsId` | `aria-details-id` | (optional) id or space separated list of ids of elements that provide or link to additional related information. | `string` | `undefined` |
| `dateAdapter` | `date-adapter` | Date adapter, for custom parsing/formatting. Must be object with a `parse` function which accepts a `string` and returns a `Date`, and a `format` function which accepts a `Date` and returns a `string`. Default is IS0-8601 parsing and formatting. | `any` | `undefined` |
| `direction` | `direction` | Forces the opening direction of the calendar modal to be always left or right. This setting can be useful when the input is smaller than the opening date picker would be as by default the picker always opens towards right. | `"left" \| "right"` | `'right'` |
| `disabled` | `disabled` | Makes the date picker input component disabled. This prevents users from being able to interact with the input, and conveys its inactive state to assistive technologies. | `boolean` | `false` |
| `firstDayOfWeek` | `first-day-of-week` | Which day is considered first day of the week? `0` for Sunday, `1` for Monday, etc. Default is Monday. | `any` | `undefined` |
| `helperText` | `helper-text` | (optional) Helper text | `string` | `''` |
| `hideLabelVisually` | `hide-label-visually` | (optional) Visually hide the label (remains accessible to screen readers) | `boolean` | `false` |
| `identifier` | `identifier` | Adds a unique identifier for the date picker input. Use this instead of html `id` attribute. | `string` | `undefined` |
| `innerRole` | `inner-role` | Defines a specific role attribute for the date picker input. | `string` | `undefined` |
| `invalid` | `invalid` | (optional) invalid status | `boolean` | `undefined` |
| `label` | `label` | (optional) Label | `string` | `''` |
| `localization` | `localization` | Button labels, day names, month names, etc, used for localization. Default is English. | `DuetLocalizedText & { today: string; }` | `undefined` |
| `max` | `max` | Maximum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. This setting can be used alone or together with the min property. | `string` | `''` |
| `min` | `min` | Minimum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. This setting can be used alone or together with the max property. | `string` | `''` |
| `name` | `name` | Name of the date picker input. | `string` | `'date'` |
| `placeholder` | `placeholder` | (optional) Input place holder | `string` | `''` |
| `popupTitle` | `popup-title` | <span style="color:red">**[DEPRECATED]**</span> in v3 in favor of localization.calendarHeading<br/><br/> | `string` | `'Pick a date'` |
| `required` | `required` | Should the input be marked as required? | `boolean` | `false` |
| `size` | `size` | <span style="color:red">**[DEPRECATED]**</span> <br/><br/> | `string` | `undefined` |
| `status` | `status` | <span style="color:red">**[DEPRECATED]**</span> - invalid should replace status<br/><br/> | `string` | `''` |
| `styles` | `styles` | (optional) Injected CSS styles | `string` | `undefined` |
| `value` | `value` | Date value. Must be in IS0-8601 format: YYYY-MM-DD. | `string` | `''` |
| `variant` | `variant` | | `"danger" \| "informational" \| "success" \| "warning"` | `'informational'` |


## Events
Expand Down
Loading
Loading