@chassis-ui/react 0.1.3 → 0.2.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/dist/accordion.d.ts +2 -0
- package/dist/accordion.js +1 -0
- package/dist/autocomplete.d.ts +2 -0
- package/dist/autocomplete.js +1 -0
- package/dist/avatar.d.ts +2 -0
- package/dist/avatar.js +1 -0
- package/dist/badge.d.ts +2 -0
- package/dist/badge.js +1 -0
- package/dist/breadcrumb.d.ts +2 -0
- package/dist/breadcrumb.js +1 -0
- package/dist/button-group.d.ts +2 -0
- package/dist/button-group.js +1 -0
- package/dist/button.d.ts +3 -0
- package/dist/button.js +1 -0
- package/dist/calendar.d.ts +3 -0
- package/dist/calendar.js +1 -0
- package/dist/card.d.ts +2 -0
- package/dist/card.js +1 -0
- package/dist/carousel.d.ts +2 -0
- package/dist/carousel.js +1 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +1 -0
- package/dist/chip-input.d.ts +2 -0
- package/dist/chip-input.js +1 -0
- package/dist/chip.d.ts +2 -0
- package/dist/chip.js +1 -0
- package/dist/chunks/Button-Cptd4Yk7.d.ts +65 -0
- package/dist/chunks/Button-I0aUy5h-.js +1 -0
- package/dist/chunks/Chip-D0Cw0mAr.js +1 -0
- package/dist/chunks/CloseButton-DJM7FRKh.js +1 -0
- package/dist/chunks/ComboboxItem-C9TpoJOI.d.ts +54 -0
- package/dist/chunks/ComboboxListBox-BhO8uRNg.js +1 -0
- package/dist/chunks/FormHelp-Be2PQL0y.js +1 -0
- package/dist/chunks/FormLabel-CYcQiFUI.js +1 -0
- package/dist/chunks/Icon-BIwkD-kx.js +1 -0
- package/dist/chunks/Icon-CioraWLF.d.ts +36 -0
- package/dist/chunks/Link-B0Y1xgYi.d.ts +69 -0
- package/dist/chunks/Link-Cq7FNWpm.js +1 -0
- package/dist/chunks/MenuItemDef-D0VDtYIQ.d.ts +82 -0
- package/dist/chunks/RangeCalendar-COnSfurr.js +1 -0
- package/dist/chunks/accordion-okRicuG5.js +1 -0
- package/dist/chunks/autocomplete-B0xTc6kg.js +1 -0
- package/dist/chunks/avatar-Bjm0DlPO.js +1 -0
- package/dist/chunks/badge-Bj8mf8lu.js +1 -0
- package/dist/chunks/breadcrumb-DDxnx_iS.js +1 -0
- package/dist/chunks/breakpoints-SLMTNHF9.d.ts +5 -0
- package/dist/chunks/breakpoints-o_2Ev7ir.js +1 -0
- package/dist/chunks/button-group-CPZYA6aZ.js +1 -0
- package/dist/chunks/card-DfF2K_5p.js +1 -0
- package/dist/chunks/carousel-DEvwcA7H.js +1 -0
- package/dist/chunks/checkbox-BFPS0pD6.js +1 -0
- package/dist/chunks/chip-input-CB1lE6vP.js +1 -0
- package/dist/chunks/collapse-WifcChO8.js +1 -0
- package/dist/chunks/color-input-CyRaLR_G.js +1 -0
- package/dist/chunks/combobox-DWEj-Sv7.js +1 -0
- package/dist/chunks/datagrid-nbnNThsT.js +2 -0
- package/dist/chunks/dateRangePresets-R1FtA1zp.d.ts +41 -0
- package/dist/chunks/datepicker-CslLKMm1.js +1 -0
- package/dist/chunks/dialogTransition-i9vw0i2Z.js +1 -0
- package/dist/chunks/direction-CPhdeL3A.js +1 -0
- package/dist/chunks/drawer-zReFjoJG.js +1 -0
- package/dist/chunks/file-input-RRqZSzjH.js +1 -0
- package/dist/chunks/flex-BTvpgaRv.js +1 -0
- package/dist/chunks/floating-input-CIC9Lm2a.js +1 -0
- package/dist/chunks/focus-ring-SR_LwaN7.js +1 -0
- package/dist/chunks/focusRedirect-BrvK3U_o.js +1 -0
- package/dist/chunks/form-GpdAyWWi.js +1 -0
- package/dist/chunks/form-field-BjQ9SIjx.js +1 -0
- package/dist/chunks/grid-CuFw89yV.js +1 -0
- package/dist/chunks/icon-mxYpL5nL.js +1 -0
- package/dist/chunks/iconConfig-Bu6Pt9o3.d.ts +69 -0
- package/dist/chunks/iconSlot-BmWxJh27.js +1 -0
- package/dist/chunks/index--0_IpTDT.d.ts +17 -0
- package/dist/chunks/index-6uob77s9.d.ts +80 -0
- package/dist/chunks/index-8PhBSbNQ.d.ts +93 -0
- package/dist/chunks/index-B0-8n-Gs.d.ts +105 -0
- package/dist/chunks/index-B8uaSJA9.d.ts +95 -0
- package/dist/chunks/index-BA-raEMm.d.ts +28 -0
- package/dist/chunks/index-BDfh8YBc.d.ts +39 -0
- package/dist/chunks/index-BKMW0rkw.d.ts +80 -0
- package/dist/chunks/index-BO9jLOIb.d.ts +58 -0
- package/dist/chunks/index-BO_1MN66.d.ts +87 -0
- package/dist/chunks/index-BTDgfLxK.d.ts +94 -0
- package/dist/chunks/index-BTTeKpiE.d.ts +363 -0
- package/dist/chunks/index-BVGGIaPX.d.ts +110 -0
- package/dist/chunks/index-Bi8FFadV.d.ts +98 -0
- package/dist/chunks/index-Bkj17NEQ.d.ts +50 -0
- package/dist/chunks/index-BlgkO3dn.d.ts +280 -0
- package/dist/chunks/index-BxTlIaZu.d.ts +301 -0
- package/dist/chunks/index-C61tPIJ-.d.ts +50 -0
- package/dist/chunks/index-CCXJXToc.d.ts +52 -0
- package/dist/chunks/index-CJzKu7QI.d.ts +40 -0
- package/dist/chunks/index-COsIPd8L.d.ts +62 -0
- package/dist/chunks/index-COsYSDrz.d.ts +109 -0
- package/dist/chunks/index-CRfm7W6C.d.ts +230 -0
- package/dist/chunks/index-CVUMS0x7.d.ts +73 -0
- package/dist/chunks/index-CaQ1JY5D.d.ts +49 -0
- package/dist/chunks/index-Cf2n0l0U.d.ts +138 -0
- package/dist/chunks/index-CftERHnE.d.ts +24 -0
- package/dist/chunks/index-ClT3E_hv.d.ts +302 -0
- package/dist/chunks/index-CsMIgBsd.d.ts +39 -0
- package/dist/chunks/index-Ctuk1xBU.d.ts +99 -0
- package/dist/chunks/index-D2VVO8rx.d.ts +49 -0
- package/dist/chunks/index-D949AidR.d.ts +40 -0
- package/dist/chunks/index-D9PZHY_I.d.ts +135 -0
- package/dist/chunks/index-DAoPg59I.d.ts +80 -0
- package/dist/chunks/index-DB_ToPdz.d.ts +202 -0
- package/dist/chunks/index-DEb9zXlC.d.ts +210 -0
- package/dist/chunks/index-DHGgezXU.d.ts +58 -0
- package/dist/chunks/index-DJJocp_q.d.ts +132 -0
- package/dist/chunks/index-DKma0jQw.d.ts +104 -0
- package/dist/chunks/index-DPV62IdF.d.ts +118 -0
- package/dist/chunks/index-DR8sYtvd.d.ts +296 -0
- package/dist/chunks/index-Dcc_W6Kv.d.ts +146 -0
- package/dist/chunks/index-Dfg4Ftb8.d.ts +68 -0
- package/dist/chunks/index-Dfy1YW5j.d.ts +73 -0
- package/dist/chunks/index-Dh5CaHTP.d.ts +44 -0
- package/dist/chunks/index-DtbUXxjz.d.ts +53 -0
- package/dist/chunks/index-Dum6Y9XR.d.ts +187 -0
- package/dist/chunks/index-HrKN6s8z.d.ts +66 -0
- package/dist/chunks/index-JllMXhVx.d.ts +176 -0
- package/dist/chunks/index-XjLvaH4G.d.ts +67 -0
- package/dist/chunks/index-dh3TKanY.d.ts +235 -0
- package/dist/chunks/index-nklPDKlC.d.ts +137 -0
- package/dist/chunks/index-qgZ5VGmc.d.ts +177 -0
- package/dist/chunks/index-tOodmT36.d.ts +129 -0
- package/dist/chunks/index-t_x6jj7l.d.ts +96 -0
- package/dist/chunks/input-adorn-C_EHML68.js +1 -0
- package/dist/chunks/input-group-iI7azfvE.js +1 -0
- package/dist/chunks/list-CMr-wB9d.js +1 -0
- package/dist/chunks/menu-CXUc-Gva.js +1 -0
- package/dist/chunks/modal-ByIj71Mq.js +1 -0
- package/dist/chunks/nav-BldxFo_B.js +1 -0
- package/dist/chunks/navbar-BwcsQuBk.js +1 -0
- package/dist/chunks/notification-DdqigVB1.js +1 -0
- package/dist/chunks/otp-input-CXe_wkII.js +1 -0
- package/dist/chunks/overlayPlacement-B7843a-Q.d.ts +6 -0
- package/dist/chunks/overlayPlacement-BtS90IVf.js +1 -0
- package/dist/chunks/pagination-BOpEAYW2.js +1 -0
- package/dist/chunks/password-strength-BfLiYiGj.js +1 -0
- package/dist/chunks/placeholder-pg95KELl.js +1 -0
- package/dist/chunks/polymorphic-CACPOv1_.js +1 -0
- package/dist/chunks/polymorphic-CVHbTHSN.d.ts +40 -0
- package/dist/chunks/popover-BpSfnZzk.js +1 -0
- package/dist/chunks/progress-DlrZ71aV.js +1 -0
- package/dist/chunks/radio-BV7Sq6D1.js +1 -0
- package/dist/chunks/range-input-BN3430j-.js +1 -0
- package/dist/chunks/renderFormCheck-BXBs6_ov.js +1 -0
- package/dist/chunks/renderFormCheck-CYWG-Rbt.d.ts +23 -0
- package/dist/chunks/renderFormField-fBEny6JV.d.ts +14 -0
- package/dist/chunks/renderFormField-wiaxvvLG.js +1 -0
- package/dist/chunks/renderMenuItemContent-CmqT3YUQ.js +1 -0
- package/dist/chunks/select-CclIIux8.js +1 -0
- package/dist/chunks/skeleton-CKq76sE_.js +1 -0
- package/dist/chunks/spacingClassName-DVhk8m3P.js +1 -0
- package/dist/chunks/spinner-BEq4PAlu.js +1 -0
- package/dist/chunks/stack-D3retZ-W.js +1 -0
- package/dist/chunks/static-table-D0M4oc_t.js +1 -0
- package/dist/chunks/stepper-CTa6e8uv.js +1 -0
- package/dist/chunks/switch-BmHpq4tL.js +1 -0
- package/dist/chunks/table-Fme9GbAR.js +1 -0
- package/dist/chunks/tableClassName-CZA2Bse8.js +1 -0
- package/dist/chunks/tabs-BnbMJM_b.js +1 -0
- package/dist/chunks/text-input-DD3d08Yf.js +1 -0
- package/dist/chunks/textarea-C0qQdCcu.js +1 -0
- package/dist/chunks/toast-BQhZ2pv5.js +1 -0
- package/dist/chunks/tooltip-DHtVAYUo.js +1 -0
- package/dist/chunks/triggerElement-BIqA4KqZ.js +1 -0
- package/dist/chunks/types-CS_40Txv.d.ts +34 -0
- package/dist/chunks/useButtonSemantics-CILM_lhi.js +1 -0
- package/dist/chunks/useDialogElement-BRIU60cT.js +1 -0
- package/dist/chunks/useDisabledAnchorGuard-Cz58UCXy.js +1 -0
- package/dist/chunks/useFloatingOverlay-CcmDZKMK.js +1 -0
- package/dist/chunks/useForkedRef-DVEfT-KI.js +1 -0
- package/dist/chunks/useFormField-BOqmBTC4.js +1 -0
- package/dist/chunks/useIsomorphicLayoutEffect-BbqRwuqn.js +1 -0
- package/dist/chunks/useToastRegionQueue-BH6bWZ73.js +1 -0
- package/dist/chunks/validationClassName-gRGs4KBm.js +1 -0
- package/dist/close-button.d.ts +2 -0
- package/dist/close-button.js +1 -0
- package/dist/collapse.d.ts +2 -0
- package/dist/collapse.js +1 -0
- package/dist/color-input.d.ts +2 -0
- package/dist/color-input.js +1 -0
- package/dist/combobox.d.ts +3 -0
- package/dist/combobox.js +1 -0
- package/dist/datagrid.d.ts +2 -0
- package/dist/datagrid.js +1 -0
- package/dist/datepicker.d.ts +2 -0
- package/dist/datepicker.js +1 -0
- package/dist/drawer.d.ts +2 -0
- package/dist/drawer.js +1 -0
- package/dist/file-input.d.ts +2 -0
- package/dist/file-input.js +1 -0
- package/dist/flex.d.ts +2 -0
- package/dist/flex.js +1 -0
- package/dist/floating-input.d.ts +2 -0
- package/dist/floating-input.js +1 -0
- package/dist/form-field.d.ts +2 -0
- package/dist/form-field.js +1 -0
- package/dist/form.d.ts +2 -0
- package/dist/form.js +1 -0
- package/dist/grid.d.ts +2 -0
- package/dist/grid.js +1 -0
- package/dist/icon.d.ts +4 -0
- package/dist/icon.js +1 -0
- package/dist/index.d.ts +72 -6369
- package/dist/index.js +1 -2
- package/dist/input-adorn.d.ts +2 -0
- package/dist/input-adorn.js +1 -0
- package/dist/input-group.d.ts +2 -0
- package/dist/input-group.js +1 -0
- package/dist/link.d.ts +3 -0
- package/dist/link.js +1 -0
- package/dist/list.d.ts +2 -0
- package/dist/list.js +1 -0
- package/dist/menu.d.ts +3 -0
- package/dist/menu.js +1 -0
- package/dist/modal.d.ts +2 -0
- package/dist/modal.js +1 -0
- package/dist/nav.d.ts +2 -0
- package/dist/nav.js +1 -0
- package/dist/navbar.d.ts +2 -0
- package/dist/navbar.js +1 -0
- package/dist/notification.d.ts +2 -0
- package/dist/notification.js +1 -0
- package/dist/otp-input.d.ts +2 -0
- package/dist/otp-input.js +1 -0
- package/dist/pagination.d.ts +2 -0
- package/dist/pagination.js +1 -0
- package/dist/password-strength.d.ts +2 -0
- package/dist/password-strength.js +1 -0
- package/dist/placeholder.d.ts +2 -0
- package/dist/placeholder.js +1 -0
- package/dist/popover.d.ts +2 -0
- package/dist/popover.js +1 -0
- package/dist/progress.d.ts +2 -0
- package/dist/progress.js +1 -0
- package/dist/radio.d.ts +2 -0
- package/dist/radio.js +1 -0
- package/dist/range-input.d.ts +2 -0
- package/dist/range-input.js +1 -0
- package/dist/select.d.ts +2 -0
- package/dist/select.js +1 -0
- package/dist/skeleton.d.ts +2 -0
- package/dist/skeleton.js +1 -0
- package/dist/spinner.d.ts +2 -0
- package/dist/spinner.js +1 -0
- package/dist/stack.d.ts +2 -0
- package/dist/stack.js +1 -0
- package/dist/static-table.d.ts +2 -0
- package/dist/static-table.js +1 -0
- package/dist/stepper.d.ts +2 -0
- package/dist/stepper.js +1 -0
- package/dist/style.css +1 -1
- package/dist/switch.d.ts +2 -0
- package/dist/switch.js +1 -0
- package/dist/table.d.ts +2 -0
- package/dist/table.js +1 -0
- package/dist/tabs.d.ts +2 -0
- package/dist/tabs.js +1 -0
- package/dist/text-input.d.ts +2 -0
- package/dist/text-input.js +1 -0
- package/dist/textarea.d.ts +2 -0
- package/dist/textarea.js +1 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +1 -0
- package/dist/tooltip.d.ts +2 -0
- package/dist/tooltip.js +1 -0
- package/package.json +62 -4
- package/src/components/accordion/index.ts +4 -0
- package/src/components/autocomplete/index.ts +4 -0
- package/src/components/avatar/index.ts +4 -0
- package/src/components/badge/index.ts +4 -0
- package/src/components/breadcrumb/index.ts +4 -0
- package/src/components/button/index.ts +4 -0
- package/src/components/button-group/index.ts +4 -0
- package/src/components/calendar/index.ts +4 -0
- package/src/components/card/index.ts +4 -0
- package/src/components/carousel/CarouselControlButton.tsx +11 -4
- package/src/components/carousel/CarouselControlNext.tsx +6 -0
- package/src/components/carousel/CarouselControlPrev.tsx +6 -0
- package/src/components/carousel/CarouselPlayPause.tsx +27 -4
- package/src/components/carousel/index.ts +4 -0
- package/src/components/checkbox/index.ts +4 -0
- package/src/components/chip/index.ts +4 -0
- package/src/components/chip-input/index.ts +4 -0
- package/src/components/close-button/index.ts +4 -0
- package/src/components/collapse/index.ts +4 -0
- package/src/components/color-input/index.ts +4 -0
- package/src/components/combobox/ComboboxListBox.tsx +2 -2
- package/src/components/combobox/index.ts +4 -0
- package/src/components/datagrid/index.ts +4 -0
- package/src/components/datepicker/index.ts +4 -0
- package/src/components/drawer/index.ts +8 -0
- package/src/components/file-input/index.ts +4 -0
- package/src/components/flex/index.ts +4 -0
- package/src/components/floating-input/index.ts +4 -0
- package/src/components/form/index.ts +4 -0
- package/src/components/form-field/index.ts +4 -0
- package/src/components/grid/index.ts +4 -0
- package/src/components/icon/Icon.tsx +69 -38
- package/src/components/icon/IconProvider.tsx +40 -0
- package/src/components/icon/index.ts +7 -0
- package/src/components/input-adorn/index.ts +4 -0
- package/src/components/input-group/index.ts +4 -0
- package/src/components/link/index.ts +4 -0
- package/src/components/list/index.ts +4 -0
- package/src/components/menu/index.ts +4 -0
- package/src/components/modal/index.ts +8 -0
- package/src/components/nav/index.ts +4 -0
- package/src/components/navbar/NavbarToggler.tsx +9 -3
- package/src/components/navbar/index.ts +4 -0
- package/src/components/notification/Notification.tsx +6 -5
- package/src/components/notification/index.ts +8 -0
- package/src/components/otp-input/index.ts +4 -0
- package/src/components/pagination/Pagination.tsx +16 -3
- package/src/components/pagination/index.ts +8 -0
- package/src/components/password-strength/index.ts +4 -0
- package/src/components/placeholder/index.ts +4 -0
- package/src/components/popover/index.ts +4 -0
- package/src/components/progress/index.ts +4 -0
- package/src/components/radio/index.ts +4 -0
- package/src/components/range-input/index.ts +4 -0
- package/src/components/select/index.ts +4 -0
- package/src/components/skeleton/SkeletonLoader.tsx +13 -6
- package/src/components/skeleton/index.ts +4 -0
- package/src/components/spinner/index.ts +4 -0
- package/src/components/stack/index.ts +4 -0
- package/src/components/static-table/StaticTable.tsx +78 -0
- package/src/components/static-table/index.ts +8 -0
- package/src/components/stepper/index.ts +4 -0
- package/src/components/switch/index.ts +4 -0
- package/src/components/table/Table.tsx +14 -22
- package/src/components/table/index.ts +4 -0
- package/src/components/tabs/index.ts +4 -0
- package/src/components/text-input/index.ts +4 -0
- package/src/components/textarea/index.ts +4 -0
- package/src/components/toast/Toast.tsx +2 -1
- package/src/components/toast/ToastHeader.tsx +4 -3
- package/src/components/toast/index.ts +8 -0
- package/src/components/tooltip/index.ts +4 -0
- package/src/hooks/useIconConfig.ts +6 -0
- package/src/index.ts +24 -4
- package/src/utils/iconConfig.ts +88 -0
- package/src/utils/iconSlot.tsx +41 -0
- package/src/utils/polymorphic.ts +49 -2
- package/src/utils/renderMenuItemContent.tsx +4 -9
- package/src/utils/slot.tsx +78 -0
- package/src/utils/tableClassName.ts +93 -0
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import React, { forwardRef, HTMLAttributes, SVGAttributes } from 'react'
|
|
1
|
+
import React, { CSSProperties, forwardRef, HTMLAttributes, SVGAttributes } from 'react'
|
|
2
2
|
import classNames from 'classnames'
|
|
3
3
|
|
|
4
|
+
import { useIconConfig } from '../../hooks/useIconConfig'
|
|
5
|
+
import { DEFAULT_FONT_PREFIX } from '../../utils/iconConfig'
|
|
6
|
+
|
|
4
7
|
interface IconOwnProps {
|
|
5
8
|
/**
|
|
6
|
-
* Icon name, e.g. `folder-tree`. Matches a `cx-{name}` font glyph
|
|
9
|
+
* Icon name, e.g. `folder-tree`. Matches an id in the SVG sprite, or a `cx-{name}` font glyph
|
|
10
|
+
* class in `font` mode (see `IconProvider`'s `fontPrefix`).
|
|
7
11
|
*/
|
|
8
12
|
name: string
|
|
9
13
|
/**
|
|
@@ -11,15 +15,18 @@ interface IconOwnProps {
|
|
|
11
15
|
*/
|
|
12
16
|
className?: string
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* Icon size: a number of pixels, or any CSS length (`'1.25rem'`, `'1em'`). Sets chassis-css's
|
|
19
|
+
* `--cx-icon-size` on the icon, so it applies in `font` mode too. Leave unset to keep the size
|
|
20
|
+
* chassis-css gives icons in context (inside a button, an input, a navbar toggler, ...).
|
|
15
21
|
*/
|
|
16
|
-
size?: number
|
|
22
|
+
size?: number | string
|
|
17
23
|
/**
|
|
18
24
|
* Accessible name. When set, the icon is exposed to assistive tech instead of hidden.
|
|
19
25
|
*/
|
|
20
26
|
title?: string
|
|
21
27
|
/**
|
|
22
|
-
*
|
|
28
|
+
* URL of the SVG sprite file. Defaults to `IconProvider`'s `sprite`, or to none — a sprite
|
|
29
|
+
* embedded in the page, referenced as `#name`. Ignored in `font` mode.
|
|
23
30
|
*/
|
|
24
31
|
sprite?: string
|
|
25
32
|
}
|
|
@@ -28,47 +35,71 @@ export type IconProps =
|
|
|
28
35
|
| (IconOwnProps & { font: true } & Omit<HTMLAttributes<HTMLSpanElement>, keyof IconOwnProps>)
|
|
29
36
|
| (IconOwnProps & { font?: false } & Omit<SVGAttributes<SVGSVGElement>, keyof IconOwnProps>)
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const _className = classNames('icon', { [`cx-${name}`]: props.font }, className)
|
|
38
|
+
// An SVG's `width`/`height` attributes lose to chassis-css's `.icon { width: var(--cx-icon-size) }`
|
|
39
|
+
// — `size` used to set only those, so `size={48}` rendered at the stylesheet's 24px whenever
|
|
40
|
+
// chassis-css was loaded. The custom property is what actually sizes an icon; the attributes stay
|
|
41
|
+
// as the fallback for a page without chassis-css, where an unsized `<svg>` would render 300×150.
|
|
42
|
+
const FALLBACK_SIZE = 24
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{...rest}
|
|
51
|
-
/>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
44
|
+
export const Icon = forwardRef<HTMLSpanElement | SVGSVGElement, IconProps>((props, ref) => {
|
|
45
|
+
const config = useIconConfig()
|
|
46
|
+
const {
|
|
47
|
+
name,
|
|
48
|
+
className,
|
|
49
|
+
font = config.font ?? false,
|
|
50
|
+
size,
|
|
51
|
+
sprite = config.sprite ?? '',
|
|
52
|
+
style,
|
|
53
|
+
title,
|
|
54
|
+
...rest
|
|
55
|
+
} = props as IconOwnProps & { font?: boolean; style?: CSSProperties }
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
const sizeStyle =
|
|
58
|
+
size == null
|
|
59
|
+
? style
|
|
60
|
+
: ({
|
|
61
|
+
'--cx-icon-size': typeof size === 'number' ? `${size}px` : size,
|
|
62
|
+
...style
|
|
63
|
+
} as CSSProperties)
|
|
64
|
+
const _className = classNames(
|
|
65
|
+
'icon',
|
|
66
|
+
{ [`${config.fontPrefix ?? DEFAULT_FONT_PREFIX}${name}`]: font },
|
|
67
|
+
config.className,
|
|
68
|
+
className
|
|
69
|
+
)
|
|
56
70
|
|
|
71
|
+
if (font) {
|
|
57
72
|
return (
|
|
58
|
-
<
|
|
73
|
+
<span
|
|
59
74
|
className={_className}
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
// A plain `<span>`'s implicit "generic" role doesn't support naming, so `aria-label`
|
|
76
|
+
// alone is dropped by browsers/assistive tech - `role="img"` (matching the SVG path's
|
|
77
|
+
// own implicit role) is what actually makes the accessible name stick.
|
|
62
78
|
role={title ? 'img' : undefined}
|
|
63
79
|
aria-hidden={title ? undefined : true}
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
</svg>
|
|
80
|
+
aria-label={title}
|
|
81
|
+
style={sizeStyle}
|
|
82
|
+
ref={ref as React.Ref<HTMLSpanElement>}
|
|
83
|
+
{...(rest as HTMLAttributes<HTMLSpanElement>)}
|
|
84
|
+
/>
|
|
70
85
|
)
|
|
71
86
|
}
|
|
72
|
-
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<svg
|
|
90
|
+
className={_className}
|
|
91
|
+
width={size ?? FALLBACK_SIZE}
|
|
92
|
+
height={size ?? FALLBACK_SIZE}
|
|
93
|
+
role={title ? 'img' : undefined}
|
|
94
|
+
aria-hidden={title ? undefined : true}
|
|
95
|
+
style={sizeStyle}
|
|
96
|
+
ref={ref as React.Ref<SVGSVGElement>}
|
|
97
|
+
{...(rest as SVGAttributes<SVGSVGElement>)}
|
|
98
|
+
>
|
|
99
|
+
{title && <title>{title}</title>}
|
|
100
|
+
<use href={`${sprite}#${name}`} />
|
|
101
|
+
</svg>
|
|
102
|
+
)
|
|
103
|
+
})
|
|
73
104
|
|
|
74
105
|
Icon.displayName = 'Icon'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { ReactNode, useMemo } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useIconConfig } from '../../hooks/useIconConfig'
|
|
4
|
+
import { IconConfig, IconContext } from '../../utils/iconConfig'
|
|
5
|
+
|
|
6
|
+
export interface IconProviderProps extends IconConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The part of the app these icon settings apply to.
|
|
9
|
+
*/
|
|
10
|
+
children?: ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Nested providers extend the one above them: a setting left unset here keeps the outer value,
|
|
14
|
+
// and `icons` merges per key, so an inner provider can remap one icon without restating the rest.
|
|
15
|
+
export const IconProvider = ({
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
|
+
component,
|
|
19
|
+
font,
|
|
20
|
+
fontPrefix,
|
|
21
|
+
icons,
|
|
22
|
+
sprite
|
|
23
|
+
}: IconProviderProps) => {
|
|
24
|
+
const parent = useIconConfig()
|
|
25
|
+
const value = useMemo<IconConfig>(
|
|
26
|
+
() => ({
|
|
27
|
+
className: className ?? parent.className,
|
|
28
|
+
component: component ?? parent.component,
|
|
29
|
+
font: font ?? parent.font,
|
|
30
|
+
fontPrefix: fontPrefix ?? parent.fontPrefix,
|
|
31
|
+
icons: icons ? { ...parent.icons, ...icons } : parent.icons,
|
|
32
|
+
sprite: sprite ?? parent.sprite
|
|
33
|
+
}),
|
|
34
|
+
[parent, className, component, font, fontPrefix, icons, sprite]
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
return <IconContext.Provider value={value}>{children}</IconContext.Provider>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
IconProvider.displayName = 'IconProvider'
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import '../../utils/suppressFocusRingGlobally'
|
|
4
|
+
|
|
1
5
|
export { Icon } from './Icon'
|
|
2
6
|
export type { IconProps } from './Icon'
|
|
7
|
+
export { IconProvider } from './IconProvider'
|
|
8
|
+
export type { IconProviderProps } from './IconProvider'
|
|
9
|
+
export type { IconComponentProps, IconKey, IconValue } from '../../utils/iconConfig'
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import '../../utils/suppressFocusRingGlobally'
|
|
4
|
+
|
|
1
5
|
export { Modal } from './Modal'
|
|
2
6
|
export type { ModalProps } from './Modal'
|
|
3
7
|
export { ModalBody } from './ModalBody'
|
|
@@ -8,3 +12,7 @@ export { ModalHeader } from './ModalHeader'
|
|
|
8
12
|
export type { ModalHeaderProps } from './ModalHeader'
|
|
9
13
|
export { ModalTitle } from './ModalTitle'
|
|
10
14
|
export type { ModalTitleProps } from './ModalTitle'
|
|
15
|
+
// Also exported from the package root; repeated here so this folder's subpath entry
|
|
16
|
+
// (`@chassis-ui/react/<folder>`) covers the whole family without reaching back to the root.
|
|
17
|
+
export { useModal } from '../../hooks/useModal'
|
|
18
|
+
export type { UseModalResult } from '../../hooks/useModal'
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes } from 'react'
|
|
2
2
|
import classNames from 'classnames'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { IconValue } from '../../utils/iconConfig'
|
|
5
|
+
import { IconSlot } from '../../utils/iconSlot'
|
|
5
6
|
|
|
6
7
|
export interface NavbarTogglerProps extends HTMLAttributes<HTMLButtonElement> {
|
|
7
8
|
/**
|
|
8
9
|
* A string of all className you want applied to the base component.
|
|
9
10
|
*/
|
|
10
11
|
className?: string
|
|
12
|
+
/**
|
|
13
|
+
* The toggler icon: an icon name, or an element of your own icon set. Defaults to
|
|
14
|
+
* `IconProvider`'s `menu` icon.
|
|
15
|
+
*/
|
|
16
|
+
icon?: IconValue
|
|
11
17
|
/**
|
|
12
18
|
* The accessible label announced by assistive technology when no children are provided.
|
|
13
19
|
*/
|
|
@@ -15,14 +21,14 @@ export interface NavbarTogglerProps extends HTMLAttributes<HTMLButtonElement> {
|
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export const NavbarToggler = forwardRef<HTMLButtonElement, NavbarTogglerProps>(
|
|
18
|
-
({ children, className, label = 'Toggle navigation', ...rest }, ref) => {
|
|
24
|
+
({ children, className, icon, label = 'Toggle navigation', ...rest }, ref) => {
|
|
19
25
|
const _className = classNames('button icon-only navbar-toggler', className)
|
|
20
26
|
|
|
21
27
|
return (
|
|
22
28
|
<button type="button" className={_className} {...rest} ref={ref}>
|
|
23
29
|
{children ?? (
|
|
24
30
|
<>
|
|
25
|
-
<
|
|
31
|
+
<IconSlot icon="menu" override={icon} className="navbar-toggler-icon" />
|
|
26
32
|
<span className="visually-hidden">{label}</span>
|
|
27
33
|
</>
|
|
28
34
|
)}
|
|
@@ -7,7 +7,7 @@ import { ContextColor } from '../../types'
|
|
|
7
7
|
import { CloseButton } from '../close-button/CloseButton'
|
|
8
8
|
import { useAutoDismiss, useDismissibleTransition } from '../../hooks'
|
|
9
9
|
import { NotificationContext } from './context'
|
|
10
|
-
import {
|
|
10
|
+
import { ResolvedIcon } from '../../utils/iconSlot'
|
|
11
11
|
import { NotificationText } from './NotificationText'
|
|
12
12
|
import { NotificationTitle } from './NotificationTitle'
|
|
13
13
|
import './Notification.scss'
|
|
@@ -45,7 +45,8 @@ export interface NotificationProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
45
45
|
*/
|
|
46
46
|
dismissible?: boolean
|
|
47
47
|
/**
|
|
48
|
-
* Leading icon. A string is rendered
|
|
48
|
+
* Leading icon. A string is an icon name, rendered like `<NotificationIcon name={icon} />` (or
|
|
49
|
+
* by `IconProvider`'s `component`); pass any other
|
|
49
50
|
* node for a fully custom icon. Automatically top-aligns with `title` when both are set —
|
|
50
51
|
* a custom icon node is responsible for its own alignment.
|
|
51
52
|
*/
|
|
@@ -159,9 +160,9 @@ export const Notification = forwardRef<HTMLDivElement, NotificationProps>(
|
|
|
159
160
|
>
|
|
160
161
|
{icon &&
|
|
161
162
|
(typeof icon === 'string' ? (
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
className={
|
|
163
|
+
<ResolvedIcon
|
|
164
|
+
value={icon}
|
|
165
|
+
className={classNames('notification-icon', { 'align-self-start': !!title })}
|
|
165
166
|
/>
|
|
166
167
|
) : (
|
|
167
168
|
icon
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import '../../utils/suppressFocusRingGlobally'
|
|
4
|
+
|
|
1
5
|
export { Notification } from './Notification'
|
|
2
6
|
export type { NotificationProps } from './Notification'
|
|
3
7
|
export { NotificationTitle } from './NotificationTitle'
|
|
@@ -15,3 +19,7 @@ export { NotificationStack } from './NotificationStack'
|
|
|
15
19
|
export type { NotificationStackProps } from './NotificationStack'
|
|
16
20
|
export { addNotification, closeNotification, notificationQueue } from './notificationQueue'
|
|
17
21
|
export type { NotificationContent } from './notificationQueue'
|
|
22
|
+
// Also exported from the package root; repeated here so this folder's subpath entry
|
|
23
|
+
// (`@chassis-ui/react/<folder>`) covers the whole family without reaching back to the root.
|
|
24
|
+
export { useNotification } from '../../hooks/useNotification'
|
|
25
|
+
export type { UseNotificationResult } from '../../hooks/useNotification'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { IconValue } from '../../utils/iconConfig'
|
|
3
|
+
import { IconSlot } from '../../utils/iconSlot'
|
|
3
4
|
import classNames from 'classnames'
|
|
4
5
|
|
|
5
6
|
import { PaginationItem } from './PaginationItem'
|
|
@@ -29,6 +30,11 @@ export interface PaginationProps extends HTMLAttributes<HTMLElement> {
|
|
|
29
30
|
* Maximum number of visible page buttons (default: 5). Flanking pages are collapsed to ellipsis.
|
|
30
31
|
*/
|
|
31
32
|
maxVisiblePages?: number
|
|
33
|
+
/**
|
|
34
|
+
* The "next page" control's icon in smart pagination mode: an icon name, or an element of your
|
|
35
|
+
* own icon set. Defaults to `IconProvider`'s `next` icon.
|
|
36
|
+
*/
|
|
37
|
+
nextIcon?: IconValue
|
|
32
38
|
/**
|
|
33
39
|
* Accessible label for the "next page" control, used in smart pagination mode. Override for
|
|
34
40
|
* non-English locales.
|
|
@@ -45,6 +51,11 @@ export interface PaginationProps extends HTMLAttributes<HTMLElement> {
|
|
|
45
51
|
* the component renders a fully-controlled smart paginator with Prev/Next and ellipsis.
|
|
46
52
|
*/
|
|
47
53
|
pages?: number
|
|
54
|
+
/**
|
|
55
|
+
* The "previous page" control's icon in smart pagination mode: an icon name, or an element of
|
|
56
|
+
* your own icon set. Defaults to `IconProvider`'s `previous` icon.
|
|
57
|
+
*/
|
|
58
|
+
previousIcon?: IconValue
|
|
48
59
|
/**
|
|
49
60
|
* Accessible label for the "previous page" control, used in smart pagination mode. Override
|
|
50
61
|
* for non-English locales.
|
|
@@ -115,9 +126,11 @@ export const Pagination = forwardRef<HTMLElement, PaginationProps>(
|
|
|
115
126
|
children,
|
|
116
127
|
className,
|
|
117
128
|
maxVisiblePages = 5,
|
|
129
|
+
nextIcon,
|
|
118
130
|
nextLabel = 'Next',
|
|
119
131
|
onActivePageChange,
|
|
120
132
|
pages,
|
|
133
|
+
previousIcon,
|
|
121
134
|
previousLabel = 'Previous',
|
|
122
135
|
showPageNumbers = true,
|
|
123
136
|
showPrevNext = true,
|
|
@@ -155,7 +168,7 @@ export const Pagination = forwardRef<HTMLElement, PaginationProps>(
|
|
|
155
168
|
onClick={handlePrevClick}
|
|
156
169
|
aria-label={previousLabel}
|
|
157
170
|
>
|
|
158
|
-
<
|
|
171
|
+
<IconSlot icon="previous" override={previousIcon} className="directional-icon" />
|
|
159
172
|
</PaginationItem>
|
|
160
173
|
)}
|
|
161
174
|
{showPageNumbers &&
|
|
@@ -182,7 +195,7 @@ export const Pagination = forwardRef<HTMLElement, PaginationProps>(
|
|
|
182
195
|
onClick={handleNextClick}
|
|
183
196
|
aria-label={nextLabel}
|
|
184
197
|
>
|
|
185
|
-
<
|
|
198
|
+
<IconSlot icon="next" override={nextIcon} className="directional-icon" />
|
|
186
199
|
</PaginationItem>
|
|
187
200
|
)}
|
|
188
201
|
</>
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import '../../utils/suppressFocusRingGlobally'
|
|
4
|
+
|
|
1
5
|
export { Pagination } from './Pagination'
|
|
2
6
|
export type { PaginationProps } from './Pagination'
|
|
3
7
|
export { PaginationItem } from './PaginationItem'
|
|
4
8
|
export type { PaginationItemProps } from './PaginationItem'
|
|
9
|
+
// Also exported from the package root; repeated here so this folder's subpath entry
|
|
10
|
+
// (`@chassis-ui/react/<folder>`) covers the whole family without reaching back to the root.
|
|
11
|
+
export { usePagination } from '../../hooks/usePagination'
|
|
12
|
+
export type { UsePaginationResult } from '../../hooks/usePagination'
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ComponentPropsWithoutRef,
|
|
3
|
+
ElementType,
|
|
4
|
+
Fragment,
|
|
5
|
+
ReactElement,
|
|
6
|
+
ReactNode
|
|
7
|
+
} from 'react'
|
|
2
8
|
|
|
3
9
|
import { Span } from '../../utils/breakpoints'
|
|
4
10
|
import { ContextColor } from '../../types'
|
|
5
|
-
import { PolymorphicComponentProps } from '../../utils/polymorphic'
|
|
6
11
|
import { Skeleton, SkeletonProps } from './Skeleton'
|
|
7
12
|
|
|
8
13
|
type SkeletonLoaderOwnProps<C extends ElementType> = {
|
|
@@ -38,10 +43,12 @@ type SkeletonLoaderOwnProps<C extends ElementType> = {
|
|
|
38
43
|
spans?: Span | Span[]
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
// Spelled out rather than `PolymorphicComponentProps`, which adds `asChild`: `SkeletonLoader`
|
|
47
|
+
// renders no element of its own (it swaps its `children` for generated `Skeleton` lines), so
|
|
48
|
+
// there's nothing for a child element to stand in for. (`Omit`-ing it from that type instead
|
|
49
|
+
// breaks `C`'s inference from `component`.)
|
|
50
|
+
export type SkeletonLoaderProps<C extends ElementType = 'span'> = SkeletonLoaderOwnProps<C> &
|
|
51
|
+
Omit<ComponentPropsWithoutRef<C>, keyof SkeletonLoaderOwnProps<C> | 'asChild'>
|
|
45
52
|
|
|
46
53
|
type SkeletonLoaderComponent = (<C extends ElementType = 'span'>(
|
|
47
54
|
props: SkeletonLoaderProps<C>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { forwardRef, ReactNode, TableHTMLAttributes } from 'react'
|
|
2
|
+
|
|
3
|
+
import { TableStyleProps, tableClassName, tableWrapperClassName } from '../../utils/tableClassName'
|
|
4
|
+
|
|
5
|
+
export interface StaticTableProps
|
|
6
|
+
extends TableStyleProps, Omit<TableHTMLAttributes<HTMLTableElement>, 'align' | 'color'> {
|
|
7
|
+
/**
|
|
8
|
+
* Content shown above the table, functioning as a heading for it.
|
|
9
|
+
*/
|
|
10
|
+
caption?: ReactNode
|
|
11
|
+
/**
|
|
12
|
+
* The table's own markup — plain `<thead>`/`<tbody>`/`<tfoot>`/`<tr>`/`<th>`/`<td>` elements,
|
|
13
|
+
* rendered as-is.
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode
|
|
16
|
+
/**
|
|
17
|
+
* Convert rows into stacked label/value blocks below a container width, for tables with too
|
|
18
|
+
* many columns to read comfortably even with horizontal scrolling. `true` always stacks; a
|
|
19
|
+
* breakpoint name stacks only below it. Implies `responsive` when `responsive` isn't set
|
|
20
|
+
* separately. Unlike `Table`, which derives each cell's label from its column header, a static
|
|
21
|
+
* table has no collection to read labels from — give each `<td>` a `data-cell` attribute with
|
|
22
|
+
* the label to show before its value.
|
|
23
|
+
*/
|
|
24
|
+
stacked?: TableStyleProps['stacked']
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A plain, server-renderable `<table>` with `Table`'s styling props and none of its behavior — no
|
|
28
|
+
// sorting, selection, or keyboard grid navigation, and no hooks, so it needs no client JavaScript
|
|
29
|
+
// at all. Imported from `@chassis-ui/react/static-table`, whose entry deliberately has no
|
|
30
|
+
// `'use client'` directive (see `RSC.md`). `forwardRef` is fine here: React Server Components
|
|
31
|
+
// render forwardRef components like any other function component (a ref just can't be passed
|
|
32
|
+
// from the server side).
|
|
33
|
+
export const StaticTable = forwardRef<HTMLTableElement, StaticTableProps>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
align,
|
|
37
|
+
bordered,
|
|
38
|
+
borderless,
|
|
39
|
+
caption,
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
color,
|
|
43
|
+
hover,
|
|
44
|
+
responsive,
|
|
45
|
+
sm,
|
|
46
|
+
stacked,
|
|
47
|
+
striped,
|
|
48
|
+
...rest
|
|
49
|
+
},
|
|
50
|
+
ref
|
|
51
|
+
) => {
|
|
52
|
+
const table = (
|
|
53
|
+
<table
|
|
54
|
+
{...rest}
|
|
55
|
+
className={tableClassName({
|
|
56
|
+
align,
|
|
57
|
+
bordered,
|
|
58
|
+
borderless,
|
|
59
|
+
className,
|
|
60
|
+
color,
|
|
61
|
+
hover,
|
|
62
|
+
sm,
|
|
63
|
+
stacked,
|
|
64
|
+
striped
|
|
65
|
+
})}
|
|
66
|
+
ref={ref}
|
|
67
|
+
>
|
|
68
|
+
{caption && <caption>{caption}</caption>}
|
|
69
|
+
{children}
|
|
70
|
+
</table>
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const wrapperClassName = tableWrapperClassName({ responsive, stacked })
|
|
74
|
+
return wrapperClassName ? <div className={wrapperClassName}>{table}</div> : table
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
StaticTable.displayName = 'StaticTable'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Deliberately no 'use client' directive — unlike every other component folder's barrel, this one
|
|
2
|
+
// is the server-safe entry point, `@chassis-ui/react/static-table`, and must stay importable from
|
|
3
|
+
// a React Server Component without creating a client boundary (see RSC.md). Nothing reachable from
|
|
4
|
+
// here may use hooks, context, or browser APIs; `scripts/check-rsc-directive.ts` fails the build if
|
|
5
|
+
// the built entry ever gains a directive. For the same reason it skips the
|
|
6
|
+
// `suppressFocusRingGlobally` import the other barrels carry — there's no client module to run it.
|
|
7
|
+
export { StaticTable } from './StaticTable'
|
|
8
|
+
export type { StaticTableProps } from './StaticTable'
|