@lumx/react 3.5.3 → 3.5.4-alpha-remove-moment-repack.0
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/_internal/00d05efa.js +111 -0
- package/_internal/00d05efa.js.map +1 -0
- package/_internal/0110d951.js +168 -0
- package/_internal/0110d951.js.map +1 -0
- package/_internal/063bb3df.js +33 -0
- package/_internal/063bb3df.js.map +1 -0
- package/_internal/0d8b4e37.d.ts +106 -0
- package/_internal/0da969e1.d.ts +45 -0
- package/_internal/1098ba6a.js +26 -0
- package/_internal/1098ba6a.js.map +1 -0
- package/_internal/1252e3a1.js +108 -0
- package/_internal/1252e3a1.js.map +1 -0
- package/_internal/135ee91f.d.ts +32 -0
- package/_internal/13603836.js +13 -0
- package/_internal/13603836.js.map +1 -0
- package/_internal/15e9a271.d.ts +26 -0
- package/_internal/188706f1.d.ts +107 -0
- package/_internal/1e67557e.d.ts +31 -0
- package/_internal/1ee4fa8c.js +85 -0
- package/_internal/1ee4fa8c.js.map +1 -0
- package/_internal/209d0906.js +56 -0
- package/_internal/209d0906.js.map +1 -0
- package/_internal/22b8c949.d.ts +57 -0
- package/_internal/23b03795.js +115 -0
- package/_internal/23b03795.js.map +1 -0
- package/_internal/25352357.d.ts +51 -0
- package/_internal/{types.d.ts → 28b656e3.d.ts} +1 -1
- package/_internal/2bd12321.d.ts +22 -0
- package/_internal/2c279dd8.d.ts +49 -0
- package/_internal/2d7bd818.js +147 -0
- package/_internal/2d7bd818.js.map +1 -0
- package/_internal/2db3ca7a.js +221 -0
- package/_internal/2db3ca7a.js.map +1 -0
- package/_internal/2e0ba45f.js +182 -0
- package/_internal/2e0ba45f.js.map +1 -0
- package/_internal/2e6810c5.js +240 -0
- package/_internal/2e6810c5.js.map +1 -0
- package/_internal/2ed577d6.d.ts +37 -0
- package/_internal/31235bda.js +133 -0
- package/_internal/31235bda.js.map +1 -0
- package/_internal/339a4cb6.d.ts +106 -0
- package/_internal/35c3a78f.js +374 -0
- package/_internal/35c3a78f.js.map +1 -0
- package/_internal/3669449c.js +135 -0
- package/_internal/3669449c.js.map +1 -0
- package/_internal/39790d2a.d.ts +52 -0
- package/_internal/3bfda595.d.ts +62 -0
- package/_internal/3f5e7653.js +205 -0
- package/_internal/3f5e7653.js.map +1 -0
- package/_internal/43bf2236.js +189 -0
- package/_internal/43bf2236.js.map +1 -0
- package/_internal/43c20e1c.js +64 -0
- package/_internal/43c20e1c.js.map +1 -0
- package/_internal/45349a37.js +78 -0
- package/_internal/45349a37.js.map +1 -0
- package/_internal/48725bae.js +61 -0
- package/_internal/48725bae.js.map +1 -0
- package/_internal/4a5eff83.js +149 -0
- package/_internal/4a5eff83.js.map +1 -0
- package/_internal/4f5a23d0.js +74 -0
- package/_internal/4f5a23d0.js.map +1 -0
- package/_internal/50472283.js +219 -0
- package/_internal/50472283.js.map +1 -0
- package/_internal/506e7420.js +805 -0
- package/_internal/506e7420.js.map +1 -0
- package/_internal/51585e5d.d.ts +31 -0
- package/_internal/52976f60.js +123 -0
- package/_internal/52976f60.js.map +1 -0
- package/_internal/53abf616.js +112 -0
- package/_internal/53abf616.js.map +1 -0
- package/_internal/561b93a4.js +132 -0
- package/_internal/561b93a4.js.map +1 -0
- package/_internal/56827efd.js +306 -0
- package/_internal/56827efd.js.map +1 -0
- package/_internal/58085542.js +132 -0
- package/_internal/58085542.js.map +1 -0
- package/_internal/5d582985.js +55 -0
- package/_internal/5d582985.js.map +1 -0
- package/_internal/5df3d4a3.d.ts +192 -0
- package/_internal/5eac291f.js +52 -0
- package/_internal/5eac291f.js.map +1 -0
- package/_internal/5ebec897.d.ts +69 -0
- package/_internal/62a51bc3.js +73 -0
- package/_internal/62a51bc3.js.map +1 -0
- package/_internal/648a40d4.js +140 -0
- package/_internal/648a40d4.js.map +1 -0
- package/_internal/6726fa56.js +113 -0
- package/_internal/6726fa56.js.map +1 -0
- package/_internal/687128ab.js +60 -0
- package/_internal/687128ab.js.map +1 -0
- package/_internal/69ec8e49.js +2130 -0
- package/_internal/69ec8e49.js.map +1 -0
- package/_internal/6a084cc0.js +154 -0
- package/_internal/6a084cc0.js.map +1 -0
- package/_internal/6b6c99f5.d.ts +59 -0
- package/_internal/6f0b1d1c.js +100 -0
- package/_internal/6f0b1d1c.js.map +1 -0
- package/_internal/717ab5c2.d.ts +33 -0
- package/_internal/71e8fb5e.d.ts +54 -0
- package/_internal/72b3a542.js +75 -0
- package/_internal/72b3a542.js.map +1 -0
- package/_internal/73d02a65.js +338 -0
- package/_internal/73d02a65.js.map +1 -0
- package/_internal/757216a1.js +80 -0
- package/_internal/757216a1.js.map +1 -0
- package/_internal/7641c1e4.js +49 -0
- package/_internal/7641c1e4.js.map +1 -0
- package/_internal/782f6fbb.js +94 -0
- package/_internal/782f6fbb.js.map +1 -0
- package/_internal/787d5d09.js +450 -0
- package/_internal/787d5d09.js.map +1 -0
- package/_internal/79b3f9aa.d.ts +22 -0
- package/_internal/7b8c2b80.js +113 -0
- package/_internal/7b8c2b80.js.map +1 -0
- package/_internal/7c07908e.d.ts +34 -0
- package/_internal/7d468bfd.d.ts +75 -0
- package/_internal/834ad334.js +25 -0
- package/_internal/834ad334.js.map +1 -0
- package/_internal/83dab2b2.js +22 -0
- package/_internal/83dab2b2.js.map +1 -0
- package/_internal/899e4acd.js +60 -0
- package/_internal/899e4acd.js.map +1 -0
- package/_internal/89fd6c7c.js +112 -0
- package/_internal/89fd6c7c.js.map +1 -0
- package/_internal/8aeb24dd.d.ts +24 -0
- package/_internal/8c7450ba.d.ts +35 -0
- package/_internal/8ea3ecc2.d.ts +46 -0
- package/_internal/8efb9d06.js +807 -0
- package/_internal/8efb9d06.js.map +1 -0
- package/_internal/93943ac3.d.ts +37 -0
- package/_internal/96ac5af6.d.ts +47 -0
- package/_internal/975a94f4.js +88 -0
- package/_internal/975a94f4.js.map +1 -0
- package/_internal/9784d7f8.js +283 -0
- package/_internal/9784d7f8.js.map +1 -0
- package/_internal/97e802dc.d.ts +66 -0
- package/_internal/9b9393ee.d.ts +29 -0
- package/_internal/9dced38c.js +284 -0
- package/_internal/9dced38c.js.map +1 -0
- package/_internal/a07fe032.d.ts +57 -0
- package/_internal/a08b82a3.d.ts +31 -0
- package/_internal/a106724b.d.ts +43 -0
- package/_internal/a7807be3.js +120 -0
- package/_internal/a7807be3.js.map +1 -0
- package/_internal/a79b2c62.js +60 -0
- package/_internal/a79b2c62.js.map +1 -0
- package/_internal/a7b06ff0.d.ts +16 -0
- package/_internal/a8af376d.d.ts +35 -0
- package/_internal/abdb0290.d.ts +35 -0
- package/_internal/adb2e104.d.ts +101 -0
- package/_internal/b13105c1.d.ts +38 -0
- package/_internal/b3361376.d.ts +55 -0
- package/_internal/b3bb0cc4.d.ts +92 -0
- package/_internal/b447833b.d.ts +24 -0
- package/_internal/b5deecfd.d.ts +64 -0
- package/_internal/b70adcf7.js +310 -0
- package/_internal/b70adcf7.js.map +1 -0
- package/_internal/b7128df5.js +137 -0
- package/_internal/b7128df5.js.map +1 -0
- package/_internal/baf84dac.js +29 -0
- package/_internal/baf84dac.js.map +1 -0
- package/_internal/bd3b5639.d.ts +183 -0
- package/_internal/bf97c97c.js +112 -0
- package/_internal/bf97c97c.js.map +1 -0
- package/_internal/c1482714.js +63 -0
- package/_internal/c1482714.js.map +1 -0
- package/_internal/c498efeb.js +12 -0
- package/_internal/c498efeb.js.map +1 -0
- package/_internal/c672b554.d.ts +87 -0
- package/_internal/c70420da.js +120 -0
- package/_internal/c70420da.js.map +1 -0
- package/_internal/ce96edec.d.ts +41 -0
- package/_internal/cf2cb6bc.d.ts +22 -0
- package/_internal/cf312aff.d.ts +38 -0
- package/_internal/cfd18b6d.js +88 -0
- package/_internal/cfd18b6d.js.map +1 -0
- package/_internal/components/alert-dialog.d.ts +6 -0
- package/_internal/components/alert-dialog.js +2 -0
- package/_internal/components/alert-dialog.js.map +1 -0
- package/_internal/components/autocomplete.d.ts +10 -0
- package/_internal/components/autocomplete.js +2 -0
- package/_internal/components/autocomplete.js.map +1 -0
- package/_internal/components/avatar.d.ts +4 -0
- package/_internal/components/avatar.js +2 -0
- package/_internal/components/avatar.js.map +1 -0
- package/_internal/components/badge.d.ts +3 -0
- package/_internal/components/badge.js +2 -0
- package/_internal/components/badge.js.map +1 -0
- package/_internal/components/button.d.ts +8 -0
- package/_internal/components/button.js +4 -0
- package/_internal/components/button.js.map +1 -0
- package/_internal/components/checkbox.d.ts +3 -0
- package/_internal/components/checkbox.js +2 -0
- package/_internal/components/checkbox.js.map +1 -0
- package/_internal/components/chip.d.ts +3 -0
- package/_internal/components/chip.js +3 -0
- package/_internal/components/chip.js.map +1 -0
- package/_internal/components/comment-block.d.ts +5 -0
- package/_internal/components/comment-block.js +2 -0
- package/_internal/components/comment-block.js.map +1 -0
- package/_internal/components/date-picker.d.ts +7 -0
- package/_internal/components/date-picker.js +2 -0
- package/_internal/components/date-picker.js.map +1 -0
- package/_internal/components/dialog.d.ts +3 -0
- package/_internal/components/dialog.js +2 -0
- package/_internal/components/dialog.js.map +1 -0
- package/_internal/components/divider.d.ts +3 -0
- package/_internal/components/divider.js +2 -0
- package/_internal/components/divider.js.map +1 -0
- package/_internal/components/drag-handle.d.ts +3 -0
- package/_internal/components/drag-handle.js +2 -0
- package/_internal/components/drag-handle.js.map +1 -0
- package/_internal/components/dropdown.d.ts +5 -0
- package/_internal/components/dropdown.js +2 -0
- package/_internal/components/dropdown.js.map +1 -0
- package/_internal/components/expansion-panel.d.ts +7 -0
- package/_internal/components/expansion-panel.js +2 -0
- package/_internal/components/expansion-panel.js.map +1 -0
- package/_internal/components/flag.d.ts +3 -0
- package/_internal/components/flag.js +2 -0
- package/_internal/components/flag.js.map +1 -0
- package/_internal/components/flex-box.d.ts +3 -0
- package/_internal/components/flex-box.js +2 -0
- package/_internal/components/flex-box.js.map +1 -0
- package/_internal/components/generic-block.d.ts +4 -0
- package/_internal/components/generic-block.js +2 -0
- package/_internal/components/generic-block.js.map +1 -0
- package/_internal/components/grid-column.d.ts +3 -0
- package/_internal/components/grid-column.js +2 -0
- package/_internal/components/grid-column.js.map +1 -0
- package/_internal/components/grid.d.ts +3 -0
- package/_internal/components/grid.js +2 -0
- package/_internal/components/grid.js.map +1 -0
- package/_internal/components/heading.d.ts +4 -0
- package/_internal/components/heading.js +2 -0
- package/_internal/components/heading.js.map +1 -0
- package/_internal/components/icon.d.ts +3 -0
- package/_internal/components/icon.js +2 -0
- package/_internal/components/icon.js.map +1 -0
- package/_internal/components/image-block.d.ts +4 -0
- package/_internal/components/image-block.js +2 -0
- package/_internal/components/image-block.js.map +1 -0
- package/_internal/components/inline-list.d.ts +3 -0
- package/_internal/components/inline-list.js +2 -0
- package/_internal/components/inline-list.js.map +1 -0
- package/_internal/components/input-helper.d.ts +3 -0
- package/_internal/components/input-helper.js +2 -0
- package/_internal/components/input-helper.js.map +1 -0
- package/_internal/components/input-label.d.ts +3 -0
- package/_internal/components/input-label.js +2 -0
- package/_internal/components/input-label.js.map +1 -0
- package/_internal/components/lightbox.d.ts +7 -0
- package/_internal/components/lightbox.js +2 -0
- package/_internal/components/lightbox.js.map +1 -0
- package/_internal/components/link-preview.d.ts +5 -0
- package/_internal/components/link-preview.js +2 -0
- package/_internal/components/link-preview.js.map +1 -0
- package/_internal/components/link.d.ts +3 -0
- package/_internal/components/link.js +2 -0
- package/_internal/components/link.js.map +1 -0
- package/_internal/components/list.d.ts +3 -0
- package/_internal/components/list.js +3 -0
- package/_internal/components/list.js.map +1 -0
- package/_internal/components/message.d.ts +3 -0
- package/_internal/components/message.js +2 -0
- package/_internal/components/message.js.map +1 -0
- package/_internal/components/mosaic.d.ts +4 -0
- package/_internal/components/mosaic.js +2 -0
- package/_internal/components/mosaic.js.map +1 -0
- package/_internal/components/navigation.d.ts +3 -0
- package/_internal/components/navigation.js +2 -0
- package/_internal/components/navigation.js.map +1 -0
- package/_internal/components/notification.d.ts +3 -0
- package/_internal/components/notification.js +2 -0
- package/_internal/components/notification.js.map +1 -0
- package/_internal/components/popover.d.ts +4 -0
- package/_internal/components/popover.js +3 -0
- package/_internal/components/popover.js.map +1 -0
- package/_internal/components/post-block.d.ts +4 -0
- package/_internal/components/post-block.js +2 -0
- package/_internal/components/post-block.js.map +1 -0
- package/_internal/components/progress-tracker.d.ts +3 -0
- package/_internal/components/progress-tracker.js +2 -0
- package/_internal/components/progress-tracker.js.map +1 -0
- package/_internal/components/progress.d.ts +3 -0
- package/_internal/components/progress.js +2 -0
- package/_internal/components/progress.js.map +1 -0
- package/_internal/components/radio-button.d.ts +3 -0
- package/_internal/components/radio-button.js +2 -0
- package/_internal/components/radio-button.js.map +1 -0
- package/_internal/components/select.d.ts +7 -0
- package/_internal/components/select.js +2 -0
- package/_internal/components/select.js.map +1 -0
- package/_internal/components/side-navigation.d.ts +7 -0
- package/_internal/components/side-navigation.js +2 -0
- package/_internal/components/side-navigation.js.map +1 -0
- package/_internal/components/skeleton.d.ts +3 -0
- package/_internal/components/skeleton.js +2 -0
- package/_internal/components/skeleton.js.map +1 -0
- package/_internal/components/slider.d.ts +3 -0
- package/_internal/components/slider.js +2 -0
- package/_internal/components/slider.js.map +1 -0
- package/_internal/components/slideshow.d.ts +7 -0
- package/_internal/components/slideshow.js +2 -0
- package/_internal/components/slideshow.js.map +1 -0
- package/_internal/components/switch.d.ts +3 -0
- package/_internal/components/switch.js +2 -0
- package/_internal/components/switch.js.map +1 -0
- package/_internal/components/table.d.ts +3 -0
- package/_internal/components/table.js +2 -0
- package/_internal/components/table.js.map +1 -0
- package/_internal/components/tabs.d.ts +4 -0
- package/_internal/components/tabs.js +2 -0
- package/_internal/components/tabs.js.map +1 -0
- package/_internal/components/text-field.d.ts +7 -0
- package/_internal/components/text-field.js +2 -0
- package/_internal/components/text-field.js.map +1 -0
- package/_internal/components/text.d.ts +3 -0
- package/_internal/components/text.js +2 -0
- package/_internal/components/text.js.map +1 -0
- package/_internal/components/thumbnail.d.ts +4 -0
- package/_internal/components/thumbnail.js +3 -0
- package/_internal/components/thumbnail.js.map +1 -0
- package/_internal/components/toolbar.d.ts +3 -0
- package/_internal/components/toolbar.js +2 -0
- package/_internal/components/toolbar.js.map +1 -0
- package/_internal/components/tooltip.d.ts +4 -0
- package/_internal/components/tooltip.js +2 -0
- package/_internal/components/tooltip.js.map +1 -0
- package/_internal/components/uploader.d.ts +3 -0
- package/_internal/components/uploader.js +2 -0
- package/_internal/components/uploader.js.map +1 -0
- package/_internal/components/user-block.d.ts +5 -0
- package/_internal/components/user-block.js +2 -0
- package/_internal/components/user-block.js.map +1 -0
- package/_internal/d0ab9418.js +217 -0
- package/_internal/d0ab9418.js.map +1 -0
- package/_internal/d182fae6.js +402 -0
- package/_internal/d182fae6.js.map +1 -0
- package/_internal/d18db1a2.d.ts +17 -0
- package/_internal/d39f1e46.d.ts +65 -0
- package/_internal/d737c470.js +312 -0
- package/_internal/d737c470.js.map +1 -0
- package/_internal/d894ca99.d.ts +49 -0
- package/_internal/da84387d.d.ts +36 -0
- package/_internal/dbee763e.d.ts +34 -0
- package/_internal/dd592f2c.d.ts +6 -0
- package/_internal/de727831.d.ts +17 -0
- package/_internal/df1fde7b.js +125 -0
- package/_internal/df1fde7b.js.map +1 -0
- package/_internal/e238e75a.d.ts +20 -0
- package/_internal/e50751c9.js +259 -0
- package/_internal/e50751c9.js.map +1 -0
- package/_internal/e986d261.js +84 -0
- package/_internal/e986d261.js.map +1 -0
- package/_internal/ebe0cef1.d.ts +88 -0
- package/_internal/ef7b6d28.d.ts +43 -0
- package/_internal/f0bb348a.js +49 -0
- package/_internal/f0bb348a.js.map +1 -0
- package/_internal/f0edbfd3.js +399 -0
- package/_internal/f0edbfd3.js.map +1 -0
- package/_internal/f722684a.js +137 -0
- package/_internal/f722684a.js.map +1 -0
- package/_internal/{ClickAwayProvider.js → f82d943d.js} +1 -1
- package/_internal/f82d943d.js.map +1 -0
- package/_internal/f99a63fb.d.ts +118 -0
- package/_internal/fc608bd9.js +16 -0
- package/_internal/fc608bd9.js.map +1 -0
- package/_internal/ff6c8991.js +180 -0
- package/_internal/ff6c8991.js.map +1 -0
- package/index.d.ts +63 -2847
- package/index.js +97 -13086
- package/index.js.map +1 -1
- package/package.json +3 -5
- package/src/components/date-picker/DatePicker.stories.tsx +38 -0
- package/src/components/date-picker/DatePicker.tsx +8 -11
- package/src/components/date-picker/DatePickerControlled.tsx +35 -43
- package/src/components/date-picker/DatePickerField.stories.tsx +0 -1
- package/src/components/date-picker/DatePickerField.tsx +7 -8
- package/src/components/date-picker/types.ts +1 -1
- package/src/utils/date/addMonthResetDay.test.ts +13 -0
- package/src/utils/date/addMonthResetDay.ts +9 -0
- package/src/utils/date/formatDate.ts +9 -0
- package/src/utils/date/formatDayNumber.ts +2 -0
- package/src/utils/date/formatMonthYear.ts +5 -0
- package/src/utils/date/getFirstDayOfWeek.test.ts +27 -0
- package/src/utils/date/getFirstDayOfWeek.ts +59 -0
- package/src/utils/date/getMonthCalendar.test.ts +119 -0
- package/src/utils/date/getMonthCalendar.ts +52 -0
- package/src/utils/date/getWeekDays.test.ts +52 -0
- package/src/utils/date/getWeekDays.ts +32 -0
- package/src/utils/date/isDateValid.test.ts +15 -0
- package/src/utils/date/isDateValid.ts +4 -0
- package/src/utils/date/isSameDay.test.ts +27 -0
- package/src/utils/date/isSameDay.ts +7 -0
- package/src/utils/locale/getCurrentLocale.ts +4 -0
- package/src/utils/locale/getLocaleLang.ts +5 -0
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
- package/_internal/ClickAwayProvider.js.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { h as Typography, g as getRootClassName, _ as _objectWithoutProperties, a as _extends, c as classnames } from './35c3a78f.js';
|
|
2
|
+
import React, { createContext, forwardRef } from 'react';
|
|
3
|
+
import { h as handleBasicClasses } from './3f5e7653.js';
|
|
4
|
+
import { T as Text } from './757216a1.js';
|
|
5
|
+
|
|
6
|
+
/** The maximum authorized heading level. */
|
|
7
|
+
const MAX_HEADING_LEVEL = 6;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Typography to use by default depending on the heading level.
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_TYPOGRAPHY_BY_LEVEL = {
|
|
13
|
+
h1: Typography.display1,
|
|
14
|
+
h2: Typography.headline,
|
|
15
|
+
h3: Typography.title,
|
|
16
|
+
h4: Typography.subtitle2,
|
|
17
|
+
h5: Typography.subtitle1,
|
|
18
|
+
h6: Typography.body2
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const defaultContext = {
|
|
22
|
+
level: 1,
|
|
23
|
+
headingElement: 'h1'
|
|
24
|
+
};
|
|
25
|
+
const HeadingLevelContext = /*#__PURE__*/createContext(defaultContext);
|
|
26
|
+
|
|
27
|
+
const useHeadingLevel = () => {
|
|
28
|
+
const {
|
|
29
|
+
level = 1,
|
|
30
|
+
headingElement = 'h1'
|
|
31
|
+
} = React.useContext(HeadingLevelContext);
|
|
32
|
+
return {
|
|
33
|
+
level,
|
|
34
|
+
headingElement
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const _excluded = ["children", "as", "className"];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Defines the props of the component.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Component display name.
|
|
46
|
+
*/
|
|
47
|
+
const COMPONENT_NAME = 'Heading';
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Component default class name and class prefix.
|
|
51
|
+
*/
|
|
52
|
+
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Component default props.
|
|
56
|
+
*/
|
|
57
|
+
const DEFAULT_PROPS = {};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Renders a heading component.
|
|
61
|
+
* Extends the `Text` Component with the heading level automatically computed based on
|
|
62
|
+
* the current level provided by the context.
|
|
63
|
+
*/
|
|
64
|
+
const Heading = /*#__PURE__*/forwardRef((props, ref) => {
|
|
65
|
+
const {
|
|
66
|
+
children,
|
|
67
|
+
as,
|
|
68
|
+
className
|
|
69
|
+
} = props,
|
|
70
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
71
|
+
const {
|
|
72
|
+
headingElement
|
|
73
|
+
} = useHeadingLevel();
|
|
74
|
+
return /*#__PURE__*/React.createElement(Text, _extends({
|
|
75
|
+
ref: ref,
|
|
76
|
+
className: classnames(className, handleBasicClasses({
|
|
77
|
+
prefix: CLASSNAME
|
|
78
|
+
})),
|
|
79
|
+
as: as || headingElement,
|
|
80
|
+
typography: DEFAULT_TYPOGRAPHY_BY_LEVEL[headingElement]
|
|
81
|
+
}, forwardedProps), children);
|
|
82
|
+
});
|
|
83
|
+
Heading.displayName = COMPONENT_NAME;
|
|
84
|
+
Heading.className = CLASSNAME;
|
|
85
|
+
Heading.defaultProps = DEFAULT_PROPS;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Provide a new heading level context.
|
|
89
|
+
*/
|
|
90
|
+
const HeadingLevelProvider = _ref => {
|
|
91
|
+
let {
|
|
92
|
+
children,
|
|
93
|
+
level
|
|
94
|
+
} = _ref;
|
|
95
|
+
const {
|
|
96
|
+
level: contextLevel
|
|
97
|
+
} = useHeadingLevel();
|
|
98
|
+
const incrementedLevel = level || contextLevel + 1;
|
|
99
|
+
/** Don't allow a level beyond the maximum level. */
|
|
100
|
+
const nextLevel = incrementedLevel > MAX_HEADING_LEVEL ? MAX_HEADING_LEVEL : incrementedLevel;
|
|
101
|
+
const headingElement = `h${nextLevel}`;
|
|
102
|
+
return /*#__PURE__*/React.createElement(HeadingLevelContext.Provider, {
|
|
103
|
+
value: {
|
|
104
|
+
level: nextLevel,
|
|
105
|
+
headingElement
|
|
106
|
+
}
|
|
107
|
+
}, children);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { Heading as H, HeadingLevelProvider as a, useHeadingLevel as u };
|
|
111
|
+
//# sourceMappingURL=00d05efa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"00d05efa.js","sources":["../../src/components/heading/constants.ts","../../src/components/heading/context.tsx","../../src/components/heading/useHeadingLevel.tsx","../../src/components/heading/Heading.tsx","../../src/components/heading/HeadingLevelProvider.tsx"],"sourcesContent":["import { Typography } from '..';\n\n/** The maximum authorized heading level. */\nexport const MAX_HEADING_LEVEL = 6;\n\n/**\n * Typography to use by default depending on the heading level.\n */\nexport const DEFAULT_TYPOGRAPHY_BY_LEVEL = {\n h1: Typography.display1,\n h2: Typography.headline,\n h3: Typography.title,\n h4: Typography.subtitle2,\n h5: Typography.subtitle1,\n h6: Typography.body2,\n};\n","import { HeadingElement } from '@lumx/react/utils/type';\nimport { createContext } from 'react';\n\ninterface HeadingLevelContext {\n /** The current level */\n level: number;\n /** The heading element matching the current level */\n headingElement: HeadingElement;\n}\n\nconst defaultContext: HeadingLevelContext = { level: 1, headingElement: 'h1' };\n\nexport const HeadingLevelContext = createContext<HeadingLevelContext>(defaultContext);\n","import React from 'react';\nimport { HeadingLevelContext } from './context';\n\nexport const useHeadingLevel = () => {\n const { level = 1, headingElement = 'h1' } = React.useContext(HeadingLevelContext);\n\n return { level, headingElement };\n};\n","import { Comp, HeadingElement } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';\nimport classNames from 'classnames';\nimport React, { forwardRef } from 'react';\nimport { Text, TextProps } from '../text';\nimport { DEFAULT_TYPOGRAPHY_BY_LEVEL } from './constants';\nimport { useHeadingLevel } from './useHeadingLevel';\n\n/**\n * Defines the props of the component.\n */\nexport interface HeadingProps extends Partial<TextProps> {\n /**\n * Display a specific heading level instead of the one provided by parent context provider.\n */\n as?: HeadingElement;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Heading';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS = {} as const;\n\n/**\n * Renders a heading component.\n * Extends the `Text` Component with the heading level automatically computed based on\n * the current level provided by the context.\n */\nexport const Heading: Comp<HeadingProps> = forwardRef((props, ref) => {\n const { children, as, className, ...forwardedProps } = props;\n const { headingElement } = useHeadingLevel();\n\n return (\n <Text\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n as={as || headingElement}\n typography={DEFAULT_TYPOGRAPHY_BY_LEVEL[headingElement]}\n {...forwardedProps}\n >\n {children}\n </Text>\n );\n});\n\nHeading.displayName = COMPONENT_NAME;\nHeading.className = CLASSNAME;\nHeading.defaultProps = DEFAULT_PROPS;\n","import { HeadingElement } from '@lumx/react/utils/type';\nimport React, { ReactNode } from 'react';\nimport { MAX_HEADING_LEVEL } from './constants';\nimport { HeadingLevelContext } from './context';\nimport { useHeadingLevel } from './useHeadingLevel';\n\nexport interface HeadingLevelProviderProps {\n /** The heading level to start at. If left undefined, the parent context will be used, if any. */\n level?: number;\n /** The children to display */\n children: ReactNode;\n}\n\n/**\n * Provide a new heading level context.\n */\nexport const HeadingLevelProvider: React.FC<HeadingLevelProviderProps> = ({ children, level }) => {\n const { level: contextLevel } = useHeadingLevel();\n\n const incrementedLevel = level || contextLevel + 1;\n /** Don't allow a level beyond the maximum level. */\n const nextLevel = incrementedLevel > MAX_HEADING_LEVEL ? MAX_HEADING_LEVEL : incrementedLevel;\n const headingElement = `h${nextLevel}` as HeadingElement;\n\n return (\n <HeadingLevelContext.Provider value={{ level: nextLevel, headingElement }}>\n {children}\n </HeadingLevelContext.Provider>\n );\n};\n"],"names":["MAX_HEADING_LEVEL","DEFAULT_TYPOGRAPHY_BY_LEVEL","h1","Typography","display1","h2","headline","h3","title","h4","subtitle2","h5","subtitle1","h6","body2","defaultContext","level","headingElement","HeadingLevelContext","createContext","useHeadingLevel","React","useContext","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","Heading","forwardRef","props","ref","children","as","className","forwardedProps","_objectWithoutProperties","_excluded","createElement","Text","_extends","classNames","handleBasicClasses","prefix","typography","displayName","defaultProps","HeadingLevelProvider","_ref","contextLevel","incrementedLevel","nextLevel","Provider","value"],"mappings":";;;;;AAEA;AACO,MAAMA,iBAAiB,GAAG,CAAC;;AAElC;AACA;AACA;AACO,MAAMC,2BAA2B,GAAG;EACvCC,EAAE,EAAEC,UAAU,CAACC,QAAQ;EACvBC,EAAE,EAAEF,UAAU,CAACG,QAAQ;EACvBC,EAAE,EAAEJ,UAAU,CAACK,KAAK;EACpBC,EAAE,EAAEN,UAAU,CAACO,SAAS;EACxBC,EAAE,EAAER,UAAU,CAACS,SAAS;EACxBC,EAAE,EAAEV,UAAU,CAACW;AACnB,CAAC;;ACLD,MAAMC,cAAmC,GAAG;EAAEC,KAAK,EAAE,CAAC;EAAEC,cAAc,EAAE;AAAK,CAAC;AAEvE,MAAMC,mBAAmB,gBAAGC,aAAa,CAAsBJ,cAAc,CAAC;;MCTxEK,eAAe,GAAGA,MAAM;EACjC,MAAM;IAAEJ,KAAK,GAAG,CAAC;IAAEC,cAAc,GAAG;GAAM,GAAGI,KAAK,CAACC,UAAU,CAACJ,mBAAmB,CAAC;EAElF,OAAO;IAAEF,KAAK;IAAEC;GAAgB;AACpC;;;;ACCA;AACA;AACA;;AAQA;AACA;AACA;AACA,MAAMM,cAAc,GAAG,SAAS;;AAEhC;AACA;AACA;AACA,MAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAc,CAAC;;AAElD;AACA;AACA;AACA,MAAMG,aAAa,GAAG,EAAW;;AAEjC;AACA;AACA;AACA;AACA;MACaC,OAA2B,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAClE,MAAM;MAAEC,QAAQ;MAAEC,EAAE;MAAEC;KAA8B,GAAGJ,KAAK;IAAxBK,cAAc,GAAAC,wBAAA,CAAKN,KAAK,EAAAO,SAAA;EAC5D,MAAM;IAAEnB;GAAgB,GAAGG,eAAe,EAAE;EAE5C,oBACIC,KAAA,CAAAgB,aAAA,CAACC,IAAI,EAAAC,QAAA;IACDT,GAAG,EAAEA,GAAI;IACTG,SAAS,EAAEO,UAAU,CACjBP,SAAS,EACTQ,kBAAkB,CAAC;MACfC,MAAM,EAAElB;KACX,CACL,CAAE;IACFQ,EAAE,EAAEA,EAAE,IAAIf,cAAe;IACzB0B,UAAU,EAAE1C,2BAA2B,CAACgB,cAAc;KAClDiB,cAAc,GAEjBH,QACC,CAAC;AAEf,CAAC;AAEDJ,OAAO,CAACiB,WAAW,GAAGrB,cAAc;AACpCI,OAAO,CAACM,SAAS,GAAGT,SAAS;AAC7BG,OAAO,CAACkB,YAAY,GAAGnB,aAAa;;ACjDpC;AACA;AACA;MACaoB,oBAAyD,GAAGC,IAAA,IAAyB;EAAA,IAAxB;IAAEhB,QAAQ;IAAEf;GAAO,GAAA+B,IAAA;EACzF,MAAM;IAAE/B,KAAK,EAAEgC;GAAc,GAAG5B,eAAe,EAAE;EAEjD,MAAM6B,gBAAgB,GAAGjC,KAAK,IAAIgC,YAAY,GAAG,CAAC;;EAElD,MAAME,SAAS,GAAGD,gBAAgB,GAAGjD,iBAAiB,GAAGA,iBAAiB,GAAGiD,gBAAgB;EAC7F,MAAMhC,cAAc,GAAI,IAAGiC,SAAU,EAAmB;EAExD,oBACI7B,KAAA,CAAAgB,aAAA,CAACnB,mBAAmB,CAACiC,QAAQ;IAACC,KAAK,EAAE;MAAEpC,KAAK,EAAEkC,SAAS;MAAEjC;;KACpDc,QACyB,CAAC;AAEvC;;;;"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { D as DOCUMENT } from './c498efeb.js';
|
|
3
|
+
import { b as onEscapePressed } from './3f5e7653.js';
|
|
4
|
+
import last from 'lodash/last';
|
|
5
|
+
import { g as getFocusableElements } from './13603836.js';
|
|
6
|
+
import pull from 'lodash/pull';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get first and last elements focusable in an element.
|
|
10
|
+
*
|
|
11
|
+
* @param parentElement The element in which to search focusable elements.
|
|
12
|
+
* @return first and last focusable elements
|
|
13
|
+
*/
|
|
14
|
+
function getFirstAndLastFocusable(parentElement) {
|
|
15
|
+
const focusableElements = getFocusableElements(parentElement);
|
|
16
|
+
|
|
17
|
+
// First non disabled element.
|
|
18
|
+
const first = focusableElements[0];
|
|
19
|
+
// Last non disabled element.
|
|
20
|
+
const last = focusableElements[focusableElements.length - 1];
|
|
21
|
+
if (last && first) {
|
|
22
|
+
return {
|
|
23
|
+
first,
|
|
24
|
+
last
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Keep track of listeners, only the last registered listener gets activated at any point (previously registered
|
|
32
|
+
* listener are disabled).
|
|
33
|
+
* When a listener gets unregistered, the previously registered listener gets enabled again.
|
|
34
|
+
*/
|
|
35
|
+
function makeListenerTowerContext() {
|
|
36
|
+
const LISTENERS = [];
|
|
37
|
+
return {
|
|
38
|
+
register(listener) {
|
|
39
|
+
var _last;
|
|
40
|
+
// Disable previous listener.
|
|
41
|
+
(_last = last(LISTENERS)) === null || _last === void 0 ? void 0 : _last.disable();
|
|
42
|
+
// Keep track of current listener.
|
|
43
|
+
LISTENERS.push(listener);
|
|
44
|
+
// Enable current listener.
|
|
45
|
+
listener.enable();
|
|
46
|
+
},
|
|
47
|
+
unregister(listener) {
|
|
48
|
+
var _last2;
|
|
49
|
+
// Disable current listener.
|
|
50
|
+
listener.disable();
|
|
51
|
+
// Remove current listener.
|
|
52
|
+
pull(LISTENERS, listener);
|
|
53
|
+
// Enable previous listener.
|
|
54
|
+
(_last2 = last(LISTENERS)) === null || _last2 === void 0 ? void 0 : _last2.enable();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const FOCUS_TRAPS = makeListenerTowerContext();
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Trap 'Tab' focus switch inside the `focusZoneElement`.
|
|
63
|
+
*
|
|
64
|
+
* If multiple focus trap are activated, only the last one is maintained and when a focus trap closes, the previous one
|
|
65
|
+
* gets activated again.
|
|
66
|
+
*
|
|
67
|
+
* @param focusZoneElement The element in which to trap the focus.
|
|
68
|
+
* @param focusElement The element to focus when the focus trap is activated (otherwise the first focusable element
|
|
69
|
+
* will be focused).
|
|
70
|
+
*/
|
|
71
|
+
function useFocusTrap(focusZoneElement, focusElement) {
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
// Body element can be undefined in SSR context.
|
|
74
|
+
const rootElement = DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
|
|
75
|
+
if (!rootElement || !focusZoneElement) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Trap 'Tab' key down focus switch into the focus zone.
|
|
80
|
+
const trapTabFocusInFocusZone = evt => {
|
|
81
|
+
const {
|
|
82
|
+
key
|
|
83
|
+
} = evt;
|
|
84
|
+
if (key !== 'Tab') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const focusable = getFirstAndLastFocusable(focusZoneElement);
|
|
88
|
+
|
|
89
|
+
// Prevent focus switch if no focusable available.
|
|
90
|
+
if (!focusable.first) {
|
|
91
|
+
evt.preventDefault();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (
|
|
95
|
+
// No previous focus
|
|
96
|
+
!document.activeElement ||
|
|
97
|
+
// Previous focus is at the end of the focus zone.
|
|
98
|
+
!evt.shiftKey && document.activeElement === focusable.last ||
|
|
99
|
+
// Previous focus is outside the focus zone
|
|
100
|
+
!focusZoneElement.contains(document.activeElement)) {
|
|
101
|
+
focusable.first.focus();
|
|
102
|
+
evt.preventDefault();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (
|
|
106
|
+
// Focus order reversed
|
|
107
|
+
evt.shiftKey &&
|
|
108
|
+
// Previous focus is at the start of the focus zone.
|
|
109
|
+
document.activeElement === focusable.first) {
|
|
110
|
+
focusable.last.focus();
|
|
111
|
+
evt.preventDefault();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const focusTrap = {
|
|
115
|
+
enable: () => rootElement.addEventListener('keydown', trapTabFocusInFocusZone),
|
|
116
|
+
disable: () => rootElement.removeEventListener('keydown', trapTabFocusInFocusZone)
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// SETUP:
|
|
120
|
+
if (focusElement && focusZoneElement.contains(focusElement)) {
|
|
121
|
+
// Focus the given element.
|
|
122
|
+
focusElement.focus({
|
|
123
|
+
preventScroll: true
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
var _getFirstAndLastFocus;
|
|
127
|
+
// Focus the first focusable element in the zone.
|
|
128
|
+
(_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElement).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus({
|
|
129
|
+
preventScroll: true
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
FOCUS_TRAPS.register(focusTrap);
|
|
133
|
+
|
|
134
|
+
// TEARDOWN:
|
|
135
|
+
return () => FOCUS_TRAPS.unregister(focusTrap);
|
|
136
|
+
}, [focusElement, focusZoneElement]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const LISTENERS = makeListenerTowerContext();
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Register a global listener on 'Escape' key pressed.
|
|
143
|
+
*
|
|
144
|
+
* If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous
|
|
145
|
+
* one gets activated again.
|
|
146
|
+
*
|
|
147
|
+
* @param callback Callback
|
|
148
|
+
* @param closeOnEscape Disables the hook when false
|
|
149
|
+
*/
|
|
150
|
+
function useCallbackOnEscape(callback) {
|
|
151
|
+
let closeOnEscape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const rootElement = DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
|
|
154
|
+
if (!closeOnEscape || !callback || !rootElement) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const onKeyDown = onEscapePressed(callback);
|
|
158
|
+
const listener = {
|
|
159
|
+
enable: () => rootElement.addEventListener('keydown', onKeyDown),
|
|
160
|
+
disable: () => rootElement.removeEventListener('keydown', onKeyDown)
|
|
161
|
+
};
|
|
162
|
+
LISTENERS.register(listener);
|
|
163
|
+
return () => LISTENERS.unregister(listener);
|
|
164
|
+
}, [callback, closeOnEscape]);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { useCallbackOnEscape as a, getFirstAndLastFocusable as g, useFocusTrap as u };
|
|
168
|
+
//# sourceMappingURL=0110d951.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0110d951.js","sources":["../../src/utils/focus/getFirstAndLastFocusable.ts","../../src/utils/makeListenerTowerContext.ts","../../src/hooks/useFocusTrap.ts","../../src/hooks/useCallbackOnEscape.ts"],"sourcesContent":["import { getFocusableElements } from './getFocusableElements';\n\n/**\n * Get first and last elements focusable in an element.\n *\n * @param parentElement The element in which to search focusable elements.\n * @return first and last focusable elements\n */\nexport function getFirstAndLastFocusable(parentElement: HTMLElement) {\n const focusableElements = getFocusableElements(parentElement);\n\n // First non disabled element.\n const first = focusableElements[0];\n // Last non disabled element.\n const last = focusableElements[focusableElements.length - 1];\n\n if (last && first) {\n return { first, last };\n }\n return {};\n}\n","import last from 'lodash/last';\nimport pull from 'lodash/pull';\n\nexport type Listener = { enable(): void; disable(): void };\n\n/**\n * Keep track of listeners, only the last registered listener gets activated at any point (previously registered\n * listener are disabled).\n * When a listener gets unregistered, the previously registered listener gets enabled again.\n */\nexport function makeListenerTowerContext() {\n const LISTENERS: Listener[] = [];\n\n return {\n register(listener: Listener) {\n // Disable previous listener.\n last(LISTENERS)?.disable();\n // Keep track of current listener.\n LISTENERS.push(listener);\n // Enable current listener.\n listener.enable();\n },\n unregister(listener: Listener) {\n // Disable current listener.\n listener.disable();\n // Remove current listener.\n pull(LISTENERS, listener);\n // Enable previous listener.\n last(LISTENERS)?.enable();\n },\n };\n}\n","import { useEffect } from 'react';\n\nimport { DOCUMENT } from '@lumx/react/constants';\nimport { getFirstAndLastFocusable } from '@lumx/react/utils/focus/getFirstAndLastFocusable';\nimport { Falsy } from '@lumx/react/utils/type';\nimport { Listener, makeListenerTowerContext } from '@lumx/react/utils/makeListenerTowerContext';\n\nconst FOCUS_TRAPS = makeListenerTowerContext();\n\n/**\n * Trap 'Tab' focus switch inside the `focusZoneElement`.\n *\n * If multiple focus trap are activated, only the last one is maintained and when a focus trap closes, the previous one\n * gets activated again.\n *\n * @param focusZoneElement The element in which to trap the focus.\n * @param focusElement The element to focus when the focus trap is activated (otherwise the first focusable element\n * will be focused).\n */\nexport function useFocusTrap(focusZoneElement: HTMLElement | Falsy, focusElement?: HTMLElement | null): void {\n useEffect(() => {\n // Body element can be undefined in SSR context.\n const rootElement = DOCUMENT?.body;\n\n if (!rootElement || !focusZoneElement) {\n return undefined;\n }\n\n // Trap 'Tab' key down focus switch into the focus zone.\n const trapTabFocusInFocusZone = (evt: KeyboardEvent) => {\n const { key } = evt;\n if (key !== 'Tab') {\n return;\n }\n const focusable = getFirstAndLastFocusable(focusZoneElement);\n\n // Prevent focus switch if no focusable available.\n if (!focusable.first) {\n evt.preventDefault();\n return;\n }\n\n if (\n // No previous focus\n !document.activeElement ||\n // Previous focus is at the end of the focus zone.\n (!evt.shiftKey && document.activeElement === focusable.last) ||\n // Previous focus is outside the focus zone\n !focusZoneElement.contains(document.activeElement)\n ) {\n focusable.first.focus();\n evt.preventDefault();\n return;\n }\n\n if (\n // Focus order reversed\n evt.shiftKey &&\n // Previous focus is at the start of the focus zone.\n document.activeElement === focusable.first\n ) {\n focusable.last.focus();\n evt.preventDefault();\n }\n };\n\n const focusTrap: Listener = {\n enable: () => rootElement.addEventListener('keydown', trapTabFocusInFocusZone),\n disable: () => rootElement.removeEventListener('keydown', trapTabFocusInFocusZone),\n };\n\n // SETUP:\n if (focusElement && focusZoneElement.contains(focusElement)) {\n // Focus the given element.\n focusElement.focus({ preventScroll: true });\n } else {\n // Focus the first focusable element in the zone.\n getFirstAndLastFocusable(focusZoneElement).first?.focus({ preventScroll: true });\n }\n FOCUS_TRAPS.register(focusTrap);\n\n // TEARDOWN:\n return () => FOCUS_TRAPS.unregister(focusTrap);\n }, [focusElement, focusZoneElement]);\n}\n","import { DOCUMENT } from '@lumx/react/constants';\nimport { Callback } from '@lumx/react/utils/type';\nimport { onEscapePressed } from '@lumx/react/utils/event';\nimport { useEffect } from 'react';\nimport { Listener, makeListenerTowerContext } from '@lumx/react/utils/makeListenerTowerContext';\n\nconst LISTENERS = makeListenerTowerContext();\n\n/**\n * Register a global listener on 'Escape' key pressed.\n *\n * If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous\n * one gets activated again.\n *\n * @param callback Callback\n * @param closeOnEscape Disables the hook when false\n */\nexport function useCallbackOnEscape(callback: Callback | undefined, closeOnEscape = true) {\n useEffect(() => {\n const rootElement = DOCUMENT?.body;\n if (!closeOnEscape || !callback || !rootElement) {\n return undefined;\n }\n const onKeyDown = onEscapePressed(callback);\n\n const listener: Listener = {\n enable: () => rootElement.addEventListener('keydown', onKeyDown),\n disable: () => rootElement.removeEventListener('keydown', onKeyDown),\n };\n\n LISTENERS.register(listener);\n return () => LISTENERS.unregister(listener);\n }, [callback, closeOnEscape]);\n}\n"],"names":["getFirstAndLastFocusable","parentElement","focusableElements","getFocusableElements","first","last","length","makeListenerTowerContext","LISTENERS","register","listener","_last","disable","push","enable","unregister","_last2","pull","FOCUS_TRAPS","useFocusTrap","focusZoneElement","focusElement","useEffect","rootElement","DOCUMENT","body","undefined","trapTabFocusInFocusZone","evt","key","focusable","preventDefault","document","activeElement","shiftKey","contains","focus","focusTrap","addEventListener","removeEventListener","preventScroll","_getFirstAndLastFocus","useCallbackOnEscape","callback","closeOnEscape","arguments","onKeyDown","onEscapePressed"],"mappings":"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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { j as _objectSpread2, i as AspectRatio } from './35c3a78f.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Focal point using vertical alignment, horizontal alignment or coordinates (from -1 to 1).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Loading attribute is not yet supported in typescript, so we need
|
|
10
|
+
* to add it in order to avoid a ts error.
|
|
11
|
+
* https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/ADVANCED.md#adding-non-standard-attributes
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* All available aspect ratios.
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
18
|
+
const ThumbnailAspectRatio = _objectSpread2({}, AspectRatio);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Thumbnail sizes.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Thumbnail variants.
|
|
26
|
+
*/
|
|
27
|
+
const ThumbnailVariant = {
|
|
28
|
+
squared: 'squared',
|
|
29
|
+
rounded: 'rounded'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { ThumbnailAspectRatio as T, ThumbnailVariant as a };
|
|
33
|
+
//# sourceMappingURL=063bb3df.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"063bb3df.js","sources":["../../src/components/thumbnail/types.ts"],"sourcesContent":["import React from 'react';\nimport { AspectRatio, Size } from '@lumx/react';\nimport { ValueOf } from '@lumx/react/utils/type';\n\n/**\n * Focal point using vertical alignment, horizontal alignment or coordinates (from -1 to 1).\n */\nexport type FocusPoint = { x?: number; y?: number };\n\n/**\n * Loading attribute is not yet supported in typescript, so we need\n * to add it in order to avoid a ts error.\n * https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/ADVANCED.md#adding-non-standard-attributes\n */\ndeclare module 'react' {\n interface ImgHTMLAttributes<T> extends React.HTMLAttributes<T> {\n loading?: 'eager' | 'lazy';\n }\n}\n\n/**\n * All available aspect ratios.\n * @deprecated\n */\nexport const ThumbnailAspectRatio: Record<string, AspectRatio> = { ...AspectRatio };\n\n/**\n * Thumbnail sizes.\n */\nexport type ThumbnailSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\n/**\n * Thumbnail variants.\n */\nexport const ThumbnailVariant = {\n squared: 'squared',\n rounded: 'rounded',\n} as const;\nexport type ThumbnailVariant = ValueOf<typeof ThumbnailVariant>;\n"],"names":["ThumbnailAspectRatio","_objectSpread","AspectRatio","ThumbnailVariant","squared","rounded"],"mappings":";;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;MACaA,oBAAiD,GAAAC,cAAA,KAAQC,WAAW;;AAEjF;AACA;AACA;;AAGA;AACA;AACA;MACaC,gBAAgB,GAAG;EAC5BC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACb;;;;"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { l as GenericProps, q as HasTheme, A as Alignment, C as Comp } from './28b656e3.js';
|
|
3
|
+
import { a as IconProps } from './717ab5c2.js';
|
|
4
|
+
|
|
5
|
+
interface TabProviderProps {
|
|
6
|
+
/** Active tab index. */
|
|
7
|
+
activeTabIndex?: number;
|
|
8
|
+
/** Tab provider children. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Tab panel children should not render if the tab panel is hidden. */
|
|
11
|
+
isLazy?: boolean;
|
|
12
|
+
/** Activate tabs on focus. */
|
|
13
|
+
shouldActivateOnFocus?: boolean;
|
|
14
|
+
/** Tab change callback. */
|
|
15
|
+
onChange?(index: number): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* This component provides a context in which tabs can be defined and linked to their tab panel.
|
|
19
|
+
*
|
|
20
|
+
* It does not produce any markup so you can wrap it around any React elements and then split the TabList and TabPanel
|
|
21
|
+
* components in the react tree.
|
|
22
|
+
*
|
|
23
|
+
* @param props React component props.
|
|
24
|
+
* @return React element.
|
|
25
|
+
*/
|
|
26
|
+
declare const TabProvider: React.FC<TabProviderProps>;
|
|
27
|
+
|
|
28
|
+
declare enum TabListLayout {
|
|
29
|
+
clustered = "clustered",
|
|
30
|
+
fixed = "fixed"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Defines the props of the component.
|
|
34
|
+
*/
|
|
35
|
+
interface TabListProps extends GenericProps, HasTheme {
|
|
36
|
+
/** ARIA label (purpose of the set of tabs). */
|
|
37
|
+
['aria-label']: string;
|
|
38
|
+
/** Tab list. */
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
/** Layout of the tabs in the list. */
|
|
41
|
+
layout?: TabListLayout;
|
|
42
|
+
/** Position of the tabs in the list (requires 'clustered' layout). */
|
|
43
|
+
position?: Alignment;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* TabList component.
|
|
47
|
+
*
|
|
48
|
+
* Implements WAI-ARIA `tablist` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
|
|
49
|
+
*
|
|
50
|
+
* @param props Component props.
|
|
51
|
+
* @param ref Component ref.
|
|
52
|
+
* @return React element.
|
|
53
|
+
*/
|
|
54
|
+
declare const TabList: Comp<TabListProps, HTMLDivElement>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Defines the props of the component.
|
|
58
|
+
*/
|
|
59
|
+
interface TabProps extends GenericProps {
|
|
60
|
+
/** Children are not supported. */
|
|
61
|
+
children?: never;
|
|
62
|
+
/** Icon (SVG path). */
|
|
63
|
+
icon?: IconProps['icon'];
|
|
64
|
+
/** Icon component properties. */
|
|
65
|
+
iconProps?: Omit<IconProps, 'icon'>;
|
|
66
|
+
/** Native id property. */
|
|
67
|
+
id?: string;
|
|
68
|
+
/** Whether the tab is active or not. */
|
|
69
|
+
isActive?: boolean;
|
|
70
|
+
/** Whether the component is disabled or not. */
|
|
71
|
+
isDisabled?: boolean;
|
|
72
|
+
/** Label content. */
|
|
73
|
+
label: string | ReactNode;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Tab component.
|
|
77
|
+
*
|
|
78
|
+
* Implements WAI-ARIA `tab` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
|
|
79
|
+
*
|
|
80
|
+
* @param props Component props.
|
|
81
|
+
* @param ref Component ref.
|
|
82
|
+
* @return React element.
|
|
83
|
+
*/
|
|
84
|
+
declare const Tab: Comp<TabProps, HTMLButtonElement>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Defines the props of the component.
|
|
88
|
+
*/
|
|
89
|
+
interface TabPanelProps extends GenericProps {
|
|
90
|
+
/** Native id property */
|
|
91
|
+
id?: string;
|
|
92
|
+
/** Whether the tab is active or not. */
|
|
93
|
+
isActive?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* TabPanel component.
|
|
97
|
+
*
|
|
98
|
+
* Implements WAI-ARIA `tabpanel` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
|
|
99
|
+
*
|
|
100
|
+
* @param props Component props.
|
|
101
|
+
* @param ref Component ref.
|
|
102
|
+
* @return React element.
|
|
103
|
+
*/
|
|
104
|
+
declare const TabPanel: Comp<TabPanelProps, HTMLDivElement>;
|
|
105
|
+
|
|
106
|
+
export { TabProviderProps as T, TabProvider as a, TabListLayout as b, TabListProps as c, TabList as d, TabProps as e, Tab as f, TabPanelProps as g, TabPanel as h };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { s as HasClassName, q as HasTheme, O as Orientation, H as HasAriaLabelOrLabelledBy, t as ComponentRef } from './28b656e3.js';
|
|
3
|
+
|
|
4
|
+
interface NavigationSectionProps extends React.ComponentPropsWithoutRef<'li'>, HasClassName {
|
|
5
|
+
/** Items inside the section */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Icon (SVG path). */
|
|
8
|
+
icon?: string;
|
|
9
|
+
/** Label content. */
|
|
10
|
+
label: string | ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare type NavigationProps = React.ComponentProps<'nav'> & HasClassName & HasTheme & {
|
|
14
|
+
/** Content of the navigation. These components should be of type NavigationItem to be rendered */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
orientation?: Orientation;
|
|
17
|
+
} & HasAriaLabelOrLabelledBy;
|
|
18
|
+
declare const Navigation: React.ForwardRefExoticComponent<Pick<NavigationProps, "orientation" | "key" | keyof React.HTMLAttributes<HTMLElement> | "theme"> & React.RefAttributes<HTMLElement>> & {
|
|
19
|
+
displayName: string;
|
|
20
|
+
className: string;
|
|
21
|
+
defaultProps: {
|
|
22
|
+
theme: "light";
|
|
23
|
+
orientation: "vertical";
|
|
24
|
+
};
|
|
25
|
+
Section: React.ForwardRefExoticComponent<NavigationSectionProps & React.RefAttributes<HTMLLIElement>> & {
|
|
26
|
+
displayName: string;
|
|
27
|
+
className: string;
|
|
28
|
+
};
|
|
29
|
+
Item: (<E extends React.ElementType<any> = "a">(props: React.PropsWithoutRef<React.ComponentProps<E>> & {
|
|
30
|
+
as?: E | undefined;
|
|
31
|
+
} & HasTheme & HasClassName & {
|
|
32
|
+
icon?: string | undefined;
|
|
33
|
+
label: React.ReactNode; /** Content of the navigation. These components should be of type NavigationItem to be rendered */
|
|
34
|
+
isCurrentPage?: boolean | undefined;
|
|
35
|
+
} & (E extends "a" ? {
|
|
36
|
+
href: string;
|
|
37
|
+
} : Record<string, unknown>) & {
|
|
38
|
+
ref?: ComponentRef<E> | undefined;
|
|
39
|
+
}) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
|
|
40
|
+
displayName: string;
|
|
41
|
+
className: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { NavigationProps as N, Navigation as a };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { _ as _objectWithoutProperties } from './35c3a78f.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const _excluded = ["linkAs"];
|
|
5
|
+
/**
|
|
6
|
+
* Render link with default <a> HTML component or a custom one provided by `linkAs`.
|
|
7
|
+
*
|
|
8
|
+
* Can be used to inject the `Link` component from `react-router` and provide better a11y on LumX components.
|
|
9
|
+
*
|
|
10
|
+
* @param linkAs Custom link component.
|
|
11
|
+
* @param children Link children.
|
|
12
|
+
* @return A link.
|
|
13
|
+
*/
|
|
14
|
+
const renderLink = function (_ref) {
|
|
15
|
+
let {
|
|
16
|
+
linkAs
|
|
17
|
+
} = _ref,
|
|
18
|
+
forwardedProps = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
for (var _len = arguments.length, children = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
20
|
+
children[_key - 1] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/React.createElement(linkAs || 'a', forwardedProps, ...children);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { renderLink as r };
|
|
26
|
+
//# sourceMappingURL=1098ba6a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1098ba6a.js","sources":["../../src/utils/renderLink.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode } from 'react';\n\ninterface Props {\n linkAs?: any;\n}\n\n/**\n * Render link with default <a> HTML component or a custom one provided by `linkAs`.\n *\n * Can be used to inject the `Link` component from `react-router` and provide better a11y on LumX components.\n *\n * @param linkAs Custom link component.\n * @param children Link children.\n * @return A link.\n */\nexport const renderLink = <P extends Props>({ linkAs, ...forwardedProps }: P, ...children: ReactNode[]): ReactElement =>\n React.createElement(linkAs || 'a', forwardedProps, ...children);\n"],"names":["renderLink","_ref","linkAs","forwardedProps","_objectWithoutProperties","_excluded","_len","arguments","length","children","Array","_key","React","createElement"],"mappings":";;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaA,UAAU,GAAG,UAAAC,IAAA;EAAA,IAAkB;MAAEC;KAA8B,GAAAD,IAAA;IAAnBE,cAAc,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAUC,QAAQ,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAARF,QAAQ,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;;EAAA,oBACrFC,KAAK,CAACC,aAAa,CAACX,MAAM,IAAI,GAAG,EAAEC,cAAc,EAAE,GAAGM,QAAQ,CAAC;AAAA;;;;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { g as getRootClassName, _ as _objectWithoutProperties, a as _extends, c as classnames, j as _objectSpread2, i as AspectRatio, T as Theme, C as ColorPalette, b as ColorVariant, S as Size } from './35c3a78f.js';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { h as handleBasicClasses } from './3f5e7653.js';
|
|
4
|
+
import { L as Link } from './c70420da.js';
|
|
5
|
+
import { T as Thumbnail } from './9dced38c.js';
|
|
6
|
+
|
|
7
|
+
const _excluded = ["className", "description", "link", "linkAs", "linkProps", "size", "theme", "thumbnailProps", "title", "titleHeading"];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Defines the props of the component.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Component display name.
|
|
15
|
+
*/
|
|
16
|
+
const COMPONENT_NAME = 'LinkPreview';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Component default class name and class prefix.
|
|
20
|
+
*/
|
|
21
|
+
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Component default props.
|
|
25
|
+
*/
|
|
26
|
+
const DEFAULT_PROPS = {
|
|
27
|
+
size: Size.regular,
|
|
28
|
+
theme: Theme.light,
|
|
29
|
+
titleHeading: 'h2'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* LinkPreview component.
|
|
34
|
+
*
|
|
35
|
+
* @param props Component props.
|
|
36
|
+
* @param ref Component ref.
|
|
37
|
+
* @return React element.
|
|
38
|
+
*/
|
|
39
|
+
const LinkPreview = /*#__PURE__*/forwardRef((props, ref) => {
|
|
40
|
+
const {
|
|
41
|
+
className,
|
|
42
|
+
description,
|
|
43
|
+
link,
|
|
44
|
+
linkAs,
|
|
45
|
+
linkProps,
|
|
46
|
+
size,
|
|
47
|
+
theme,
|
|
48
|
+
thumbnailProps,
|
|
49
|
+
title,
|
|
50
|
+
titleHeading
|
|
51
|
+
} = props,
|
|
52
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
53
|
+
// Use title heading as title wrapper (see DEFAULT_PROPS for the default value).
|
|
54
|
+
const TitleHeading = titleHeading;
|
|
55
|
+
return /*#__PURE__*/React.createElement("article", _extends({
|
|
56
|
+
ref: ref
|
|
57
|
+
}, forwardedProps, {
|
|
58
|
+
className: classnames(className, handleBasicClasses({
|
|
59
|
+
prefix: CLASSNAME,
|
|
60
|
+
size: size === Size.big && thumbnailProps ? Size.big : Size.regular,
|
|
61
|
+
theme
|
|
62
|
+
}))
|
|
63
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: `${CLASSNAME}__wrapper`
|
|
65
|
+
}, thumbnailProps && /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: `${CLASSNAME}__thumbnail`
|
|
67
|
+
}, /*#__PURE__*/React.createElement(Thumbnail, _extends({}, thumbnailProps, {
|
|
68
|
+
linkAs: linkAs,
|
|
69
|
+
linkProps: _objectSpread2(_objectSpread2({}, linkProps), {}, {
|
|
70
|
+
href: link,
|
|
71
|
+
target: '_blank',
|
|
72
|
+
// Avoid redundant links in focus order
|
|
73
|
+
tabIndex: -1
|
|
74
|
+
}),
|
|
75
|
+
aspectRatio: AspectRatio.free,
|
|
76
|
+
fillHeight: true
|
|
77
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: `${CLASSNAME}__container`
|
|
79
|
+
}, title && /*#__PURE__*/React.createElement(TitleHeading, {
|
|
80
|
+
className: `${CLASSNAME}__title`
|
|
81
|
+
}, /*#__PURE__*/React.createElement(Link, _extends({}, linkProps, {
|
|
82
|
+
linkAs: linkAs,
|
|
83
|
+
target: "_blank",
|
|
84
|
+
href: link,
|
|
85
|
+
color: theme === Theme.light ? ColorPalette.dark : ColorPalette.light,
|
|
86
|
+
colorVariant: ColorVariant.N
|
|
87
|
+
}), title)), description && /*#__PURE__*/React.createElement("p", {
|
|
88
|
+
className: `${CLASSNAME}__description`
|
|
89
|
+
}, description), /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: `${CLASSNAME}__link`
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Link, _extends({}, linkProps, {
|
|
92
|
+
linkAs: linkAs,
|
|
93
|
+
className: classnames(`${CLASSNAME}__link`, linkProps === null || linkProps === void 0 ? void 0 : linkProps.className),
|
|
94
|
+
target: "_blank",
|
|
95
|
+
href: link,
|
|
96
|
+
color: theme === Theme.light ? ColorPalette.primary : ColorPalette.light,
|
|
97
|
+
colorVariant: ColorVariant.N
|
|
98
|
+
// Avoid redundant links in focus order
|
|
99
|
+
,
|
|
100
|
+
tabIndex: title ? '-1' : undefined
|
|
101
|
+
}), link)))));
|
|
102
|
+
});
|
|
103
|
+
LinkPreview.displayName = COMPONENT_NAME;
|
|
104
|
+
LinkPreview.className = CLASSNAME;
|
|
105
|
+
LinkPreview.defaultProps = DEFAULT_PROPS;
|
|
106
|
+
|
|
107
|
+
export { LinkPreview as L };
|
|
108
|
+
//# sourceMappingURL=1252e3a1.js.map
|