@hashicorp/mds-react 0.9.3 → 0.9.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/components/accordion/index.js +9 -0
- package/components/accordion/index.js.map +1 -0
- package/components/accordion/item/button.js +44 -0
- package/components/accordion/item/button.js.map +1 -0
- package/components/accordion/item/index.js +59 -0
- package/components/accordion/item/index.js.map +1 -0
- package/components/accordion/style.module.scss.js +24 -0
- package/components/accordion/style.module.scss.js.map +1 -0
- package/components/alert/alert.module.scss.js +29 -0
- package/components/alert/alert.module.scss.js.map +1 -0
- package/components/alert/icon.js +34 -0
- package/components/alert/icon.js.map +1 -0
- package/components/alert/index.js +97 -0
- package/components/alert/index.js.map +1 -0
- package/components/badge/index.js +50 -0
- package/components/badge/index.js.map +1 -0
- package/components/badge/style.module.scss +8 -6
- package/components/badge/style.module.scss.js +22 -0
- package/components/badge/style.module.scss.js.map +1 -0
- package/components/badge-count/index.js +29 -0
- package/components/badge-count/index.js.map +1 -0
- package/components/badge-count/style.module.scss +7 -6
- package/components/badge-count/style.module.scss.js +15 -0
- package/components/badge-count/style.module.scss.js.map +1 -0
- package/components/breadcrumbs/index.js +38 -0
- package/components/breadcrumbs/index.js.map +1 -0
- package/components/breadcrumbs/item/index.js +32 -0
- package/components/breadcrumbs/item/index.js.map +1 -0
- package/components/breadcrumbs/style.module.scss.js +27 -0
- package/components/breadcrumbs/style.module.scss.js.map +1 -0
- package/components/breadcrumbs/truncation-button/index.js +25 -0
- package/components/breadcrumbs/truncation-button/index.js.map +1 -0
- package/components/button/button-primitive.d.ts +5 -0
- package/components/button/button-primitive.js +59 -0
- package/components/button/button-primitive.js.map +1 -0
- package/components/button/index.d.ts +4 -5
- package/components/button/index.js +69 -0
- package/components/button/index.js.map +1 -0
- package/components/button/styles.module.scss.js +32 -0
- package/components/button/styles.module.scss.js.map +1 -0
- package/components/card/card-thumbnail/card-thumbnail.module.css.js +8 -0
- package/components/card/card-thumbnail/card-thumbnail.module.css.js.map +1 -0
- package/components/card/card-thumbnail/index.js +23 -0
- package/components/card/card-thumbnail/index.js.map +1 -0
- package/components/card/index.d.ts +2 -1
- package/components/card/index.js +160 -0
- package/components/card/index.js.map +1 -0
- package/components/card/styles.module.css.js +29 -0
- package/components/card/styles.module.css.js.map +1 -0
- package/components/card/types.d.ts +1 -0
- package/components/code-block/code-block.module.scss.js +34 -0
- package/components/code-block/code-block.module.scss.js.map +1 -0
- package/components/code-block/code-lines/index.js +59 -0
- package/components/code-block/code-lines/index.js.map +1 -0
- package/components/code-block/code-lines/utils/split-html-into-lines.js +19 -0
- package/components/code-block/code-lines/utils/split-html-into-lines.js.map +1 -0
- package/components/code-block/code-lines/utils/split-jsx-into-lines.js +31 -0
- package/components/code-block/code-lines/utils/split-jsx-into-lines.js.map +1 -0
- package/components/code-block/hidden-copy-content/index.js +13 -0
- package/components/code-block/hidden-copy-content/index.js.map +1 -0
- package/components/code-block/index.js +88 -0
- package/components/code-block/index.js.map +1 -0
- package/components/code-block/utils/parse-highlighted-lines.js +39 -0
- package/components/code-block/utils/parse-highlighted-lines.js.map +1 -0
- package/components/code-block/utils/process-snippet.js +20 -0
- package/components/code-block/utils/process-snippet.js.map +1 -0
- package/components/code-block/utils/shellwords.js +33 -0
- package/components/code-block/utils/shellwords.js.map +1 -0
- package/components/combo-box-primitive/index.js +302 -0
- package/components/combo-box-primitive/index.js.map +1 -0
- package/components/dialog-primitive/dialog.module.scss.js +12 -0
- package/components/dialog-primitive/dialog.module.scss.js.map +1 -0
- package/components/dialog-primitive/index.js +15 -0
- package/components/dialog-primitive/index.js.map +1 -0
- package/components/disclosure-primitive/index.js +57 -0
- package/components/disclosure-primitive/index.js.map +1 -0
- package/components/disclosure-primitive/styles.module.css.js +7 -0
- package/components/disclosure-primitive/styles.module.css.js.map +1 -0
- package/components/disclosure-primitive/use-disclosure-primitive.js +17 -0
- package/components/disclosure-primitive/use-disclosure-primitive.js.map +1 -0
- package/components/dismiss-button/index.js +22 -0
- package/components/dismiss-button/index.js.map +1 -0
- package/components/dismiss-button/styles.module.scss.js +7 -0
- package/components/dismiss-button/styles.module.scss.js.map +1 -0
- package/components/dropdown/index.js +79 -0
- package/components/dropdown/index.js.map +1 -0
- package/components/dropdown/list-item/custom.js +9 -0
- package/components/dropdown/list-item/custom.js.map +1 -0
- package/components/dropdown/list-item/index.js +14 -0
- package/components/dropdown/list-item/index.js.map +1 -0
- package/components/dropdown/list-item/interactive.js +49 -0
- package/components/dropdown/list-item/interactive.js.map +1 -0
- package/components/dropdown/list-item/separator.js +17 -0
- package/components/dropdown/list-item/separator.js.map +1 -0
- package/components/dropdown/list-item/styles.module.css.js +26 -0
- package/components/dropdown/list-item/styles.module.css.js.map +1 -0
- package/components/dropdown/list-item/title.js +9 -0
- package/components/dropdown/list-item/title.js.map +1 -0
- package/components/dropdown/styles.module.css.js +24 -0
- package/components/dropdown/styles.module.css.js.map +1 -0
- package/components/dropdown/toggle-button/index.js +54 -0
- package/components/dropdown/toggle-button/index.js.map +1 -0
- package/components/dropdown/toggle-button/styles.module.scss.js +14 -0
- package/components/dropdown/toggle-button/styles.module.scss.js.map +1 -0
- package/components/flight-icon/flight-icon.module.css.js +12 -0
- package/components/flight-icon/flight-icon.module.css.js.map +1 -0
- package/components/flight-icon/index.js +58 -0
- package/components/flight-icon/index.js.map +1 -0
- package/components/form/checkbox/form-checkbox.module.css.js +8 -0
- package/components/form/checkbox/form-checkbox.module.css.js.map +1 -0
- package/components/form/checkbox/index.js +109 -0
- package/components/form/checkbox/index.js.map +1 -0
- package/components/form/error/form-error.module.css.js +14 -0
- package/components/form/error/form-error.module.css.js.map +1 -0
- package/components/form/error/index.js +22 -0
- package/components/form/error/index.js.map +1 -0
- package/components/form/field/form-field.module.css.js +17 -0
- package/components/form/field/form-field.module.css.js.map +1 -0
- package/components/form/field/index.js +46 -0
- package/components/form/field/index.js.map +1 -0
- package/components/form/fieldset/form-fieldset.module.css.js +19 -0
- package/components/form/fieldset/form-fieldset.module.css.js.map +1 -0
- package/components/form/fieldset/index.d.ts +1 -2
- package/components/form/fieldset/index.js +65 -0
- package/components/form/fieldset/index.js.map +1 -0
- package/components/form/file-input/form-file-input.module.scss +2 -2
- package/components/form/file-input/form-file-input.module.scss.js +7 -0
- package/components/form/file-input/form-file-input.module.scss.js.map +1 -0
- package/components/form/file-input/index.js +68 -0
- package/components/form/file-input/index.js.map +1 -0
- package/components/form/helper-text/form-helper-text.module.css.js +7 -0
- package/components/form/helper-text/form-helper-text.module.css.js.map +1 -0
- package/components/form/helper-text/index.js +22 -0
- package/components/form/helper-text/index.js.map +1 -0
- package/components/form/indicator/form-indicator.module.css.js +8 -0
- package/components/form/indicator/form-indicator.module.css.js.map +1 -0
- package/components/form/indicator/index.js +23 -0
- package/components/form/indicator/index.js.map +1 -0
- package/components/form/label/form-label.module.css.js +10 -0
- package/components/form/label/form-label.module.css.js.map +1 -0
- package/components/form/label/index.js +33 -0
- package/components/form/label/index.js.map +1 -0
- package/components/form/legend/form-legend.module.css.js +10 -0
- package/components/form/legend/form-legend.module.css.js.map +1 -0
- package/components/form/legend/index.js +19 -0
- package/components/form/legend/index.js.map +1 -0
- package/components/form/radio/form-radio.module.scss.js +8 -0
- package/components/form/radio/form-radio.module.scss.js.map +1 -0
- package/components/form/radio/index.d.ts +3 -5
- package/components/form/radio/index.js +100 -0
- package/components/form/radio/index.js.map +1 -0
- package/components/form/radio-card/RadioCardStory.css +21 -0
- package/components/form/radio-card/description.js +10 -0
- package/components/form/radio-card/description.js.map +1 -0
- package/components/form/radio-card/form-radio-card.module.css.js +30 -0
- package/components/form/radio-card/form-radio-card.module.css.js.map +1 -0
- package/components/form/radio-card/group.js +31 -0
- package/components/form/radio-card/group.js.map +1 -0
- package/components/form/radio-card/index.js +67 -0
- package/components/form/radio-card/index.js.map +1 -0
- package/components/form/radio-card/label.js +10 -0
- package/components/form/radio-card/label.js.map +1 -0
- package/components/form/select/form-select.module.css.js +14 -0
- package/components/form/select/form-select.module.css.js.map +1 -0
- package/components/form/select/index.js +79 -0
- package/components/form/select/index.js.map +1 -0
- package/components/form/super-select/form-super-select.module.css.js +22 -0
- package/components/form/super-select/form-super-select.module.css.js.map +1 -0
- package/components/form/super-select/index.js +170 -0
- package/components/form/super-select/index.js.map +1 -0
- package/components/form/text-input/index.js +91 -0
- package/components/form/text-input/index.js.map +1 -0
- package/components/form/text-input/styles.module.css.js +15 -0
- package/components/form/text-input/styles.module.css.js.map +1 -0
- package/components/form/textarea/form-textarea.module.css.js +14 -0
- package/components/form/textarea/form-textarea.module.css.js.map +1 -0
- package/components/form/textarea/index.js +74 -0
- package/components/form/textarea/index.js.map +1 -0
- package/components/form/toggle/form-toggle.module.scss.js +12 -0
- package/components/form/toggle/form-toggle.module.scss.js.map +1 -0
- package/components/form/toggle/index.js +102 -0
- package/components/form/toggle/index.js.map +1 -0
- package/components/hds/wrappers/tooltip.js +51 -0
- package/components/hds/wrappers/tooltip.js.map +1 -0
- package/components/icon-tile/index.js +50 -0
- package/components/icon-tile/index.js.map +1 -0
- package/components/icon-tile/style.module.scss +12 -10
- package/components/icon-tile/style.module.scss.js +29 -0
- package/components/icon-tile/style.module.scss.js.map +1 -0
- package/components/index.d.ts +1 -1
- package/components/index.js +116 -73
- package/components/index.js.map +1 -1
- package/components/inline-link/index.js +34 -0
- package/components/inline-link/index.js.map +1 -0
- package/components/inline-link/inline-link.module.css.js +11 -0
- package/components/inline-link/inline-link.module.css.js.map +1 -0
- package/components/interactive/index.js +59 -0
- package/components/interactive/index.js.map +1 -0
- package/components/legacy-button/index.js +65 -0
- package/components/legacy-button/index.js.map +1 -0
- package/components/legacy-button/utils.js +39 -0
- package/components/legacy-button/utils.js.map +1 -0
- package/components/menu-primitive/index.js +68 -0
- package/components/menu-primitive/index.js.map +1 -0
- package/components/menu-primitive/styles.module.css.js +12 -0
- package/components/menu-primitive/styles.module.css.js.map +1 -0
- package/components/menu-primitive/use-menu-primitive.js +17 -0
- package/components/menu-primitive/use-menu-primitive.js.map +1 -0
- package/components/modal/index.js +61 -0
- package/components/modal/index.js.map +1 -0
- package/components/modal/modal.module.css +5 -0
- package/components/modal/modal.module.css.js +8 -0
- package/components/modal/modal.module.css.js.map +1 -0
- package/components/modal/use-modal.js +17 -0
- package/components/modal/use-modal.js.map +1 -0
- package/components/separator/index.js +15 -0
- package/components/separator/index.js.map +1 -0
- package/components/separator/separator.module.css.js +10 -0
- package/components/separator/separator.module.css.js.map +1 -0
- package/components/standalone-link/index.js +54 -0
- package/components/standalone-link/index.js.map +1 -0
- package/components/standalone-link/styles.module.scss.js +17 -0
- package/components/standalone-link/styles.module.scss.js.map +1 -0
- package/components/table/index.js +52 -0
- package/components/table/index.js.map +1 -0
- package/components/table/table.module.scss.js +33 -0
- package/components/table/table.module.scss.js.map +1 -0
- package/components/table/td.js +28 -0
- package/components/table/td.js.map +1 -0
- package/components/table/th-button-tooltip.js +24 -0
- package/components/table/th-button-tooltip.js.map +1 -0
- package/components/table/th.js +43 -0
- package/components/table/th.js.map +1 -0
- package/components/table/tr.js +9 -0
- package/components/table/tr.js.map +1 -0
- package/components/table/utils.js +28 -0
- package/components/table/utils.js.map +1 -0
- package/components/tabs/index.js +115 -0
- package/components/tabs/index.js.map +1 -0
- package/components/tabs/tab-panel.js +35 -0
- package/components/tabs/tab-panel.js.map +1 -0
- package/components/tabs/tab.js +70 -0
- package/components/tabs/tab.js.map +1 -0
- package/components/tabs/tabs.module.scss.js +22 -0
- package/components/tabs/tabs.module.scss.js.map +1 -0
- package/components/tabs/use-tabs-context.js +16 -0
- package/components/tabs/use-tabs-context.js.map +1 -0
- package/components/text/index.js +112 -0
- package/components/text/index.js.map +1 -0
- package/components/text/style.module.scss.js +9 -0
- package/components/text/style.module.scss.js.map +1 -0
- package/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.js +62 -0
- package/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.js.map +1 -0
- package/components/visualizations/bar-chart/horizontal-chart/dataset-value/style.module.css.js +20 -0
- package/components/visualizations/bar-chart/horizontal-chart/dataset-value/style.module.css.js.map +1 -0
- package/components/visualizations/bar-chart/horizontal-chart/index.js +104 -0
- package/components/visualizations/bar-chart/horizontal-chart/index.js.map +1 -0
- package/components/visualizations/bar-chart/horizontal-chart/legend/index.js +13 -0
- package/components/visualizations/bar-chart/horizontal-chart/legend/index.js.map +1 -0
- package/components/visualizations/bar-chart/horizontal-chart/legend/style.module.css.js +14 -0
- package/components/visualizations/bar-chart/horizontal-chart/legend/style.module.css.js.map +1 -0
- package/components/visualizations/bar-chart/horizontal-chart/style.module.css.js +28 -0
- package/components/visualizations/bar-chart/horizontal-chart/style.module.css.js.map +1 -0
- package/components/visualizations/bar-chart/index.js +37 -0
- package/components/visualizations/bar-chart/index.js.map +1 -0
- package/components/visualizations/bar-chart/style.module.css.js +12 -0
- package/components/visualizations/bar-chart/style.module.css.js.map +1 -0
- package/components/visualizations/donut-chart/components/arc-tooltip/index.js +14 -0
- package/components/visualizations/donut-chart/components/arc-tooltip/index.js.map +1 -0
- package/components/visualizations/donut-chart/components/arc-tooltip/styles.module.css.js +10 -0
- package/components/visualizations/donut-chart/components/arc-tooltip/styles.module.css.js.map +1 -0
- package/components/visualizations/donut-chart/components/external-arc-label/index.js +58 -0
- package/components/visualizations/donut-chart/components/external-arc-label/index.js.map +1 -0
- package/components/visualizations/donut-chart/components/external-arc-label/styles.module.css.js +16 -0
- package/components/visualizations/donut-chart/components/external-arc-label/styles.module.css.js.map +1 -0
- package/components/visualizations/donut-chart/components/internal-arc-label/index.js +42 -0
- package/components/visualizations/donut-chart/components/internal-arc-label/index.js.map +1 -0
- package/components/visualizations/donut-chart/components/internal-arc-label/styles.module.css.js +14 -0
- package/components/visualizations/donut-chart/components/internal-arc-label/styles.module.css.js.map +1 -0
- package/components/visualizations/donut-chart/index.js +90 -0
- package/components/visualizations/donut-chart/index.js.map +1 -0
- package/components/visualizations/donut-chart/styles.module.css.js +20 -0
- package/components/visualizations/donut-chart/styles.module.css.js.map +1 -0
- package/hooks/use-media-query/index.js +16 -0
- package/hooks/use-media-query/index.js.map +1 -0
- package/index.js +155 -101
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/patterns/card/newsroom-card/index.js +26 -0
- package/patterns/card/newsroom-card/index.js.map +1 -0
- package/patterns/card/newsroom-card/style.module.css.js +8 -0
- package/patterns/card/newsroom-card/style.module.css.js.map +1 -0
- package/patterns/card/partner-card/index.js +42 -0
- package/patterns/card/partner-card/index.js.map +1 -0
- package/patterns/card/partner-card/style.module.css.js +12 -0
- package/patterns/card/partner-card/style.module.css.js.map +1 -0
- package/patterns/card/person-card/index.js +54 -0
- package/patterns/card/person-card/index.js.map +1 -0
- package/patterns/card/person-card/style.module.css.js +12 -0
- package/patterns/card/person-card/style.module.css.js.map +1 -0
- package/patterns/card/primitives.js +77 -0
- package/patterns/card/primitives.js.map +1 -0
- package/patterns/card/promo-card/index.js +36 -0
- package/patterns/card/promo-card/index.js.map +1 -0
- package/patterns/card/resource-card/index.js +26 -0
- package/patterns/card/resource-card/index.js.map +1 -0
- package/patterns/card/style.module.css.js +30 -0
- package/patterns/card/style.module.css.js.map +1 -0
- package/patterns/card/thumbnails/index.js +25 -0
- package/patterns/card/thumbnails/index.js.map +1 -0
- package/patterns/card/unified-card/index.js +37 -0
- package/patterns/card/unified-card/index.js.map +1 -0
- package/patterns/copy-button/clipboard.js +78 -0
- package/patterns/copy-button/clipboard.js.map +1 -0
- package/patterns/copy-button/index.js +57 -0
- package/patterns/copy-button/index.js.map +1 -0
- package/patterns/copy-button/style.module.css.js +13 -0
- package/patterns/copy-button/style.module.css.js.map +1 -0
- package/patterns/index.js +32 -22
- package/patterns/index.js.map +1 -1
- package/patterns/layout/index.js +47 -0
- package/patterns/layout/index.js.map +1 -0
- package/patterns/layout/layout.module.css.js +20 -0
- package/patterns/layout/layout.module.css.js.map +1 -0
- package/patterns/product-badge/index.js +22 -0
- package/patterns/product-badge/index.js.map +1 -0
- package/patterns/product-badge/style.module.css.js +8 -0
- package/patterns/product-badge/style.module.css.js.map +1 -0
- package/patterns/product-logo/index.js +130 -0
- package/patterns/product-logo/index.js.map +1 -0
- package/patterns/product-logo/product-logo.module.css.js +13 -0
- package/patterns/product-logo/product-logo.module.css.js.map +1 -0
- package/patterns/related-content/index.js +65 -0
- package/patterns/related-content/index.js.map +1 -0
- package/patterns/related-content/style.module.css.js +22 -0
- package/patterns/related-content/style.module.css.js.map +1 -0
- package/style.css +1 -1
- package/utils/get-contrast-yiq.js +13 -0
- package/utils/get-contrast-yiq.js.map +1 -0
- package/utils/hooks/use-screen-size.js +10 -0
- package/utils/hooks/use-screen-size.js.map +1 -0
- package/utils/i18n/constants/index.js +98 -0
- package/utils/i18n/constants/index.js.map +1 -0
- package/utils/i18n/helpers/locale-provider.js +9 -0
- package/utils/i18n/helpers/locale-provider.js.map +1 -0
- package/utils/i18n/helpers/to-smart-sentence-case.js +12 -0
- package/utils/i18n/helpers/to-smart-sentence-case.js.map +1 -0
- package/utils/i18n/helpers/to-smart-title-case.js +10 -0
- package/utils/i18n/helpers/to-smart-title-case.js.map +1 -0
- package/utils/i18n/helpers/use-locale.js +14 -0
- package/utils/i18n/helpers/use-locale.js.map +1 -0
- package/utils/i18n/index.js +41 -0
- package/utils/i18n/index.js.map +1 -0
- package/utils/i18n/index2.js +33 -0
- package/utils/i18n/index2.js.map +1 -0
- package/utils/index.js +7 -7
- package/utils/make-normalizer/index.js +34 -0
- package/utils/make-normalizer/index.js.map +1 -0
- package/{index-DBjAbGt7.js → utils/mds-context/index.js} +20 -19
- package/utils/mds-context/index.js.map +1 -0
- package/index-B9mPJh9w.js +0 -579
- package/index-B9mPJh9w.js.map +0 -1
- package/index-BHBlMMNF.js +0 -16
- package/index-BHBlMMNF.js.map +0 -1
- package/index-C4GBbW3N.js +0 -3567
- package/index-C4GBbW3N.js.map +0 -1
- package/index-DBjAbGt7.js.map +0 -1
- package/index-WkGIywHj.js +0 -767
- package/index-WkGIywHj.js.map +0 -1
- package/use-screen-size-BOnkX_K-.js +0 -9
- package/use-screen-size-BOnkX_K-.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const t = "table__tdU5g", e = "striped__MBMc-", n = "tbody__W5bOI", _ = "tr__xeZno", d = "th__GQbKk", i = "td__WktB5", a = "content__Js-E8", l = "thead__3-vDU", o = {
|
|
2
|
+
table: t,
|
|
3
|
+
"layout-fixed": "layout-fixed__9PpwJ",
|
|
4
|
+
striped: e,
|
|
5
|
+
tbody: n,
|
|
6
|
+
tr: _,
|
|
7
|
+
"density-short": "density-short__7tyZx",
|
|
8
|
+
"density-medium": "density-medium__nmuYV",
|
|
9
|
+
"density-tall": "density-tall__2N9i0",
|
|
10
|
+
"valign-top": "valign-top__SRqQY",
|
|
11
|
+
"valign-middle": "valign-middle__kSfMx",
|
|
12
|
+
"valign-baseline": "valign-baseline__UFJwd",
|
|
13
|
+
th: d,
|
|
14
|
+
td: i,
|
|
15
|
+
"align-center": "align-center__vOTTL",
|
|
16
|
+
content: a,
|
|
17
|
+
"align-right": "align-right__3vUHD",
|
|
18
|
+
thead: l,
|
|
19
|
+
"th-button": "th-button__drg-o",
|
|
20
|
+
"aria-label-hidden-segment": "aria-label-hidden-segment__oQhN8"
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
a as content,
|
|
24
|
+
o as default,
|
|
25
|
+
e as striped,
|
|
26
|
+
t as table,
|
|
27
|
+
n as tbody,
|
|
28
|
+
i as td,
|
|
29
|
+
d as th,
|
|
30
|
+
l as thead,
|
|
31
|
+
_ as tr
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=table.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import e from "classnames";
|
|
3
|
+
import { DEFAULT_ALIGNMENT as p } from "./utils.js";
|
|
4
|
+
import r from "./table.module.scss.js";
|
|
5
|
+
const d = ({
|
|
6
|
+
align: t = p,
|
|
7
|
+
children: m,
|
|
8
|
+
className: a,
|
|
9
|
+
...s
|
|
10
|
+
}) => /* @__PURE__ */ o(
|
|
11
|
+
"td",
|
|
12
|
+
{
|
|
13
|
+
className: e(
|
|
14
|
+
r.td,
|
|
15
|
+
r[`align-${t}`],
|
|
16
|
+
"mds-typography-legacy-body-200",
|
|
17
|
+
"mds-typography-font-weight-regular",
|
|
18
|
+
a
|
|
19
|
+
),
|
|
20
|
+
...s,
|
|
21
|
+
children: /* @__PURE__ */ o("div", { className: r.content, children: m })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
d.displayName = "B.Td";
|
|
25
|
+
export {
|
|
26
|
+
d as TD
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=td.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"td.js","sources":["../../../src/components/table/td.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { DEFAULT_ALIGNMENT, type HorizontalAlignment } from './utils'\nimport type { HTMLAttributes, ReactNode } from 'react'\nimport s from './table.module.scss'\n\nexport interface TDProps extends HTMLAttributes<HTMLTableCellElement> {\n\t/**\n\t * Determines the horizontal content alignment (sometimes referred to as text alignment) for the cell (make sure it is also set for the column header).\n\t */\n\talign?: HorizontalAlignment\n\t/**\n\t * Elements passed as children are yielded as inner content of a <td> HTML element.\n\t */\n\tchildren: ReactNode\n}\n\nconst TD = ({\n\talign = DEFAULT_ALIGNMENT,\n\tchildren,\n\tclassName,\n\t...rest\n}: TDProps) => {\n\treturn (\n\t\t<td\n\t\t\tclassName={classNames(\n\t\t\t\ts.td,\n\t\t\t\ts[`align-${align}`],\n\t\t\t\t'mds-typography-legacy-body-200',\n\t\t\t\t'mds-typography-font-weight-regular',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\t{...rest}\n\t\t>\n\t\t\t<div className={s.content}>{children}</div>\n\t\t</td>\n\t)\n}\n\nTD.displayName = 'B.Td'\n\nexport { TD }\n"],"names":["TD","align","DEFAULT_ALIGNMENT","children","className","rest","jsx","classNames","s"],"mappings":";;;;AAgBA,MAAMA,IAAK,CAAC;AAAA,EACX,OAAAC,IAAQC;AAAA,EACR,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACJ,MAEE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACA,WAAWC;AAAA,MACVC,EAAE;AAAA,MACFA,EAAE,SAASP,CAAK,EAAE;AAAA,MAClB;AAAA,MACA;AAAA,MACAG;AAAA,IAAA;AAAA,IAEA,GAAGC;AAAA,IAEJ,UAAA,gBAAAC,EAAC,OAAA,EAAI,WAAWE,EAAE,SAAU,UAAAL,EAAA,CAAS;AAAA,EAAA;AAAA;AAKxCH,EAAG,cAAc;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as o, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { useId as m } from "react";
|
|
3
|
+
import { Tooltip as a } from "../hds/wrappers/tooltip.js";
|
|
4
|
+
import { FlightIcon as l } from "../flight-icon/index.js";
|
|
5
|
+
import r from "./table.module.scss.js";
|
|
6
|
+
const b = ({ tooltip: e, labelId: i }) => {
|
|
7
|
+
const t = m();
|
|
8
|
+
return /* @__PURE__ */ o(a, { text: e, children: /* @__PURE__ */ n(
|
|
9
|
+
"button",
|
|
10
|
+
{
|
|
11
|
+
type: "button",
|
|
12
|
+
className: r["th-button"],
|
|
13
|
+
"aria-labelledby": `${t} ${i}`,
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ o("span", { id: t, className: r["aria-label-hidden-segment"], children: "More information for" }),
|
|
16
|
+
/* @__PURE__ */ o(l, { name: "info" })
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
) });
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
b as ThButtonTooltip
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=th-button-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"th-button-tooltip.js","sources":["../../../src/components/table/th-button-tooltip.tsx"],"sourcesContent":["import { useId } from 'react'\nimport { Tooltip } from '../hds/wrappers/tooltip'\nimport { FlightIcon } from '../flight-icon'\nimport s from './table.module.scss'\n\ninterface TooltipProps {\n\ttooltip: string\n\tlabelId: string\n}\n\nexport const ThButtonTooltip = ({ tooltip, labelId }: TooltipProps) => {\n\tconst prefixLabelId = useId()\n\n\treturn (\n\t\t<Tooltip text={tooltip}>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tclassName={s['th-button']}\n\t\t\t\taria-labelledby={`${prefixLabelId} ${labelId}`}\n\t\t\t>\n\t\t\t\t<span id={prefixLabelId} className={s['aria-label-hidden-segment']}>\n\t\t\t\t\tMore information for\n\t\t\t\t</span>\n\t\t\t\t<FlightIcon name=\"info\" />\n\t\t\t</button>\n\t\t</Tooltip>\n\t)\n}\n"],"names":["ThButtonTooltip","tooltip","labelId","prefixLabelId","useId","jsx","Tooltip","jsxs","s","FlightIcon"],"mappings":";;;;;AAUO,MAAMA,IAAkB,CAAC,EAAE,SAAAC,GAAS,SAAAC,QAA4B;AACtE,QAAMC,IAAgBC,EAAA;AAEtB,SACC,gBAAAC,EAACC,GAAA,EAAQ,MAAML,GACd,UAAA,gBAAAM;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,MAAK;AAAA,MACL,WAAWC,EAAE,WAAW;AAAA,MACxB,mBAAiB,GAAGL,CAAa,IAAID,CAAO;AAAA,MAE5C,UAAA;AAAA,QAAA,gBAAAG,EAAC,UAAK,IAAIF,GAAe,WAAWK,EAAE,2BAA2B,GAAG,UAAA,wBAEpE;AAAA,QACA,gBAAAH,EAACI,GAAA,EAAW,MAAK,OAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAE1B;AAEF;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as s, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import f from "classnames";
|
|
3
|
+
import { DEFAULT_SCOPE as y, DEFAULT_ALIGNMENT as N } from "./utils.js";
|
|
4
|
+
import { useId as T } from "react";
|
|
5
|
+
import { ThButtonTooltip as g } from "./th-button-tooltip.js";
|
|
6
|
+
import t from "./table.module.scss.js";
|
|
7
|
+
const h = ({
|
|
8
|
+
align: l = N,
|
|
9
|
+
width: e,
|
|
10
|
+
scope: n = y,
|
|
11
|
+
tooltip: a,
|
|
12
|
+
isVisuallyHidden: i,
|
|
13
|
+
children: m,
|
|
14
|
+
className: p,
|
|
15
|
+
...c
|
|
16
|
+
}) => {
|
|
17
|
+
const r = T();
|
|
18
|
+
let o;
|
|
19
|
+
return i ? o = /* @__PURE__ */ s("span", { className: "sr-only", children: m }) : a ? o = /* @__PURE__ */ d("div", { className: t.content, children: [
|
|
20
|
+
/* @__PURE__ */ s("span", { id: r, children: m }),
|
|
21
|
+
/* @__PURE__ */ s(g, { tooltip: a, labelId: r })
|
|
22
|
+
] }) : o = /* @__PURE__ */ s("div", { className: t.content, children: m }), /* @__PURE__ */ s(
|
|
23
|
+
"th",
|
|
24
|
+
{
|
|
25
|
+
className: f(
|
|
26
|
+
t.th,
|
|
27
|
+
t[`align-${l}`],
|
|
28
|
+
"mds-typography-legacy-body-200",
|
|
29
|
+
"mds-typography-font-weight-semibold",
|
|
30
|
+
p
|
|
31
|
+
),
|
|
32
|
+
style: e ? { width: e, minWidth: e } : {},
|
|
33
|
+
...c,
|
|
34
|
+
scope: n,
|
|
35
|
+
children: o
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
h.displayName = "H.TH";
|
|
40
|
+
export {
|
|
41
|
+
h as TH
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=th.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"th.js","sources":["../../../src/components/table/th.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { DEFAULT_ALIGNMENT, DEFAULT_SCOPE } from './utils'\nimport { useId, type HTMLAttributes, type ReactNode } from 'react'\nimport { ThButtonTooltip } from './th-button-tooltip'\nimport type { HorizontalAlignment, Scope } from './utils'\nimport s from './table.module.scss'\n\nexport interface THProps extends HTMLAttributes<HTMLTableCellElement> {\n\t/**\n\t * Determines the horizontal content alignment (sometimes referred to as text alignment) for the column header.\n\t */\n\talign?: HorizontalAlignment\n\t/**\n\t * If used as the first item in a table body’s row, scope should be set to row for accessibility purposes.\n\t */\n\tscope?: Scope\n\t/**\n\t * Any valid CSS\n\t * If set, determines the column’s width.\n\t */\n\twidth?: string\n\t/**\n\t * Text string which will appear in the tooltip. May contain basic HTML tags for formatting text such as strong and em tags. Not intended for multi-paragraph text or other more complex content. May not contain interactive content such as links or buttons. The placement and offset are automatically set and can’t be overwritten.\n\t */\n\ttooltip?: string\n\t/**\n\t * If set to `true`, it visually hides the column’s text content (it will still be available to screen readers for accessibility).\n\t */\n\tisVisuallyHidden?: boolean\n\t/**\n\t * Elements passed as children are yielded as inner content of a `<th>` HTML element.\n\t */\n\tchildren: ReactNode\n}\n\nconst TH = ({\n\talign = DEFAULT_ALIGNMENT,\n\twidth,\n\tscope = DEFAULT_SCOPE,\n\ttooltip,\n\tisVisuallyHidden,\n\tchildren,\n\tclassName,\n\t...rest\n}: THProps) => {\n\tconst labelId = useId()\n\tlet content: React.ReactNode\n\n\tif (isVisuallyHidden) {\n\t\tcontent = <span className=\"sr-only\">{children}</span>\n\t} else if (tooltip) {\n\t\tcontent = (\n\t\t\t<div className={s.content}>\n\t\t\t\t<span id={labelId}>{children}</span>\n\t\t\t\t<ThButtonTooltip tooltip={tooltip} labelId={labelId} />\n\t\t\t</div>\n\t\t)\n\t} else {\n\t\tcontent = <div className={s.content}>{children}</div>\n\t}\n\n\treturn (\n\t\t<th\n\t\t\tclassName={classNames(\n\t\t\t\ts.th,\n\t\t\t\ts[`align-${align}`],\n\t\t\t\t'mds-typography-legacy-body-200',\n\t\t\t\t'mds-typography-font-weight-semibold',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={width ? { width, minWidth: width } : {}}\n\t\t\t{...rest}\n\t\t\tscope={scope}\n\t\t>\n\t\t\t{content}\n\t\t</th>\n\t)\n}\n\nTH.displayName = 'H.TH'\n\nexport { TH }\n"],"names":["TH","align","DEFAULT_ALIGNMENT","width","scope","DEFAULT_SCOPE","tooltip","isVisuallyHidden","children","className","rest","labelId","useId","content","jsx","jsxs","s","ThButtonTooltip","classNames"],"mappings":";;;;;;AAmCA,MAAMA,IAAK,CAAC;AAAA,EACX,OAAAC,IAAQC;AAAA,EACR,OAAAC;AAAA,EACA,OAAAC,IAAQC;AAAA,EACR,SAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACJ,MAAe;AACd,QAAMC,IAAUC,EAAA;AAChB,MAAIC;AAEJ,SAAIN,IACHM,IAAU,gBAAAC,EAAC,QAAA,EAAK,WAAU,WAAW,UAAAN,GAAS,IACpCF,IACVO,IACC,gBAAAE,EAAC,OAAA,EAAI,WAAWC,EAAE,SACjB,UAAA;AAAA,IAAA,gBAAAF,EAAC,QAAA,EAAK,IAAIH,GAAU,UAAAH,EAAA,CAAS;AAAA,IAC7B,gBAAAM,EAACG,GAAA,EAAgB,SAAAX,GAAkB,SAAAK,EAAA,CAAkB;AAAA,EAAA,GACtD,IAGDE,IAAU,gBAAAC,EAAC,OAAA,EAAI,WAAWE,EAAE,SAAU,UAAAR,GAAS,GAI/C,gBAAAM;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAWI;AAAA,QACVF,EAAE;AAAA,QACFA,EAAE,SAASf,CAAK,EAAE;AAAA,QAClB;AAAA,QACA;AAAA,QACAQ;AAAA,MAAA;AAAA,MAED,OAAON,IAAQ,EAAE,OAAAA,GAAO,UAAUA,EAAA,IAAU,CAAA;AAAA,MAC3C,GAAGO;AAAA,MACJ,OAAAN;AAAA,MAEC,UAAAS;AAAA,IAAA;AAAA,EAAA;AAGJ;AAEAb,EAAG,cAAc;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import t from "classnames";
|
|
3
|
+
import a from "./table.module.scss.js";
|
|
4
|
+
const e = ({ children: r, className: m, ...s }) => /* @__PURE__ */ o("tr", { className: t(a.tr, m), ...s, children: r });
|
|
5
|
+
e.displayName = "T.TR";
|
|
6
|
+
export {
|
|
7
|
+
e as TR
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=tr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tr.js","sources":["../../../src/components/table/tr.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport type { HTMLAttributes, ReactNode } from 'react'\nimport s from './table.module.scss'\n\nexport interface TRProps extends HTMLAttributes<HTMLTableRowElement> {\n\t/**\n\t * Elements passed as children are yielded as inner content of a `<tr>` HTML element.\n\t */\n\tchildren: ReactNode\n}\n\nconst TR = ({ children, className, ...rest }: TRProps) => {\n\treturn (\n\t\t<tr className={classNames(s.tr, className)} {...rest}>\n\t\t\t{children}\n\t\t</tr>\n\t)\n}\n\nTR.displayName = 'T.TR'\n\nexport { TR }\n"],"names":["TR","children","className","rest","jsx","classNames","s"],"mappings":";;;AAWA,MAAMA,IAAK,CAAC,EAAE,UAAAC,GAAU,WAAAC,GAAW,GAAGC,QAEpC,gBAAAC,EAAC,MAAA,EAAG,WAAWC,EAAWC,EAAE,IAAIJ,CAAS,GAAI,GAAGC,GAC9C,UAAAF,EAAA,CACF;AAIFD,EAAG,cAAc;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const e = "medium", o = ["default", "medium", "short", "tall"], A = (n) => {
|
|
2
|
+
const t = n;
|
|
3
|
+
return o.includes(t) ? t : e;
|
|
4
|
+
}, c = "top", s = ["baseline", "middle", "top"], T = (n) => {
|
|
5
|
+
const t = n;
|
|
6
|
+
return s.includes(t) ? t : c;
|
|
7
|
+
}, l = "left", i = ["left", "center", "right"], u = (n) => {
|
|
8
|
+
const t = n;
|
|
9
|
+
return i.includes(t) ? t : l;
|
|
10
|
+
}, r = "col", E = ["col", "row"], d = (n) => {
|
|
11
|
+
const t = n;
|
|
12
|
+
return E.includes(t) ? t : r;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
i as ALIGNMENTS,
|
|
16
|
+
l as DEFAULT_ALIGNMENT,
|
|
17
|
+
e as DEFAULT_DENSITY,
|
|
18
|
+
r as DEFAULT_SCOPE,
|
|
19
|
+
c as DEFAULT_VERTICAL_ALIGNMENT,
|
|
20
|
+
o as DENSITIES,
|
|
21
|
+
E as SCOPES,
|
|
22
|
+
s as VERTICAL_ALIGNMENTS,
|
|
23
|
+
A as getDensity,
|
|
24
|
+
u as getHorizontalAlignment,
|
|
25
|
+
d as getScope,
|
|
26
|
+
T as getVerticalAlignment
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/table/utils.ts"],"sourcesContent":["export const DEFAULT_DENSITY = 'medium'\nexport const DENSITIES = ['default', 'medium', 'short', 'tall'] as const\nexport type Density = (typeof DENSITIES)[number]\nexport const getDensity = (densityStr: string): Density => {\n\tconst density = densityStr as Density\n\treturn DENSITIES.includes(density) ? density : DEFAULT_DENSITY\n}\n\nexport const DEFAULT_VERTICAL_ALIGNMENT = 'top'\nexport const VERTICAL_ALIGNMENTS = ['baseline', 'middle', 'top'] as const\nexport type VerticalAlignment = (typeof VERTICAL_ALIGNMENTS)[number]\nexport const getVerticalAlignment = (valignStr: string): VerticalAlignment => {\n\tconst valign = valignStr as VerticalAlignment\n\treturn VERTICAL_ALIGNMENTS.includes(valign)\n\t\t? valign\n\t\t: DEFAULT_VERTICAL_ALIGNMENT\n}\n\nexport const DEFAULT_ALIGNMENT = 'left'\nexport const ALIGNMENTS = ['left', 'center', 'right'] as const\nexport type HorizontalAlignment = (typeof ALIGNMENTS)[number]\nexport const getHorizontalAlignment = (\n\talignStr: string\n): HorizontalAlignment => {\n\tconst align = alignStr as HorizontalAlignment\n\treturn ALIGNMENTS.includes(align) ? align : DEFAULT_ALIGNMENT\n}\n\nexport const DEFAULT_SCOPE = 'col'\nexport const SCOPES = ['col', 'row'] as const\nexport type Scope = (typeof SCOPES)[number]\nexport const getScope = (scopeStr: string): Scope => {\n\tconst scope = scopeStr as Scope\n\treturn SCOPES.includes(scope) ? scope : DEFAULT_SCOPE\n}\n"],"names":["DEFAULT_DENSITY","DENSITIES","getDensity","densityStr","density","DEFAULT_VERTICAL_ALIGNMENT","VERTICAL_ALIGNMENTS","getVerticalAlignment","valignStr","valign","DEFAULT_ALIGNMENT","ALIGNMENTS","getHorizontalAlignment","alignStr","align","DEFAULT_SCOPE","SCOPES","getScope","scopeStr","scope"],"mappings":"AAAO,MAAMA,IAAkB,UAClBC,IAAY,CAAC,WAAW,UAAU,SAAS,MAAM,GAEjDC,IAAa,CAACC,MAAgC;AAC1D,QAAMC,IAAUD;AAChB,SAAOF,EAAU,SAASG,CAAO,IAAIA,IAAUJ;AAChD,GAEaK,IAA6B,OAC7BC,IAAsB,CAAC,YAAY,UAAU,KAAK,GAElDC,IAAuB,CAACC,MAAyC;AAC7E,QAAMC,IAASD;AACf,SAAOF,EAAoB,SAASG,CAAM,IACvCA,IACAJ;AACJ,GAEaK,IAAoB,QACpBC,IAAa,CAAC,QAAQ,UAAU,OAAO,GAEvCC,IAAyB,CACrCC,MACyB;AACzB,QAAMC,IAAQD;AACd,SAAOF,EAAW,SAASG,CAAK,IAAIA,IAAQJ;AAC7C,GAEaK,IAAgB,OAChBC,IAAS,CAAC,OAAO,KAAK,GAEtBC,IAAW,CAACC,MAA4B;AACpD,QAAMC,IAAQD;AACd,SAAOF,EAAO,SAASG,CAAK,IAAIA,IAAQJ;AACzC;"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as u, jsxs as M } from "react/jsx-runtime";
|
|
3
|
+
import x from "classnames";
|
|
4
|
+
import { useState as a, useRef as T, useCallback as f, useEffect as d, useMemo as O } from "react";
|
|
5
|
+
import { TabPanel as S } from "./tab-panel.js";
|
|
6
|
+
import { Tab as U } from "./tab.js";
|
|
7
|
+
import { useTabsContext as q, TabsContext as B } from "./use-tabs-context.js";
|
|
8
|
+
import m from "./tabs.module.scss.js";
|
|
9
|
+
const F = ({
|
|
10
|
+
children: p,
|
|
11
|
+
onClickTab: r,
|
|
12
|
+
initialSelectedTabIndex: n = 0,
|
|
13
|
+
size: w = "medium",
|
|
14
|
+
className: I,
|
|
15
|
+
...k
|
|
16
|
+
}) => {
|
|
17
|
+
const [i, b] = a(
|
|
18
|
+
n
|
|
19
|
+
), s = T([]), l = T([]), [o, A] = a([]), [L, E] = a([]), [R, W] = a(0), [C, K] = a(0), c = T(null), h = f((t) => {
|
|
20
|
+
const e = s.current[t]?.parentNode;
|
|
21
|
+
e && e.scrollIntoView({
|
|
22
|
+
behavior: "smooth",
|
|
23
|
+
block: "nearest",
|
|
24
|
+
inline: "nearest"
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
27
|
+
d(() => {
|
|
28
|
+
b(n);
|
|
29
|
+
}, [n]), d(() => {
|
|
30
|
+
const t = s.current[i]?.parentElement;
|
|
31
|
+
if (t && c.current) {
|
|
32
|
+
const e = t.offsetLeft, v = t.offsetWidth;
|
|
33
|
+
K(e), W(v), c.current.scrollTo({
|
|
34
|
+
left: e,
|
|
35
|
+
behavior: "smooth"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, [s, i, h, c]), d(() => {
|
|
39
|
+
A(s.current.map((e) => e.id));
|
|
40
|
+
let t = 0;
|
|
41
|
+
s.current.forEach((e) => {
|
|
42
|
+
e.hasAttribute("data-is-selected") && t++;
|
|
43
|
+
}), t > 1 && console.error("Only one tab may use isSelected argument");
|
|
44
|
+
}, [s]), d(() => {
|
|
45
|
+
E(l.current.map((t) => t.id));
|
|
46
|
+
}, [l]);
|
|
47
|
+
const P = f(
|
|
48
|
+
(t, e) => {
|
|
49
|
+
b(t), h(t), typeof r == "function" && r(e, t);
|
|
50
|
+
},
|
|
51
|
+
[r, h]
|
|
52
|
+
), y = f(
|
|
53
|
+
(t, e) => {
|
|
54
|
+
e.preventDefault(), s.current[t].focus();
|
|
55
|
+
},
|
|
56
|
+
[]
|
|
57
|
+
), g = f(
|
|
58
|
+
(t, e) => {
|
|
59
|
+
const v = "ArrowLeft", j = "ArrowRight", $ = "Enter", D = " ";
|
|
60
|
+
if (e.key === j) {
|
|
61
|
+
const N = (t + 1) % o.length;
|
|
62
|
+
y(N, e);
|
|
63
|
+
} else if (e.key === v) {
|
|
64
|
+
const N = (t + o.length - 1) % o.length;
|
|
65
|
+
y(N, e);
|
|
66
|
+
} else (e.key === $ || e.key === D) && b(t);
|
|
67
|
+
},
|
|
68
|
+
[y, o.length]
|
|
69
|
+
), V = O(
|
|
70
|
+
() => ({
|
|
71
|
+
tabNodes: s,
|
|
72
|
+
tabIds: o,
|
|
73
|
+
panelNodes: l,
|
|
74
|
+
panelIds: L,
|
|
75
|
+
selectedTabIndex: i,
|
|
76
|
+
onClick: P,
|
|
77
|
+
onKeyUp: g,
|
|
78
|
+
size: w,
|
|
79
|
+
tabsListRef: c
|
|
80
|
+
}),
|
|
81
|
+
[
|
|
82
|
+
s,
|
|
83
|
+
o,
|
|
84
|
+
l,
|
|
85
|
+
L,
|
|
86
|
+
i,
|
|
87
|
+
P,
|
|
88
|
+
g,
|
|
89
|
+
w,
|
|
90
|
+
c
|
|
91
|
+
]
|
|
92
|
+
);
|
|
93
|
+
return /* @__PURE__ */ u(B.Provider, { value: V, children: /* @__PURE__ */ u(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: x(m.tabs, I),
|
|
97
|
+
...k,
|
|
98
|
+
style: {
|
|
99
|
+
"--indicator-left-pos": `${C}px`,
|
|
100
|
+
"--indicator-width": `${R}px`
|
|
101
|
+
},
|
|
102
|
+
children: p
|
|
103
|
+
}
|
|
104
|
+
) });
|
|
105
|
+
}, G = ({ children: p, className: r }) => {
|
|
106
|
+
const { tabsListRef: n } = q();
|
|
107
|
+
return /* @__PURE__ */ u("div", { className: x(m["tablist-wrapper"], r), children: /* @__PURE__ */ M("ul", { className: m.tablist, role: "tablist", ref: n, children: [
|
|
108
|
+
p,
|
|
109
|
+
/* @__PURE__ */ u("li", { className: m.indicator, role: "presentation" })
|
|
110
|
+
] }) });
|
|
111
|
+
}, z = { Provider: F, TabList: G, Panel: S, Tab: U };
|
|
112
|
+
export {
|
|
113
|
+
z as Tabs
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/tabs/index.tsx"],"sourcesContent":["'use client'\n\nimport classNames from 'classnames'\nimport {\n\ttype ReactNode,\n\ttype HTMLAttributes,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n} from 'react'\nimport { TabPanel } from './tab-panel'\nimport { Tab } from './tab'\nimport { TabsContext, useTabsContext } from './use-tabs-context'\nimport s from './tabs.module.scss'\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n\tonClickTab?: (event: MouseEvent<HTMLButtonElement>, tabIndex: number) => void\n\tinitialSelectedTabIndex?: number\n\tsize?: 'medium' | 'large'\n}\n\nconst Provider = ({\n\tchildren,\n\tonClickTab,\n\tinitialSelectedTabIndex = 0,\n\tsize = 'medium',\n\tclassName,\n\t...rest\n}: TabsProps) => {\n\tconst [selectedTabIndex, setSelectedTabIndex] = useState(\n\t\tinitialSelectedTabIndex\n\t)\n\tconst tabNodes = useRef<Array<HTMLButtonElement>>([])\n\tconst panelNodes = useRef<Array<HTMLDivElement>>([])\n\tconst [tabIds, setTabIds] = useState<Array<string>>([])\n\tconst [panelIds, setPanelIds] = useState<Array<string>>([])\n\tconst [indicatorWidth, setIndicatorWidth] = useState(0)\n\tconst [indicatorLeftPosition, setIndicatorLeftPosition] = useState(0)\n\tconst tabsListRef = useRef<HTMLUListElement | null>(null)\n\n\tconst scrollIntoView = useCallback((tabIndex: number) => {\n\t\t// Scroll Tab into view if it's out of view\n\t\tconst parentNode = tabNodes.current[tabIndex]\n\t\t\t?.parentNode as HTMLElement | null\n\t\tif (parentNode) {\n\t\t\tparentNode.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'nearest',\n\t\t\t})\n\t\t}\n\t}, [])\n\n\tuseEffect(() => {\n\t\tsetSelectedTabIndex(initialSelectedTabIndex)\n\t}, [initialSelectedTabIndex])\n\n\tuseEffect(() => {\n\t\tconst tabElem = tabNodes.current[selectedTabIndex]?.parentElement\n\t\tif (tabElem && tabsListRef.current) {\n\t\t\tconst tabLeftPos = tabElem.offsetLeft\n\t\t\tconst tabWidth = tabElem.offsetWidth\n\t\t\tsetIndicatorLeftPosition(tabLeftPos)\n\t\t\tsetIndicatorWidth(tabWidth)\n\t\t\ttabsListRef.current.scrollTo({\n\t\t\t\tleft: tabLeftPos,\n\t\t\t\tbehavior: 'smooth',\n\t\t\t})\n\t\t}\n\t}, [tabNodes, selectedTabIndex, scrollIntoView, tabsListRef])\n\n\tuseEffect(() => {\n\t\tsetTabIds(tabNodes.current.map((tab) => tab.id))\n\n\t\tlet selectedCount = 0\n\n\t\ttabNodes.current.forEach((tabElement) => {\n\t\t\tif (tabElement.hasAttribute('data-is-selected')) {\n\t\t\t\tselectedCount++\n\t\t\t}\n\t\t})\n\n\t\tif (selectedCount > 1) {\n\t\t\tconsole.error('Only one tab may use isSelected argument')\n\t\t}\n\t}, [tabNodes])\n\n\tuseEffect(() => {\n\t\tsetPanelIds(panelNodes.current.map((tab) => tab.id))\n\t}, [panelNodes])\n\n\tconst onClick = useCallback(\n\t\t(tabIndex: number, event: MouseEvent<HTMLButtonElement>) => {\n\t\t\tsetSelectedTabIndex(tabIndex)\n\n\t\t\tscrollIntoView(tabIndex)\n\n\t\t\t// invoke the callback function if it's provided as argument\n\t\t\tif (typeof onClickTab === 'function') {\n\t\t\t\tonClickTab(event, tabIndex)\n\t\t\t}\n\t\t},\n\t\t[onClickTab, scrollIntoView]\n\t)\n\n\t// Focus tab for keyboard & mouse navigation:\n\tconst focusTab = useCallback(\n\t\t(tabIndex: number, e: KeyboardEvent<HTMLButtonElement>) => {\n\t\t\te.preventDefault()\n\t\t\ttabNodes.current[tabIndex].focus()\n\t\t},\n\t\t[]\n\t)\n\n\tconst onKeyUp = useCallback(\n\t\t(tabIndex: number, e: KeyboardEvent<HTMLButtonElement>) => {\n\t\t\tconst leftArrow = 'ArrowLeft'\n\t\t\tconst rightArrow = 'ArrowRight'\n\t\t\tconst enterKey = 'Enter'\n\t\t\tconst spaceKey = ' '\n\n\t\t\tif (e.key === rightArrow) {\n\t\t\t\tconst nextTabIndex = (tabIndex + 1) % tabIds.length\n\t\t\t\tfocusTab(nextTabIndex, e)\n\t\t\t} else if (e.key === leftArrow) {\n\t\t\t\tconst prevTabIndex = (tabIndex + tabIds.length - 1) % tabIds.length\n\t\t\t\tfocusTab(prevTabIndex, e)\n\t\t\t} else if (e.key === enterKey || e.key === spaceKey) {\n\t\t\t\tsetSelectedTabIndex(tabIndex)\n\t\t\t}\n\t\t},\n\t\t[focusTab, tabIds.length]\n\t)\n\n\tconst contextValue = useMemo(\n\t\t() => ({\n\t\t\ttabNodes,\n\t\t\ttabIds,\n\t\t\tpanelNodes,\n\t\t\tpanelIds,\n\t\t\tselectedTabIndex,\n\t\t\tonClick,\n\t\t\tonKeyUp,\n\t\t\tsize,\n\t\t\ttabsListRef,\n\t\t}),\n\t\t[\n\t\t\ttabNodes,\n\t\t\ttabIds,\n\t\t\tpanelNodes,\n\t\t\tpanelIds,\n\t\t\tselectedTabIndex,\n\t\t\tonClick,\n\t\t\tonKeyUp,\n\t\t\tsize,\n\t\t\ttabsListRef,\n\t\t]\n\t)\n\n\treturn (\n\t\t<TabsContext.Provider value={contextValue}>\n\t\t\t<div\n\t\t\t\tclassName={classNames(s.tabs, className)}\n\t\t\t\t{...rest}\n\t\t\t\tstyle={{\n\t\t\t\t\t['--indicator-left-pos' as string]: `${indicatorLeftPosition}px`,\n\t\t\t\t\t['--indicator-width' as string]: `${indicatorWidth}px`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</TabsContext.Provider>\n\t)\n}\n\ninterface TabsListProps {\n\t/**\n\t * `<Tabs.Tab />` as children\n\t */\n\tchildren: ReactNode\n\tclassName?: string\n}\n\nconst TabList = ({ children, className }: TabsListProps) => {\n\tconst { tabsListRef } = useTabsContext()\n\treturn (\n\t\t<div className={classNames(s['tablist-wrapper'], className)}>\n\t\t\t<ul className={s.tablist} role=\"tablist\" ref={tabsListRef}>\n\t\t\t\t{children}\n\t\t\t\t<li className={s.indicator} role=\"presentation\"></li>\n\t\t\t</ul>\n\t\t</div>\n\t)\n}\n\nconst Tabs = { Provider, TabList, Panel: TabPanel, Tab }\n\nexport type { TabsListProps }\nexport { Tabs }\n"],"names":["Provider","children","onClickTab","initialSelectedTabIndex","size","className","rest","selectedTabIndex","setSelectedTabIndex","useState","tabNodes","useRef","panelNodes","tabIds","setTabIds","panelIds","setPanelIds","indicatorWidth","setIndicatorWidth","indicatorLeftPosition","tabsListRef","scrollIntoView","useCallback","tabIndex","parentNode","useEffect","tabElem","tabLeftPos","tabWidth","setIndicatorLeftPosition","tab","selectedCount","onClick","event","focusTab","onKeyUp","leftArrow","rightArrow","enterKey","spaceKey","nextTabIndex","prevTabIndex","contextValue","useMemo","jsx","TabsContext","classNames","s","jsxs"],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
3
|
+
import { useId as f, useMemo as o } from "react";
|
|
4
|
+
import u from "classnames";
|
|
5
|
+
import { useTabsContext as I } from "./use-tabs-context.js";
|
|
6
|
+
import x from "./tabs.module.scss.js";
|
|
7
|
+
const y = ({ children: r, className: d, ...l }) => {
|
|
8
|
+
const { panelIds: n, tabIds: t, selectedTabIndex: a, panelNodes: c } = I(), s = "panel-" + f(), e = o(
|
|
9
|
+
() => n.indexOf(s),
|
|
10
|
+
[n, s]
|
|
11
|
+
), i = o(
|
|
12
|
+
() => e > -1 ? t[e] : void 0,
|
|
13
|
+
[t, e]
|
|
14
|
+
), m = o(
|
|
15
|
+
() => e === a,
|
|
16
|
+
[e, a]
|
|
17
|
+
);
|
|
18
|
+
return /* @__PURE__ */ b(
|
|
19
|
+
"section",
|
|
20
|
+
{
|
|
21
|
+
className: u(x.panel, d),
|
|
22
|
+
...l,
|
|
23
|
+
role: "tabpanel",
|
|
24
|
+
"aria-labelledby": i,
|
|
25
|
+
id: s,
|
|
26
|
+
hidden: !m,
|
|
27
|
+
ref: (p) => c.current.push(p),
|
|
28
|
+
children: r
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
y as TabPanel
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=tab-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-panel.js","sources":["../../../src/components/tabs/tab-panel.tsx"],"sourcesContent":["'use client'\n\nimport { useId, useMemo, type HTMLAttributes } from 'react'\nimport classNames from 'classnames'\nimport { useTabsContext } from './use-tabs-context'\nimport s from './tabs.module.scss'\n\ntype TabPanelProps = HTMLAttributes<HTMLDivElement>\n\nconst TabPanel = ({ children, className, ...rest }: TabPanelProps) => {\n\tconst { panelIds, tabIds, selectedTabIndex, panelNodes } = useTabsContext()\n\tconst panelId = 'panel-' + useId()\n\n\tconst nodeIndex = useMemo(\n\t\t() => panelIds.indexOf(panelId),\n\t\t[panelIds, panelId]\n\t)\n\n\tconst tabId = useMemo(\n\t\t() => (nodeIndex > -1 ? tabIds[nodeIndex] : undefined),\n\t\t[tabIds, nodeIndex]\n\t)\n\n\tconst isSelected = useMemo(\n\t\t() => nodeIndex === selectedTabIndex,\n\t\t[nodeIndex, selectedTabIndex]\n\t)\n\n\treturn (\n\t\t<section\n\t\t\tclassName={classNames(s.panel, className)}\n\t\t\t{...rest}\n\t\t\trole=\"tabpanel\"\n\t\t\taria-labelledby={tabId}\n\t\t\tid={panelId}\n\t\t\thidden={!isSelected}\n\t\t\tref={(el: HTMLDivElement) => panelNodes.current.push(el)}\n\t\t>\n\t\t\t{children}\n\t\t</section>\n\t)\n}\n\nexport type { TabPanelProps }\nexport { TabPanel }\n"],"names":["TabPanel","children","className","rest","panelIds","tabIds","panelNodes","useTabsContext","panelId","useId","useMemo","tabId","nodeIndex","isSelected","selectedTabIndex","jsx","classNames","s","el"],"mappings":";;;;;;AAUC,MAAAA,IAAQ,CAAA,EAAU,UAAAC,GAAQ,WAAAC,GAAA,GAAAC,EAAkB,MAAA;AAC5C,QAAM,EAAA,UAAAC,GAAU,QAAAC,wBAAiB,YAAAC,EAAA,IAAAC,EAAA,GAE3BC,IAAA,WAAYC,EAAA,OACFC;AAAA,IACf,MAACN,EAAU,QAAOI,CAAA;AAAA,IACnB,CAAAJ,GAAAI,CAAA;AAAA,EAEA,GACCG,IAAOD;AAAA,IACP,MAACE,IAAiB,KAAAP,EAAAO,CAAA,IAAA;AAAA,IACnB,CAAAP,GAAAO,CAAA;AAAA,EAEA,GACCC,IAAMH;AAAA,IACN,MAACE,MAAWE;AAAA,IACb,CAAAF,GAAAE,CAAA;AAAA,EAEA;AACC,SAAC,gBAAAC;AAAA,IAAA;AAAA,IAAA;AAAA,MAEC,WAAGC,EAAAC,EAAA,OAAAf,CAAA;AAAA,MACJ,GAAAC;AAAA,MACA,MAAA;AAAA,MACA,mBAAIQ;AAAA,MACJ,IAAAH;AAAA,MACA,QAAM,CAAAK;AAAA,MAEL,KAAA,CAAAK,MAAAZ,EAAA,QAAA,KAAAY,CAAA;AAAA,MAAA,UAAAjB;AAAA,IACF;AAAA,EAEF;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as N } from "react/jsx-runtime";
|
|
3
|
+
import c from "classnames";
|
|
4
|
+
import { BadgeCount as z } from "../badge-count/index.js";
|
|
5
|
+
import { useId as T, useMemo as p } from "react";
|
|
6
|
+
import { useTabsContext as j } from "./use-tabs-context.js";
|
|
7
|
+
import { FlightIcon as k } from "../flight-icon/index.js";
|
|
8
|
+
import o from "./tabs.module.scss.js";
|
|
9
|
+
const M = ({
|
|
10
|
+
count: n,
|
|
11
|
+
icon: i,
|
|
12
|
+
isSelected: b,
|
|
13
|
+
children: y,
|
|
14
|
+
className: u,
|
|
15
|
+
trackingKey: f,
|
|
16
|
+
tabIndicatorTheme: g = "primary",
|
|
17
|
+
...x
|
|
18
|
+
}) => {
|
|
19
|
+
const { tabNodes: h, tabIds: d, selectedTabIndex: m, onClick: I, onKeyUp: C, size: l } = j(), s = "tab-" + T(), t = p(() => d.indexOf(s), [d, s]), a = p(
|
|
20
|
+
() => t === m,
|
|
21
|
+
[t, m]
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ r(
|
|
24
|
+
"li",
|
|
25
|
+
{
|
|
26
|
+
className: c(
|
|
27
|
+
o.tab,
|
|
28
|
+
o[g],
|
|
29
|
+
{
|
|
30
|
+
[o.selected]: a
|
|
31
|
+
},
|
|
32
|
+
u
|
|
33
|
+
),
|
|
34
|
+
...x,
|
|
35
|
+
role: "presentation",
|
|
36
|
+
children: /* @__PURE__ */ N(
|
|
37
|
+
"button",
|
|
38
|
+
{
|
|
39
|
+
className: c(
|
|
40
|
+
o["tab-button"],
|
|
41
|
+
"mds-typography-font-weight-medium",
|
|
42
|
+
{
|
|
43
|
+
"mds-typography-legacy-body-200": l === "medium",
|
|
44
|
+
"mds-typography-legacy-body-300": l === "large"
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
role: "tab",
|
|
48
|
+
type: "button",
|
|
49
|
+
id: s,
|
|
50
|
+
"aria-selected": a,
|
|
51
|
+
tabIndex: a ? void 0 : -1,
|
|
52
|
+
onClick: (e) => I(t, e),
|
|
53
|
+
onKeyUp: (e) => C(t, e),
|
|
54
|
+
"data-is-selected": b,
|
|
55
|
+
"data-analytics": f,
|
|
56
|
+
ref: (e) => h.current.push(e),
|
|
57
|
+
children: [
|
|
58
|
+
i && /* @__PURE__ */ r(k, { name: i, size: 16, role: "presentation" }),
|
|
59
|
+
y,
|
|
60
|
+
n && /* @__PURE__ */ r(z, { text: n, size: "small", role: "presentation" })
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
M as Tab
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab.js","sources":["../../../src/components/tabs/tab.tsx"],"sourcesContent":["'use client'\n\nimport classNames from 'classnames'\nimport { BadgeCount } from '../badge-count'\nimport { useId, type HTMLAttributes, useMemo } from 'react'\nimport { useTabsContext } from './use-tabs-context'\nimport type { FlightIconName } from '../flight-icon'\nimport { FlightIcon } from '../flight-icon'\nimport s from './tabs.module.scss'\n\ninterface TabProps extends HTMLAttributes<HTMLLIElement> {\n\ttabIndicatorTheme?: 'primary' | 'secondary'\n\t/**\n\t * Displays a count indicator in the tab. Accepts the text value that should go in Badge Count. (optional)\n\t */\n\tcount?: string\n\t/**\n\t * Displays an icon in the tab. (optional)\n\t */\n\ticon?: FlightIconName\n\t/**\n\t * Customizes the initial tab to display when the page is loaded. The first tab is selected on page load by default. (optional)\n\t */\n\tisSelected?: boolean\n\t/**\n\t * Used to append analytics and tracking related data attributes to any interactive element internal to this component.\n\t */\n\ttrackingKey?: string\n}\n\nconst Tab = ({\n\tcount,\n\ticon,\n\tisSelected: isInitialTab,\n\tchildren,\n\tclassName,\n\ttrackingKey,\n\ttabIndicatorTheme = 'primary',\n\t...rest\n}: TabProps) => {\n\tconst { tabNodes, tabIds, selectedTabIndex, onClick, onKeyUp, size } =\n\t\tuseTabsContext()\n\tconst tabId = 'tab-' + useId()\n\n\tconst nodeIndex = useMemo(() => tabIds.indexOf(tabId), [tabIds, tabId])\n\n\tconst isSelected = useMemo(\n\t\t() => nodeIndex === selectedTabIndex,\n\t\t[nodeIndex, selectedTabIndex]\n\t)\n\n\treturn (\n\t\t<li\n\t\t\tclassName={classNames(\n\t\t\t\ts.tab,\n\t\t\t\ts[tabIndicatorTheme],\n\t\t\t\t{\n\t\t\t\t\t[s.selected]: isSelected,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\t{...rest}\n\t\t\trole=\"presentation\"\n\t\t>\n\t\t\t<button\n\t\t\t\tclassName={classNames(\n\t\t\t\t\ts['tab-button'],\n\t\t\t\t\t'mds-typography-font-weight-medium',\n\t\t\t\t\t{\n\t\t\t\t\t\t['mds-typography-legacy-body-200']: size === 'medium',\n\t\t\t\t\t\t['mds-typography-legacy-body-300']: size === 'large',\n\t\t\t\t\t}\n\t\t\t\t)}\n\t\t\t\trole=\"tab\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tid={tabId}\n\t\t\t\taria-selected={isSelected}\n\t\t\t\ttabIndex={!isSelected ? -1 : undefined}\n\t\t\t\tonClick={(e) => onClick(nodeIndex, e)}\n\t\t\t\tonKeyUp={(e) => onKeyUp(nodeIndex, e)}\n\t\t\t\tdata-is-selected={isInitialTab}\n\t\t\t\tdata-analytics={trackingKey}\n\t\t\t\tref={(el: HTMLButtonElement) => tabNodes.current.push(el)}\n\t\t\t>\n\t\t\t\t{icon && <FlightIcon name={icon} size={16} role=\"presentation\" />}\n\n\t\t\t\t{children}\n\n\t\t\t\t{count && <BadgeCount text={count} size=\"small\" role=\"presentation\" />}\n\t\t\t</button>\n\t\t</li>\n\t)\n}\n\nexport type { TabProps }\nexport { Tab }\n"],"names":["Tab","count","icon","isInitialTab","children","className","trackingKey","tabIndicatorTheme","rest","tabNodes","tabIds","onClick","onKeyUp","size","useTabsContext","tabId","nodeIndex","useMemo","isSelected","selectedTabIndex","jsx","classNames","s","jsxs","el","FlightIcon","BadgeCount"],"mappings":";;;;;;;;AA8Ba,MACZA,IAAA,CAAA;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,mBAAAC,IAAG;AAAA,EACJ,GAAAC;AACC;AAEA,QAAM,EAAA,UAAAC,GAAQ,QAAAC,wBAAe,SAAAC,GAAA,SAAAC,GAAA,MAAAC,EAAA,IAAAC,EAAA,GAEvBC,IAAA,WAAoB,GAEpBC,IAAAC,EAAa,MAAAP,EAAA,QAAAK,CAAA,GAAA,CAAAL,GAAAK,CAAA,CAAA,GAClBG,IAAMD;AAAA,IACN,MAACD,MAAWG;AAAA,IACb,CAAAH,GAAAG,CAAA;AAAA,EAEA;AACC,SAAC,gBAAAC;AAAA,IAAA;AAAA,IAAA;AAAA,MACW,WACRC;AAAA,QACFC,EAAE;AAAA,QACFA,EAAAf,CAAA;AAAA,QAAA;AAAA,UAEA,CAAAe,EAAA,QAAA,GAAAJ;AAAA,QACA;AAAA,QACDb;AAAA,MACC;AAAA,MACD,GAAAG;AAAA,MAEA,MAAA;AAAA,MAAA,UAAC,gBAAAe;AAAA,QAAA;AAAA,QAAA;AAAA,UACW,WACRF;AAAA,YACFC,EAAA,YAAA;AAAA,YACA;AAAA,YAAA;AAAA,cAEE,kCAAmCT,MAAS;AAAA,cAAA,kCAAAA,MAAA;AAAA,YAE/C;AAAA,UACA;AAAA,UACA,MAAK;AAAA,UACL,MAAI;AAAA,UACJ,IAAAE;AAAA,UACA;UACA,UAAUG,IAAc,SAAA;AAAA,UACxB,SAAS,CAAC,MAAMP,EAAQK,GAAW,CAAC;AAAA,UACpC,SAAA,CAAA,MAAAJ,EAAkBI,GAAA,CAAA;AAAA,UAClB,oBAAgBb;AAAA,UAChB,kBAAgCG;AAAA,UAE/B,YAAAG,EAAA,QAAA,KAAAe,CAAA;AAAA,UAAA,UAAA;AAAA,YAEAtB,KAAA,gBAAAkB,EAAAK,GAAA,EAAA,MAAAvB,GAAA,MAAA,IAAA,MAAA,eAAA,CAAA;AAAA,YAEAE;AAAA,YAAmEH,KAAA,gBAAAmB,EAAAM,GAAA,EAAA,MAAAzB,GAAA,MAAA,SAAA,MAAA,eAAA,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACrE;AAAA,IACD;AAAA,EAEF;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const t = "tablist__sKiEs", a = "tab__qi523", s = "primary__iGc9C", e = "selected__SVr0E", n = "indicator__OHxre", r = "secondary__qlHsL", c = "panel__G8tI0", _ = {
|
|
2
|
+
"tablist-wrapper": "tablist-wrapper__nF28e",
|
|
3
|
+
tablist: t,
|
|
4
|
+
tab: a,
|
|
5
|
+
primary: s,
|
|
6
|
+
selected: e,
|
|
7
|
+
indicator: n,
|
|
8
|
+
secondary: r,
|
|
9
|
+
"tab-button": "tab-button__qI9wt",
|
|
10
|
+
panel: c
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
_ as default,
|
|
14
|
+
n as indicator,
|
|
15
|
+
c as panel,
|
|
16
|
+
s as primary,
|
|
17
|
+
r as secondary,
|
|
18
|
+
e as selected,
|
|
19
|
+
a as tab,
|
|
20
|
+
t as tablist
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=tabs.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext as e, useContext as o } from "react";
|
|
3
|
+
const n = e(
|
|
4
|
+
void 0
|
|
5
|
+
);
|
|
6
|
+
function s() {
|
|
7
|
+
const t = o(n);
|
|
8
|
+
if (t === void 0)
|
|
9
|
+
throw new Error("useTabsContext must be used within a TabsContext.Provider");
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
n as TabsContext,
|
|
14
|
+
s as useTabsContext
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=use-tabs-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tabs-context.js","sources":["../../../src/components/tabs/use-tabs-context.ts"],"sourcesContent":["'use client'\n\nimport {\n\ttype MutableRefObject,\n\ttype MouseEvent,\n\ttype KeyboardEvent,\n\tcreateContext,\n\tuseContext,\n} from 'react'\n\ninterface TabsContextState {\n\ttabNodes: MutableRefObject<Array<HTMLButtonElement>>\n\tpanelNodes: MutableRefObject<Array<HTMLDivElement>>\n\ttabIds: Array<string>\n\tpanelIds: Array<string>\n\tselectedTabIndex: number\n\tonClick: (tabIndex: number, event: MouseEvent<HTMLButtonElement>) => void\n\tonKeyUp: (tabIndex: number, event: KeyboardEvent<HTMLButtonElement>) => void\n\tsize: 'medium' | 'large'\n\ttabsListRef: MutableRefObject<HTMLUListElement | null>\n}\n\nexport const TabsContext = createContext<TabsContextState | undefined>(\n\tundefined\n)\n\nexport function useTabsContext(): TabsContextState {\n\tconst context = useContext(TabsContext)\n\tif (context === undefined) {\n\t\tthrow new Error('useTabsContext must be used within a TabsContext.Provider')\n\t}\n\treturn context\n}\n"],"names":["TabsContext","createContext","useTabsContext","context","useContext"],"mappings":";;AAsB2B,MAC1BA,IAAAC;AAAA,EACD;AAEO;AACN,SAAMC,IAAU;AAChB,QAAIC,IAAYC,EAAWJ,CAAA;AAC1B,MAAAG,MAAU;AACX,UAAA,IAAA,MAAA,2DAAA;AAED,SAAAA;;"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import l from "classnames";
|
|
3
|
+
import { createElement as e } from "react";
|
|
4
|
+
import m from "./style.module.scss.js";
|
|
5
|
+
const b = [
|
|
6
|
+
"primary",
|
|
7
|
+
"strong",
|
|
8
|
+
"faint",
|
|
9
|
+
"disabled",
|
|
10
|
+
"high-contrast",
|
|
11
|
+
"action",
|
|
12
|
+
"action-hover",
|
|
13
|
+
"action-active",
|
|
14
|
+
"highlight",
|
|
15
|
+
"highlight-on-surface",
|
|
16
|
+
"highlight-high-contrast",
|
|
17
|
+
"success",
|
|
18
|
+
"success-on-surface",
|
|
19
|
+
"success-high-contrast",
|
|
20
|
+
"warning",
|
|
21
|
+
"warning-on-surface",
|
|
22
|
+
"warning-high-contrast",
|
|
23
|
+
"critical",
|
|
24
|
+
"critical-on-surface",
|
|
25
|
+
"critical-high-contrast"
|
|
26
|
+
], B = ["regular", "medium", "semibold", "bold"];
|
|
27
|
+
function f(r, o) {
|
|
28
|
+
return {
|
|
29
|
+
"hds-body": `mds-typography-legacy-body-${o}`,
|
|
30
|
+
code: `mds-typography-code-${o}`,
|
|
31
|
+
"display-expressive": `mds-typography-display-expressive-${o}`,
|
|
32
|
+
label: "mds-typography-label",
|
|
33
|
+
body: `mds-typography-body-${o}`
|
|
34
|
+
}[r];
|
|
35
|
+
}
|
|
36
|
+
const n = ({
|
|
37
|
+
tag: r,
|
|
38
|
+
group: o,
|
|
39
|
+
size: s = "200",
|
|
40
|
+
weight: a,
|
|
41
|
+
align: c,
|
|
42
|
+
color: t,
|
|
43
|
+
children: p,
|
|
44
|
+
className: g,
|
|
45
|
+
...d
|
|
46
|
+
}) => {
|
|
47
|
+
const h = r ?? "span", u = f(o, s), i = b.includes(t);
|
|
48
|
+
return /* @__PURE__ */ y(
|
|
49
|
+
h,
|
|
50
|
+
{
|
|
51
|
+
className: l(
|
|
52
|
+
u,
|
|
53
|
+
{
|
|
54
|
+
[m[`align-${c}`]]: c,
|
|
55
|
+
[`mds-typography-font-weight-${a}`]: a,
|
|
56
|
+
[`mds-foreground-${t}`]: t && i
|
|
57
|
+
},
|
|
58
|
+
g
|
|
59
|
+
),
|
|
60
|
+
style: t && !i ? { color: t } : {},
|
|
61
|
+
...d,
|
|
62
|
+
children: p
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}, T = ({
|
|
66
|
+
size: r = "300",
|
|
67
|
+
...o
|
|
68
|
+
}) => e(n, {
|
|
69
|
+
...o,
|
|
70
|
+
size: r,
|
|
71
|
+
group: "body"
|
|
72
|
+
}), x = ({
|
|
73
|
+
size: r = "200",
|
|
74
|
+
...o
|
|
75
|
+
}) => e(n, {
|
|
76
|
+
...o,
|
|
77
|
+
size: r,
|
|
78
|
+
group: "display-expressive"
|
|
79
|
+
}), v = (r) => e(n, {
|
|
80
|
+
...r,
|
|
81
|
+
group: "label"
|
|
82
|
+
}), $ = ({
|
|
83
|
+
size: r = "200",
|
|
84
|
+
weight: o = "regular",
|
|
85
|
+
...s
|
|
86
|
+
}) => e(n, {
|
|
87
|
+
...s,
|
|
88
|
+
size: r,
|
|
89
|
+
weight: o,
|
|
90
|
+
group: "hds-body"
|
|
91
|
+
}), E = ({
|
|
92
|
+
size: r = "200",
|
|
93
|
+
weight: o = "regular",
|
|
94
|
+
...s
|
|
95
|
+
}) => e(n, {
|
|
96
|
+
...s,
|
|
97
|
+
size: r,
|
|
98
|
+
weight: o,
|
|
99
|
+
group: "code"
|
|
100
|
+
}), D = {
|
|
101
|
+
Body: T,
|
|
102
|
+
DisplayExpressive: x,
|
|
103
|
+
Label: v,
|
|
104
|
+
HDSBody: $,
|
|
105
|
+
Code: E
|
|
106
|
+
};
|
|
107
|
+
export {
|
|
108
|
+
b as TEXT_COLORS,
|
|
109
|
+
B as TEXT_WEIGHTS,
|
|
110
|
+
D as Text
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=index.js.map
|