@popsure/dirty-swan 27.0.0 → 27.0.5
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/Readme.md +10 -1
- package/dist/index.css +11 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +26 -17
- package/dist/index.js.map +1 -1
- package/dist/lib/components/autocompleteAddress/demo.d.ts +2 -0
- package/dist/lib/components/autocompleteAddress/index.d.ts +13 -1
- package/dist/lib/components/dateSelector/index.d.ts +8 -1
- package/dist/lib/scss/private/_reset.scss +5 -0
- package/dist/lib/scss/private/base/_typography.scss +7 -0
- package/dist/lib/scss/private/base/demo.tsx +4 -0
- package/dist/lib/scss/private/components/_input.scss +1 -4
- package/package.json +1 -1
- package/src/lib/components/autocompleteAddress/demo.tsx +50 -0
- package/src/lib/components/autocompleteAddress/index.stories.mdx +18 -9
- package/src/lib/components/autocompleteAddress/index.tsx +29 -10
- package/src/lib/components/autocompleteAddress/style.module.scss +1 -7
- package/src/lib/components/dateSelector/index.stories.mdx +44 -0
- package/src/lib/components/dateSelector/index.tsx +30 -5
- package/src/lib/scss/private/_reset.scss +5 -0
- package/src/lib/scss/private/base/_typography.scss +7 -0
- package/src/lib/scss/private/base/demo.tsx +4 -0
- package/src/lib/scss/private/base/typography.stories.mdx +3 -0
- package/src/lib/scss/private/components/_input.scss +1 -4
- package/src/lib/scss/public/grid.stories.mdx +3 -3
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const WithoutAddress: () => JSX.Element;
|
|
3
3
|
export declare const WithAddress: () => JSX.Element;
|
|
4
|
+
export declare const WithoutAddressLocalized: () => JSX.Element;
|
|
5
|
+
export declare const WithAddressLocalized: () => JSX.Element;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Address } from '@popsure/public-models';
|
|
3
|
-
declare const AutoCompleteAddress: ({ apiKey, address: initialAddress, onAddressChange, }: {
|
|
3
|
+
declare const AutoCompleteAddress: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, }: {
|
|
4
4
|
apiKey: string;
|
|
5
5
|
address?: Partial<Address> | undefined;
|
|
6
6
|
onAddressChange: (address: Partial<Address>) => void;
|
|
7
|
+
placeholders?: {
|
|
8
|
+
manualAddressEntry?: string | undefined;
|
|
9
|
+
street?: string | undefined;
|
|
10
|
+
houseNumber?: string | undefined;
|
|
11
|
+
additionalInformation?: string | undefined;
|
|
12
|
+
postcode?: string | undefined;
|
|
13
|
+
city?: string | undefined;
|
|
14
|
+
} | undefined;
|
|
15
|
+
manualAddressEntryTexts?: {
|
|
16
|
+
preText?: string | undefined;
|
|
17
|
+
cta?: string | undefined;
|
|
18
|
+
} | undefined;
|
|
7
19
|
}) => JSX.Element;
|
|
8
20
|
export default AutoCompleteAddress;
|
|
@@ -5,7 +5,7 @@ export declare const daysInMonthOfYear: ({ month, year, }: {
|
|
|
5
5
|
month: number;
|
|
6
6
|
year: number;
|
|
7
7
|
}) => number;
|
|
8
|
-
declare const DateSelector: ({ value, onChange, yearBoundaries, displayCalendar, }: {
|
|
8
|
+
declare const DateSelector: ({ value, onChange, yearBoundaries, displayCalendar, placeholders, dayjsLocale, firstDayOfWeek, }: {
|
|
9
9
|
value?: string | undefined;
|
|
10
10
|
onChange: (date: string) => void;
|
|
11
11
|
yearBoundaries: {
|
|
@@ -13,5 +13,12 @@ declare const DateSelector: ({ value, onChange, yearBoundaries, displayCalendar,
|
|
|
13
13
|
max: number;
|
|
14
14
|
};
|
|
15
15
|
displayCalendar?: boolean | undefined;
|
|
16
|
+
placeholders?: {
|
|
17
|
+
day?: string | undefined;
|
|
18
|
+
month?: string | undefined;
|
|
19
|
+
year?: string | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
dayjsLocale?: ILocale | undefined;
|
|
22
|
+
firstDayOfWeek?: number | undefined;
|
|
16
23
|
}) => JSX.Element;
|
|
17
24
|
export default DateSelector;
|
|
@@ -95,10 +95,17 @@ body {
|
|
|
95
95
|
.p-a {
|
|
96
96
|
color: $ds-primary-500;
|
|
97
97
|
text-decoration: none;
|
|
98
|
+
|
|
98
99
|
&:hover,
|
|
99
100
|
&:focus {
|
|
100
101
|
color: $ds-primary-700;
|
|
101
102
|
}
|
|
103
|
+
|
|
104
|
+
&:focus-visible {
|
|
105
|
+
outline: 2px solid $ds-grey-900;
|
|
106
|
+
border-radius: 2px;
|
|
107
|
+
outline-offset: 2px;
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
// Layout
|
|
@@ -11,6 +11,10 @@ export const Typography = () => (
|
|
|
11
11
|
<h4 className="p-h4">The quick brown fox jumps over the lazy dog</h4>
|
|
12
12
|
<p className="p-p">The quick brown fox jumps over the lazy dog</p>
|
|
13
13
|
<p className="p-p--small">The quick brown fox jumps over the lazy dog</p>
|
|
14
|
+
<a href="#" className="p-a">
|
|
15
|
+
The quick brown fox jumps over the lazy dog
|
|
16
|
+
</a>
|
|
17
|
+
<p className="p-error">The quick brown fox jumps over the lazy dog</p>
|
|
14
18
|
</>
|
|
15
19
|
);
|
|
16
20
|
|
|
@@ -94,10 +94,7 @@
|
|
|
94
94
|
.p-radio:checked {
|
|
95
95
|
& + label::before {
|
|
96
96
|
border-color: $ds-primary-500;
|
|
97
|
-
|
|
98
|
-
background-image: url('data:image/svg+xml;utf8,<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="6" cy="6" r="5.5" fill="#{util.url-encoded-color($ds-primary-500)}" /></svg>');
|
|
99
|
-
background-repeat: no-repeat;
|
|
100
|
-
background-position: center;
|
|
97
|
+
background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 20 20" stroke="white" stroke-width="4" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="50%" fill="#{util.url-encoded-color($ds-primary-500)}"/></svg>');
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
100
|
|
package/package.json
CHANGED
|
@@ -36,3 +36,53 @@ export const WithAddress = () => {
|
|
|
36
36
|
/>
|
|
37
37
|
);
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
export const WithoutAddressLocalized = () => {
|
|
41
|
+
const [address, setAddress] = useState<Partial<Address> | undefined>();
|
|
42
|
+
return (
|
|
43
|
+
<AutoCompleteAddress
|
|
44
|
+
onAddressChange={(address) => {
|
|
45
|
+
setAddress(address);
|
|
46
|
+
}}
|
|
47
|
+
address={address}
|
|
48
|
+
apiKey="AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8"
|
|
49
|
+
placeholders={{
|
|
50
|
+
manualAddressEntry: 'Adresse suchen',
|
|
51
|
+
street: 'Straße',
|
|
52
|
+
houseNumber: 'Hausnummer',
|
|
53
|
+
additionalInformation: 'Adresszusatz (c/o, z. Hd., o.V.i.A, ...)',
|
|
54
|
+
postcode: 'PLZ',
|
|
55
|
+
city: 'Stadt',
|
|
56
|
+
}}
|
|
57
|
+
manualAddressEntryTexts={{
|
|
58
|
+
preText: 'Oder ',
|
|
59
|
+
cta: 'Adresse direkt eingeben',
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const WithAddressLocalized = () => {
|
|
66
|
+
const [address, setAddress] = useState<Partial<Address> | undefined>({});
|
|
67
|
+
return (
|
|
68
|
+
<AutoCompleteAddress
|
|
69
|
+
onAddressChange={(address) => {
|
|
70
|
+
setAddress(address);
|
|
71
|
+
}}
|
|
72
|
+
address={address}
|
|
73
|
+
apiKey="AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8"
|
|
74
|
+
placeholders={{
|
|
75
|
+
manualAddressEntry: 'Adresse suchen',
|
|
76
|
+
street: 'Straße',
|
|
77
|
+
houseNumber: 'Hausnummer',
|
|
78
|
+
additionalInformation: 'Adresszusatz (c/o, z.Hd., o.V.i.A, ...)',
|
|
79
|
+
postcode: 'PLZ',
|
|
80
|
+
city: 'Stadt',
|
|
81
|
+
}}
|
|
82
|
+
manualAddressEntryTexts={{
|
|
83
|
+
preText: 'Oder ',
|
|
84
|
+
cta: 'Adresse direkt eingeben',
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -3,17 +3,24 @@ import { useState } from 'react';
|
|
|
3
3
|
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
4
4
|
|
|
5
5
|
import AutocompleteAddress from '.';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
WithoutAddress,
|
|
8
|
+
WithoutAddressLocalized,
|
|
9
|
+
WithAddress,
|
|
10
|
+
WithAddressLocalized,
|
|
11
|
+
} from './demo';
|
|
7
12
|
|
|
8
13
|
<Meta title="JSX/Autocomplete Address" component={AutocompleteAddress} />
|
|
9
14
|
|
|
10
15
|
# Autocomplete Address
|
|
11
16
|
|
|
12
|
-
| attribute
|
|
13
|
-
|
|
|
14
|
-
| address
|
|
15
|
-
| onAddressChange
|
|
16
|
-
| apiKey
|
|
17
|
+
| attribute | unit | description | default value | required |
|
|
18
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------- | -------- |
|
|
19
|
+
| address | `Partial<Address>` | The address | undefined | false |
|
|
20
|
+
| onAddressChange | `function (newAddress: Partial<Address>)` | Callback with the updated address, this function will get called everytime the address gets updated. | n/a | true |
|
|
21
|
+
| apiKey | string | Your private API key for the [Google Places API](https://developers.google.com/maps/documentation/places/web-service/overview) | n/a | true |
|
|
22
|
+
| placeholders | `{ manualAddressEntry?: string; street: string?; houseNumber?: string; additionalInformation?: string; postcode?: string; city?: string; }` | Placeholder text | undefined | false |
|
|
23
|
+
| manualAddressEntryTexts | `{ preText?: string; cta: string?; }` | The CTA that enables manual address entry and the text preceding it | undefined | false |
|
|
17
24
|
|
|
18
25
|
Autocomplete Address are user interface elements which allow users start typing an address and get autocompletion suggestions on the address.
|
|
19
26
|
|
|
@@ -31,10 +38,12 @@ This component is for now only restricted to "address" types and will restrict e
|
|
|
31
38
|
|
|
32
39
|
<WithAddress />
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
import React, { useState } from 'react';
|
|
36
|
-
import { Address } from '@popsure/public-models';
|
|
41
|
+
### Localized inputs
|
|
37
42
|
|
|
43
|
+
<WithoutAddressLocalized />
|
|
44
|
+
<WithAddressLocalized />
|
|
45
|
+
|
|
46
|
+
```typescript import React, {useState} from 'react'; import {Address} from '@popsure/public-models';
|
|
38
47
|
import AutoCompleteAddress from '.';
|
|
39
48
|
|
|
40
49
|
export default () => {
|
|
@@ -53,10 +53,24 @@ const AutoCompleteAddress = ({
|
|
|
53
53
|
apiKey,
|
|
54
54
|
address: initialAddress,
|
|
55
55
|
onAddressChange,
|
|
56
|
+
placeholders,
|
|
57
|
+
manualAddressEntryTexts,
|
|
56
58
|
}: {
|
|
57
59
|
apiKey: string;
|
|
58
60
|
address?: Partial<Address>;
|
|
59
61
|
onAddressChange: (address: Partial<Address>) => void;
|
|
62
|
+
placeholders?: {
|
|
63
|
+
manualAddressEntry?: string;
|
|
64
|
+
street?: string;
|
|
65
|
+
houseNumber?: string;
|
|
66
|
+
additionalInformation?: string;
|
|
67
|
+
postcode?: string;
|
|
68
|
+
city?: string;
|
|
69
|
+
};
|
|
70
|
+
manualAddressEntryTexts?: {
|
|
71
|
+
preText?: string;
|
|
72
|
+
cta?: string;
|
|
73
|
+
};
|
|
60
74
|
}) => {
|
|
61
75
|
const [manualAddressEntry, setManualAddressEntry] = useState(false);
|
|
62
76
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -216,7 +230,9 @@ const AutoCompleteAddress = ({
|
|
|
216
230
|
id="autocomplete"
|
|
217
231
|
data-cy="autocomplete"
|
|
218
232
|
type="text"
|
|
219
|
-
placeholder=
|
|
233
|
+
placeholder={
|
|
234
|
+
placeholders?.manualAddressEntry || 'Search for address'
|
|
235
|
+
}
|
|
220
236
|
ref={autocompleteElement}
|
|
221
237
|
/>
|
|
222
238
|
{hasLoadedGoogleAPI === false && (
|
|
@@ -227,12 +243,12 @@ const AutoCompleteAddress = ({
|
|
|
227
243
|
</div>
|
|
228
244
|
) : (
|
|
229
245
|
<>
|
|
230
|
-
<div className={`d-flex ${styles['input-line']}`}>
|
|
246
|
+
<div className={`d-flex c-gap16 ${styles['input-line']}`}>
|
|
231
247
|
<Input
|
|
232
248
|
className="w100"
|
|
233
249
|
data-cy="autocomplete"
|
|
234
250
|
type="text"
|
|
235
|
-
placeholder=
|
|
251
|
+
placeholder={placeholders?.street || 'Street'}
|
|
236
252
|
value={address?.street || ''}
|
|
237
253
|
onChange={(e) => {
|
|
238
254
|
const newAddress = {
|
|
@@ -247,7 +263,7 @@ const AutoCompleteAddress = ({
|
|
|
247
263
|
<Input
|
|
248
264
|
className={`wmx2 ${styles['house-number-input']}`}
|
|
249
265
|
data-cy="autocomplete-house-number"
|
|
250
|
-
placeholder=
|
|
266
|
+
placeholder={placeholders?.houseNumber || 'House Number'}
|
|
251
267
|
value={address?.houseNumber || ''}
|
|
252
268
|
onChange={(e) => {
|
|
253
269
|
const newAddress = {
|
|
@@ -263,7 +279,10 @@ const AutoCompleteAddress = ({
|
|
|
263
279
|
<Input
|
|
264
280
|
className="mt16"
|
|
265
281
|
data-cy="autocomplete-additional-info"
|
|
266
|
-
placeholder=
|
|
282
|
+
placeholder={
|
|
283
|
+
placeholders?.additionalInformation ||
|
|
284
|
+
'Additional information (C/O, apartment, …)'
|
|
285
|
+
}
|
|
267
286
|
value={address?.additionalInformation || ''}
|
|
268
287
|
onChange={(e) => {
|
|
269
288
|
const newAddress = {
|
|
@@ -274,11 +293,11 @@ const AutoCompleteAddress = ({
|
|
|
274
293
|
setAddress(newAddress);
|
|
275
294
|
}}
|
|
276
295
|
/>
|
|
277
|
-
<div className={`d-flex mt16 ${styles['input-line']}`}>
|
|
296
|
+
<div className={`d-flex mt16 c-gap16 ${styles['input-line']}`}>
|
|
278
297
|
<Input
|
|
279
298
|
className="w100"
|
|
280
299
|
data-cy="autocomplete-postcode"
|
|
281
|
-
placeholder=
|
|
300
|
+
placeholder={placeholders?.postcode || 'Postcode'}
|
|
282
301
|
value={address?.postcode || ''}
|
|
283
302
|
onChange={(e) => {
|
|
284
303
|
const newAddress = {
|
|
@@ -293,7 +312,7 @@ const AutoCompleteAddress = ({
|
|
|
293
312
|
<Input
|
|
294
313
|
className="w100"
|
|
295
314
|
data-cy="autocomplete-city"
|
|
296
|
-
placeholder=
|
|
315
|
+
placeholder={placeholders?.city || 'City'}
|
|
297
316
|
value={address?.city || ''}
|
|
298
317
|
onChange={(e) => {
|
|
299
318
|
const newAddress = {
|
|
@@ -311,12 +330,12 @@ const AutoCompleteAddress = ({
|
|
|
311
330
|
</div>
|
|
312
331
|
{manualAddressEntry === false && (
|
|
313
332
|
<div className="p-p mt8">
|
|
314
|
-
|
|
333
|
+
{manualAddressEntryTexts?.preText || 'Or '}
|
|
315
334
|
<span
|
|
316
335
|
className="p-a fw-bold c-pointer"
|
|
317
336
|
onClick={handleEnterAddressManually}
|
|
318
337
|
>
|
|
319
|
-
Enter address manually
|
|
338
|
+
{manualAddressEntryTexts?.cta || 'Enter address manually'}
|
|
320
339
|
</span>
|
|
321
340
|
</div>
|
|
322
341
|
)}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
@use "../../scss/public/colors" as *;
|
|
3
3
|
|
|
4
4
|
.input-line {
|
|
5
|
-
margin-left: -16px;
|
|
6
|
-
|
|
7
|
-
> * {
|
|
8
|
-
margin-left: 16px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
5
|
@include p-size-mobile {
|
|
12
6
|
flex-direction: column;
|
|
13
7
|
|
|
@@ -19,7 +13,7 @@
|
|
|
19
13
|
|
|
20
14
|
.house-number-input {
|
|
21
15
|
@include p-size-mobile {
|
|
22
|
-
max-width: none;
|
|
16
|
+
max-width: none !important;
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
19
|
|
|
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
|
|
2
2
|
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
3
3
|
|
|
4
4
|
import DateSelector from '.';
|
|
5
|
+
import de from 'dayjs/locale/de';
|
|
5
6
|
|
|
6
7
|
<Meta title="JSX/Date selector" component={DateSelector} />
|
|
7
8
|
|
|
@@ -60,3 +61,46 @@ export const DateSelectorWithCalendarStory = () => {
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
<DateSelectorWithCalendarStory />
|
|
64
|
+
|
|
65
|
+
### Localization
|
|
66
|
+
|
|
67
|
+
| attribute | unit | description | default value | required |
|
|
68
|
+
| -------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------- | -------- |
|
|
69
|
+
| placeholders | `{ day?: string; month: string?; year?: string; }` | Placeholder text | undefined | false |
|
|
70
|
+
| dayjsLocale | `ILocale` | Imported [Day.js locale Object](https://day.js.org/docs/en/customization/customization) | undefined | false |
|
|
71
|
+
| firstDayOfWeek | number | Index of the first day of the week (0 = Sunday, 1 = Monday, etc.) | 0 | false |
|
|
72
|
+
|
|
73
|
+
The `dayjsLocale` and `firstDayOfWeek` properties are used to localize the calendar of the `DateSelector`, whereas
|
|
74
|
+
the `placeholders` object can be used to change the text of the different dropdowns. If no `dayjsLocale` is supplied, the default locale 'en' will be used for the DateSelector.
|
|
75
|
+
|
|
76
|
+
Additional locales can be imported from dayjs like
|
|
77
|
+
`import de from 'dayjs/locale/de';` and then passed on to the component:
|
|
78
|
+
`<DateSelector ... dayjsLocale={de} />`
|
|
79
|
+
|
|
80
|
+
[List of all supported locales](https://github.com/iamkun/dayjs/tree/dev/src/locale)
|
|
81
|
+
|
|
82
|
+
export const DateSelectorWithCalendarLocalizedStory = () => {
|
|
83
|
+
const [date, setDate] = useState('');
|
|
84
|
+
return (
|
|
85
|
+
<div style={{ paddingBottom: '120px' }}>
|
|
86
|
+
<DateSelector
|
|
87
|
+
value={date}
|
|
88
|
+
className="mt24"
|
|
89
|
+
yearBoundaries={{ min: 2020, max: 2022 }}
|
|
90
|
+
onChange={(date) => {
|
|
91
|
+
setDate(date);
|
|
92
|
+
}}
|
|
93
|
+
displayCalendar={true}
|
|
94
|
+
placeholders={{
|
|
95
|
+
day: 'Tag',
|
|
96
|
+
month: 'Monat',
|
|
97
|
+
year: 'Jahr',
|
|
98
|
+
}}
|
|
99
|
+
dayjsLocale={de}
|
|
100
|
+
firstDayOfWeek={1}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
<DateSelectorWithCalendarLocalizedStory />
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
|
+
|
|
3
4
|
import localeData from 'dayjs/plugin/localeData';
|
|
4
5
|
import { CalendarDate } from '@popsure/public-models';
|
|
5
6
|
import DayPicker from 'react-day-picker';
|
|
@@ -13,7 +14,6 @@ import './datepicker.scss';
|
|
|
13
14
|
import calendarIcon from './icons/calendar.svg';
|
|
14
15
|
|
|
15
16
|
dayjs.extend(localeData);
|
|
16
|
-
|
|
17
17
|
const COLLECTABLE_DATE_FORMAT = 'YYYY-MM-DD';
|
|
18
18
|
|
|
19
19
|
/*
|
|
@@ -55,11 +55,21 @@ const DateSelector = ({
|
|
|
55
55
|
onChange,
|
|
56
56
|
yearBoundaries,
|
|
57
57
|
displayCalendar,
|
|
58
|
+
placeholders,
|
|
59
|
+
dayjsLocale,
|
|
60
|
+
firstDayOfWeek = 0,
|
|
58
61
|
}: {
|
|
59
62
|
value?: string;
|
|
60
63
|
onChange: (date: string) => void;
|
|
61
64
|
yearBoundaries: { min: number; max: number };
|
|
62
65
|
displayCalendar?: boolean;
|
|
66
|
+
placeholders?: {
|
|
67
|
+
day?: string;
|
|
68
|
+
month?: string;
|
|
69
|
+
year?: string;
|
|
70
|
+
};
|
|
71
|
+
dayjsLocale?: ILocale;
|
|
72
|
+
firstDayOfWeek?: number;
|
|
63
73
|
}) => {
|
|
64
74
|
const calendarDateValue = value ? isoStringtoCalendarDate(value) : undefined;
|
|
65
75
|
const daysInSelectedDate = calendarDateValue
|
|
@@ -68,9 +78,19 @@ const DateSelector = ({
|
|
|
68
78
|
year: calendarDateValue.year,
|
|
69
79
|
})
|
|
70
80
|
: 31;
|
|
81
|
+
|
|
82
|
+
const localeDate = dayjsLocale
|
|
83
|
+
? dayjs().locale(dayjsLocale).localeData()
|
|
84
|
+
: dayjs().locale('en').localeData();
|
|
85
|
+
|
|
86
|
+
const localizedWeekdays = localeDate.weekdays();
|
|
87
|
+
const localizedWeekdaysShort = localeDate.weekdaysShort();
|
|
88
|
+
const localizedMonths = localeDate.months();
|
|
89
|
+
const localizedMonthsShort = localeDate.monthsShort();
|
|
90
|
+
|
|
71
91
|
const availableDays = fillArray(1, daysInSelectedDate);
|
|
72
92
|
const availableYears = fillArray(yearBoundaries.max, yearBoundaries.min);
|
|
73
|
-
const availableMonths =
|
|
93
|
+
const availableMonths = localizedMonthsShort;
|
|
74
94
|
|
|
75
95
|
const [date, setDate] = useState<Partial<CalendarDate>>(
|
|
76
96
|
calendarDateValue ?? {}
|
|
@@ -154,7 +174,7 @@ const DateSelector = ({
|
|
|
154
174
|
}}
|
|
155
175
|
>
|
|
156
176
|
<option value="" disabled={true}>
|
|
157
|
-
Day
|
|
177
|
+
{placeholders?.day || 'Day'}
|
|
158
178
|
</option>
|
|
159
179
|
{availableDays.map((day) => (
|
|
160
180
|
<option key={day} value={day}>
|
|
@@ -174,7 +194,7 @@ const DateSelector = ({
|
|
|
174
194
|
}}
|
|
175
195
|
>
|
|
176
196
|
<option value="" disabled={true}>
|
|
177
|
-
Month
|
|
197
|
+
{placeholders?.month || 'Month'}
|
|
178
198
|
</option>
|
|
179
199
|
{availableMonths.map((month, i) => (
|
|
180
200
|
<option key={month} value={i + 1}>
|
|
@@ -195,7 +215,7 @@ const DateSelector = ({
|
|
|
195
215
|
}}
|
|
196
216
|
>
|
|
197
217
|
<option value="" disabled={true}>
|
|
198
|
-
Year
|
|
218
|
+
{placeholders?.year || 'Year'}
|
|
199
219
|
</option>
|
|
200
220
|
{availableYears.map((year) => (
|
|
201
221
|
<option key={year} value={year}>
|
|
@@ -236,6 +256,11 @@ const DateSelector = ({
|
|
|
236
256
|
before: dateCalendarFromMonth,
|
|
237
257
|
after: dateCalendarToMonth,
|
|
238
258
|
}}
|
|
259
|
+
firstDayOfWeek={firstDayOfWeek}
|
|
260
|
+
locale={dayjsLocale?.name || 'en'}
|
|
261
|
+
months={localizedMonths}
|
|
262
|
+
weekdaysLong={localizedWeekdays}
|
|
263
|
+
weekdaysShort={localizedWeekdaysShort}
|
|
239
264
|
/>
|
|
240
265
|
)}
|
|
241
266
|
</div>
|
|
@@ -95,10 +95,17 @@ body {
|
|
|
95
95
|
.p-a {
|
|
96
96
|
color: $ds-primary-500;
|
|
97
97
|
text-decoration: none;
|
|
98
|
+
|
|
98
99
|
&:hover,
|
|
99
100
|
&:focus {
|
|
100
101
|
color: $ds-primary-700;
|
|
101
102
|
}
|
|
103
|
+
|
|
104
|
+
&:focus-visible {
|
|
105
|
+
outline: 2px solid $ds-grey-900;
|
|
106
|
+
border-radius: 2px;
|
|
107
|
+
outline-offset: 2px;
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
// Layout
|
|
@@ -11,6 +11,10 @@ export const Typography = () => (
|
|
|
11
11
|
<h4 className="p-h4">The quick brown fox jumps over the lazy dog</h4>
|
|
12
12
|
<p className="p-p">The quick brown fox jumps over the lazy dog</p>
|
|
13
13
|
<p className="p-p--small">The quick brown fox jumps over the lazy dog</p>
|
|
14
|
+
<a href="#" className="p-a">
|
|
15
|
+
The quick brown fox jumps over the lazy dog
|
|
16
|
+
</a>
|
|
17
|
+
<p className="p-error">The quick brown fox jumps over the lazy dog</p>
|
|
14
18
|
</>
|
|
15
19
|
);
|
|
16
20
|
|
|
@@ -48,6 +48,8 @@ Dirty swan provides classes to override default heading.
|
|
|
48
48
|
<h4 class="p-h4">The quick brown fox jumps over the lazy dog</h4>
|
|
49
49
|
<p class="p-p">The quick brown fox jumps over the lazy dog</p>
|
|
50
50
|
<p class="p-p--small">The quick brown fox jumps over the lazy dog</p>
|
|
51
|
+
<a class="p-a">The quick brown fox jumps over the lazy dog</a>
|
|
52
|
+
<p class="p-error">The quick brown fox jumps over the lazy dog</p>
|
|
51
53
|
```
|
|
52
54
|
|
|
53
55
|
## Layout
|
|
@@ -69,3 +71,4 @@ Dirty swan provides classes to override default heading.
|
|
|
69
71
|
| ----------- | ------------------- |
|
|
70
72
|
| `fs-italic` | font-style: italic; |
|
|
71
73
|
| `fs-normal` | font-style: normal; |
|
|
74
|
+
|
|
@@ -94,10 +94,7 @@
|
|
|
94
94
|
.p-radio:checked {
|
|
95
95
|
& + label::before {
|
|
96
96
|
border-color: $ds-primary-500;
|
|
97
|
-
|
|
98
|
-
background-image: url('data:image/svg+xml;utf8,<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="6" cy="6" r="5.5" fill="#{util.url-encoded-color($ds-primary-500)}" /></svg>');
|
|
99
|
-
background-repeat: no-repeat;
|
|
100
|
-
background-position: center;
|
|
97
|
+
background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 20 20" stroke="white" stroke-width="4" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="50%" fill="#{util.url-encoded-color($ds-primary-500)}"/></svg>');
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
100
|
|
|
@@ -19,9 +19,9 @@ You can use the following helper within your sass code.
|
|
|
19
19
|
|
|
20
20
|
| Help | Range |
|
|
21
21
|
| ---------------- | ------- |
|
|
22
|
-
| `p-size-mobile` |
|
|
23
|
-
| `p-size-tablet` |
|
|
24
|
-
| `p-size-desktop` |
|
|
22
|
+
| `p-size-mobile` | <= 34rem |
|
|
23
|
+
| `p-size-tablet` | >= 34rem |
|
|
24
|
+
| `p-size-desktop` | >= 64rem |
|
|
25
25
|
|
|
26
26
|
### Example
|
|
27
27
|
|