@quaffui/quaff 0.1.0-prealpha9 → 1.0.0-alpha2
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/LICENSE +1 -1
- package/README.md +47 -14
- package/dist/classes/QContext.svelte.d.ts +42 -0
- package/dist/classes/QContext.svelte.js +63 -0
- package/dist/classes/QScrollObserver.svelte.d.ts +48 -0
- package/dist/classes/QScrollObserver.svelte.js +107 -0
- package/dist/classes/QTheme.svelte.d.ts +13 -0
- package/dist/classes/QTheme.svelte.js +62 -0
- package/dist/classes/Quaff.svelte.d.ts +27 -0
- package/dist/classes/Quaff.svelte.js +91 -0
- package/dist/components/avatar/QAvatar.scss +101 -0
- package/dist/components/avatar/QAvatar.svelte +42 -42
- package/dist/components/avatar/QAvatar.svelte.d.ts +4 -17
- package/dist/components/avatar/docs.d.ts +2 -2
- package/dist/components/avatar/docs.js +3 -8
- package/dist/components/avatar/docs.props.d.ts +3 -8
- package/dist/components/avatar/docs.props.js +68 -15
- package/dist/components/avatar/index.scss +5 -3
- package/dist/components/avatar/props.d.ts +51 -8
- package/dist/components/breadcrumbs/QBreadcrumbs.scss +10 -0
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +32 -14
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +4 -13
- package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +10 -0
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +65 -48
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +4 -16
- package/dist/components/breadcrumbs/docs.d.ts +2 -2
- package/dist/components/breadcrumbs/docs.js +3 -8
- package/dist/components/breadcrumbs/docs.props.d.ts +5 -16
- package/dist/components/breadcrumbs/docs.props.js +105 -45
- package/dist/components/breadcrumbs/props.d.ts +26 -24
- package/dist/components/button/QBtn.scss +136 -0
- package/dist/components/button/QBtn.svelte +156 -52
- package/dist/components/button/QBtn.svelte.d.ts +4 -23
- package/dist/components/button/docs.d.ts +2 -2
- package/dist/components/button/docs.js +3 -8
- package/dist/components/button/docs.props.d.ts +3 -8
- package/dist/components/button/docs.props.js +174 -37
- package/dist/components/button/props.d.ts +48 -11
- package/dist/components/card/QCard.scss +47 -0
- package/dist/components/card/QCard.svelte +42 -19
- package/dist/components/card/QCard.svelte.d.ts +4 -16
- package/dist/components/card/QCardActions.scss +10 -0
- package/dist/components/card/QCardActions.svelte +23 -15
- package/dist/components/card/QCardActions.svelte.d.ts +4 -12
- package/dist/components/card/QCardSection.scss +10 -0
- package/dist/components/card/QCardSection.svelte +15 -11
- package/dist/components/card/QCardSection.svelte.d.ts +4 -13
- package/dist/components/card/docs.d.ts +4 -4
- package/dist/components/card/docs.js +7 -22
- package/dist/components/card/docs.props.d.ts +7 -24
- package/dist/components/card/docs.props.js +57 -30
- package/dist/components/card/props.d.ts +11 -16
- package/dist/components/checkbox/QCheckbox.svelte +15 -9
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +3 -10
- package/dist/components/checkbox/docs.d.ts +2 -2
- package/dist/components/checkbox/docs.js +3 -3
- package/dist/components/checkbox/docs.props.d.ts +3 -8
- package/dist/components/checkbox/docs.props.js +24 -9
- package/dist/components/checkbox/index.scss +3 -1
- package/dist/components/checkbox/props.d.ts +2 -2
- package/dist/components/chip/QChip.scss +179 -0
- package/dist/components/chip/QChip.svelte +130 -60
- package/dist/components/chip/QChip.svelte.d.ts +4 -25
- package/dist/components/chip/docs.d.ts +2 -2
- package/dist/components/chip/docs.js +3 -16
- package/dist/components/chip/docs.props.d.ts +3 -8
- package/dist/components/chip/docs.props.js +96 -49
- package/dist/components/chip/props.d.ts +27 -29
- package/dist/components/codeBlock/QCodeBlock.svelte +101 -42
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +3 -10
- package/dist/components/codeBlock/docs.props.d.ts +3 -8
- package/dist/components/codeBlock/docs.props.js +61 -12
- package/dist/components/codeBlock/props.d.ts +12 -2
- package/dist/components/dialog/{index.scss → QDialog.scss} +12 -14
- package/dist/components/dialog/QDialog.svelte +85 -78
- package/dist/components/dialog/QDialog.svelte.d.ts +9 -24
- package/dist/components/dialog/docs.d.ts +2 -2
- package/dist/components/dialog/docs.js +3 -3
- package/dist/components/dialog/docs.props.d.ts +3 -16
- package/dist/components/dialog/docs.props.js +37 -128
- package/dist/components/dialog/props.d.ts +4 -19
- package/dist/components/drawer/QDrawer.scss +55 -0
- package/dist/components/drawer/QDrawer.svelte +334 -88
- package/dist/components/drawer/QDrawer.svelte.d.ts +9 -28
- package/dist/components/drawer/docs.d.ts +2 -2
- package/dist/components/drawer/docs.js +3 -3
- package/dist/components/drawer/docs.props.d.ts +3 -8
- package/dist/components/drawer/docs.props.js +90 -47
- package/dist/components/drawer/props.d.ts +10 -13
- package/dist/components/footer/QFooter.scss +42 -0
- package/dist/components/footer/QFooter.svelte +99 -24
- package/dist/components/footer/QFooter.svelte.d.ts +4 -14
- package/dist/components/footer/docs.d.ts +2 -2
- package/dist/components/footer/docs.js +3 -3
- package/dist/components/footer/docs.props.d.ts +3 -8
- package/dist/components/footer/docs.props.js +47 -16
- package/dist/components/footer/props.d.ts +15 -9
- package/dist/components/header/QHeader.scss +53 -0
- package/dist/components/header/QHeader.svelte +90 -23
- package/dist/components/header/QHeader.svelte.d.ts +4 -14
- package/dist/components/header/docs.d.ts +2 -0
- package/dist/components/header/docs.js +11 -0
- package/dist/components/header/docs.props.d.ts +7 -0
- package/dist/components/header/docs.props.js +131 -0
- package/dist/components/header/props.d.ts +13 -5
- package/dist/components/icon/{index.scss → QIcon.scss} +2 -4
- package/dist/components/icon/QIcon.svelte +44 -28
- package/dist/components/icon/QIcon.svelte.d.ts +4 -18
- package/dist/components/icon/docs.d.ts +2 -2
- package/dist/components/icon/docs.js +3 -3
- package/dist/components/icon/docs.props.d.ts +3 -8
- package/dist/components/icon/docs.props.js +65 -24
- package/dist/components/icon/props.d.ts +9 -8
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +5 -2
- package/dist/components/input/QInput.svelte +106 -72
- package/dist/components/input/QInput.svelte.d.ts +4 -22
- package/dist/components/input/docs.d.ts +2 -2
- package/dist/components/input/docs.js +5 -71
- package/dist/components/input/docs.props.d.ts +3 -8
- package/dist/components/input/docs.props.js +129 -57
- package/dist/components/input/index.scss +1 -3
- package/dist/components/input/props.d.ts +81 -21
- package/dist/components/input/props.js +1 -13
- package/dist/components/layout/QLayout.scss +184 -0
- package/dist/components/layout/QLayout.svelte +178 -79
- package/dist/components/layout/QLayout.svelte.d.ts +12 -45
- package/dist/components/layout/docs.d.ts +2 -2
- package/dist/components/layout/docs.js +3 -3
- package/dist/components/layout/docs.props.d.ts +3 -8
- package/dist/components/layout/docs.props.js +62 -39
- package/dist/components/layout/props.d.ts +29 -21
- package/dist/components/list/QItem.scss +69 -0
- package/dist/components/list/QItem.svelte +99 -51
- package/dist/components/list/QItem.svelte.d.ts +4 -24
- package/dist/components/list/QItemSection.scss +60 -0
- package/dist/components/list/QItemSection.svelte +63 -37
- package/dist/components/list/QItemSection.svelte.d.ts +4 -15
- package/dist/components/list/QList.scss +30 -0
- package/dist/components/list/QList.svelte +43 -20
- package/dist/components/list/QList.svelte.d.ts +4 -26
- package/dist/components/list/docs.d.ts +4 -2
- package/dist/components/list/docs.js +23 -3
- package/dist/components/list/docs.props.d.ts +11 -40
- package/dist/components/list/docs.props.js +344 -136
- package/dist/components/list/props.d.ts +126 -28
- package/dist/components/list/props.js +1 -25
- package/dist/components/private/ContextReseter.svelte +15 -11
- package/dist/components/private/ContextReseter.svelte.d.ts +4 -8
- package/dist/components/private/QApi.svelte +264 -113
- package/dist/components/private/QApi.svelte.d.ts +3 -6
- package/dist/components/private/QDocs.svelte +131 -70
- package/dist/components/private/QDocs.svelte.d.ts +4 -11
- package/dist/components/private/QDocsSection.svelte +48 -18
- package/dist/components/private/QDocsSection.svelte.d.ts +9 -24
- package/dist/components/private/QIconSnippet.svelte +22 -0
- package/dist/components/private/QIconSnippet.svelte.d.ts +14 -0
- package/dist/components/private/index.d.ts +6 -0
- package/dist/components/private/index.js +6 -0
- package/dist/components/progress/QCircularProgress.scss +63 -0
- package/dist/components/progress/QCircularProgress.svelte +134 -21
- package/dist/components/progress/QCircularProgress.svelte.d.ts +3 -11
- package/dist/components/progress/QLinearProgress.scss +75 -0
- package/dist/components/progress/QLinearProgress.svelte +80 -23
- package/dist/components/progress/QLinearProgress.svelte.d.ts +3 -11
- package/dist/components/progress/docs.d.ts +3 -2
- package/dist/components/progress/docs.js +15 -5
- package/dist/components/progress/docs.props.d.ts +5 -16
- package/dist/components/progress/docs.props.js +287 -41
- package/dist/components/progress/props.d.ts +126 -14
- package/dist/components/radio/QRadio.svelte +16 -9
- package/dist/components/radio/QRadio.svelte.d.ts +3 -11
- package/dist/components/radio/docs.d.ts +2 -2
- package/dist/components/radio/docs.js +4 -26
- package/dist/components/radio/docs.props.d.ts +3 -8
- package/dist/components/radio/docs.props.js +39 -20
- package/dist/components/radio/index.scss +3 -1
- package/dist/components/radio/props.d.ts +26 -6
- package/dist/components/radio/props.js +1 -8
- package/dist/components/railbar/QRailbar.scss +54 -0
- package/dist/components/railbar/QRailbar.svelte +71 -65
- package/dist/components/railbar/QRailbar.svelte.d.ts +4 -13
- package/dist/components/railbar/docs.d.ts +2 -2
- package/dist/components/railbar/docs.js +3 -3
- package/dist/components/railbar/docs.props.d.ts +3 -8
- package/dist/components/railbar/docs.props.js +36 -15
- package/dist/components/railbar/props.d.ts +13 -6
- package/dist/components/select/QSelect.svelte +222 -146
- package/dist/components/select/QSelect.svelte.d.ts +4 -24
- package/dist/components/select/docs.d.ts +2 -2
- package/dist/components/select/docs.js +5 -83
- package/dist/components/select/docs.props.d.ts +3 -8
- package/dist/components/select/docs.props.js +156 -64
- package/dist/components/select/index.scss +25 -10
- package/dist/components/select/props.d.ts +100 -20
- package/dist/components/select/props.js +1 -14
- package/dist/components/separator/QSeparator.scss +54 -0
- package/dist/components/separator/QSeparator.svelte +50 -57
- package/dist/components/separator/QSeparator.svelte.d.ts +3 -14
- package/dist/components/separator/docs.d.ts +3 -2
- package/dist/components/separator/docs.js +14 -4
- package/dist/components/separator/docs.props.d.ts +5 -16
- package/dist/components/separator/docs.props.js +152 -72
- package/dist/components/separator/props.d.ts +84 -16
- package/dist/components/separator/props.js +1 -9
- package/dist/components/switch/QSwitch.scss +305 -0
- package/dist/components/switch/QSwitch.svelte +115 -0
- package/dist/components/switch/QSwitch.svelte.d.ts +14 -0
- package/dist/components/switch/docs.d.ts +2 -0
- package/dist/components/switch/docs.js +17 -0
- package/dist/components/switch/docs.props.d.ts +3 -0
- package/dist/components/switch/docs.props.js +119 -0
- package/dist/components/switch/props.d.ts +53 -0
- package/dist/components/switch/props.js +1 -0
- package/dist/components/table/QTable.svelte +133 -97
- package/dist/components/table/QTable.svelte.d.ts +4 -19
- package/dist/components/table/docs.d.ts +2 -2
- package/dist/components/table/docs.js +3 -3
- package/dist/components/table/docs.props.d.ts +3 -8
- package/dist/components/table/docs.props.js +67 -15
- package/dist/components/table/index.scss +3 -1
- package/dist/components/table/props.d.ts +14 -3
- package/dist/components/tabs/QTab.scss +71 -0
- package/dist/components/tabs/QTab.svelte +101 -88
- package/dist/components/tabs/QTab.svelte.d.ts +4 -16
- package/dist/components/tabs/QTabs.scss +53 -0
- package/dist/components/tabs/QTabs.svelte +163 -46
- package/dist/components/tabs/QTabs.svelte.d.ts +9 -13
- package/dist/components/tabs/docs.d.ts +3 -2
- package/dist/components/tabs/docs.js +13 -3
- package/dist/components/tabs/docs.props.d.ts +5 -16
- package/dist/components/tabs/docs.props.js +64 -30
- package/dist/components/tabs/index.scss +36 -24
- package/dist/components/tabs/props.d.ts +38 -9
- package/dist/components/tabs/props.js +1 -13
- package/dist/components/toolbar/{index.scss → QToolbar.scss} +10 -16
- package/dist/components/toolbar/QToolbar.svelte +26 -21
- package/dist/components/toolbar/QToolbar.svelte.d.ts +4 -15
- package/dist/components/toolbar/QToolbarTitle.svelte +10 -7
- package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +4 -12
- package/dist/components/toolbar/docs.d.ts +3 -2
- package/dist/components/toolbar/docs.js +13 -3
- package/dist/components/toolbar/docs.props.d.ts +5 -16
- package/dist/components/toolbar/docs.props.js +55 -15
- package/dist/components/toolbar/props.d.ts +19 -9
- package/dist/components/tooltip/QTooltip.scss +40 -0
- package/dist/components/tooltip/QTooltip.svelte +200 -10
- package/dist/components/tooltip/QTooltip.svelte.d.ts +17 -18
- package/dist/components/tooltip/QTooltipBase.svelte +86 -0
- package/dist/components/tooltip/QTooltipBase.svelte.d.ts +14 -0
- package/dist/components/tooltip/docs.d.ts +2 -2
- package/dist/components/tooltip/docs.js +3 -2
- package/dist/components/tooltip/docs.props.d.ts +3 -8
- package/dist/components/tooltip/docs.props.js +69 -10
- package/dist/components/tooltip/props.d.ts +36 -4
- package/dist/components/tooltip/props.js +1 -6
- package/dist/composables/index.d.ts +3 -0
- package/dist/composables/index.js +3 -1
- package/dist/composables/{use-align.d.ts → useAlign.d.ts} +1 -1
- package/dist/composables/{use-align.js → useAlign.js} +1 -1
- package/dist/composables/{use-router-link.d.ts → useRouterLink.d.ts} +3 -3
- package/dist/composables/{use-router-link.js → useRouterLink.js} +4 -4
- package/dist/composables/useSize.d.ts +10 -0
- package/dist/composables/useSize.js +37 -0
- package/dist/css/_components.scss +31 -0
- package/dist/css/_disabled.scss +18 -0
- package/dist/css/{ripple.scss → _ripple.scss} +10 -3
- package/dist/css/_variables.scss +73 -0
- package/dist/css/classes/_design.scss +57 -0
- package/dist/css/{flex.scss → classes/_flex.scss} +23 -2
- package/dist/css/classes/_grid.scss +35 -0
- package/dist/css/classes/_index.scss +7 -0
- package/dist/css/classes/_overflow.scss +7 -0
- package/dist/css/classes/_position.scss +7 -0
- package/dist/css/classes/_select.scss +6 -0
- package/dist/css/classes/_spaces.scss +23 -0
- package/dist/css/fonts.scss +18 -4
- package/dist/css/index.css +1 -1
- package/dist/css/index.scss +13 -93
- package/dist/css/mixins/_design.scss +64 -0
- package/dist/css/mixins/_field.scss +64 -0
- package/dist/css/mixins/_image.scss +64 -0
- package/dist/css/mixins/_index.scss +11 -0
- package/dist/css/mixins/_layout.scss +20 -0
- package/dist/css/mixins/{menu.scss → _menu.scss} +4 -2
- package/dist/css/mixins/_responsive.scss +56 -0
- package/dist/css/mixins/{selection.scss → _selection.scss} +10 -70
- package/dist/css/mixins/_spaces.scss +36 -0
- package/dist/css/mixins/_toolbar.scss +7 -0
- package/dist/css/mixins/_typography.scss +7 -0
- package/dist/css/shared/q-field.scss +351 -0
- package/dist/css/theme/_color-classes.scss +332 -0
- package/dist/css/theme/_colors.scss +205 -0
- package/dist/css/theme/_css-variables.scss +5 -0
- package/dist/css/theme/_index.scss +12 -0
- package/dist/css/theme/_page.scss +17 -0
- package/dist/css/theme/{palette.scss → _palette.scss} +27 -5
- package/dist/css/theme/{reset.scss → _reset.scss} +11 -2
- package/dist/css/theme/_typography-variables.scss +107 -0
- package/dist/global.d.ts +1 -1
- package/dist/helpers/clickOutside.d.ts +2 -2
- package/dist/helpers/clickOutside.js +5 -4
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.js +2 -1
- package/dist/helpers/pageTitle.d.ts +1 -0
- package/dist/helpers/pageTitle.js +3 -0
- package/dist/helpers/ripple.d.ts +1 -0
- package/dist/helpers/ripple.js +31 -16
- package/dist/helpers/version.d.ts +1 -1
- package/dist/helpers/version.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/stores/index.d.ts +0 -0
- package/dist/stores/index.js +1 -0
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +3 -4
- package/dist/utils/colors.d.ts +69 -0
- package/dist/utils/colors.js +141 -15
- package/dist/utils/context.d.ts +33 -0
- package/dist/utils/context.js +33 -0
- package/dist/utils/dom.d.ts +3 -0
- package/dist/utils/dom.js +14 -4
- package/dist/utils/events.d.ts +24 -0
- package/dist/utils/events.js +24 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +11 -1
- package/dist/utils/number.d.ts +2 -0
- package/dist/utils/number.js +9 -0
- package/dist/utils/props.d.ts +4 -4
- package/dist/utils/props.js +8 -6
- package/dist/utils/router.d.ts +16 -0
- package/dist/utils/router.js +20 -0
- package/dist/utils/string.d.ts +2 -0
- package/dist/utils/string.js +12 -1
- package/dist/utils/types.d.ts +12 -18
- package/dist/utils/types.js +0 -3
- package/dist/utils/types.json +31 -1
- package/package.json +44 -39
- package/dist/components/breadcrumbs/index.scss +0 -20
- package/dist/components/button/index.scss +0 -98
- package/dist/components/card/index.scss +0 -56
- package/dist/components/chip/index.scss +0 -86
- package/dist/components/drawer/index.scss +0 -59
- package/dist/components/footer/index.scss +0 -28
- package/dist/components/layout/index.scss +0 -387
- package/dist/components/list/index.scss +0 -121
- package/dist/components/progress/index.scss +0 -65
- package/dist/components/railbar/index.scss +0 -39
- package/dist/components/toggle/QToggle.svelte +0 -35
- package/dist/components/toggle/QToggle.svelte.d.ts +0 -23
- package/dist/components/toggle/docs.d.ts +0 -2
- package/dist/components/toggle/docs.js +0 -47
- package/dist/components/toggle/docs.props.d.ts +0 -8
- package/dist/components/toggle/docs.props.js +0 -42
- package/dist/components/toggle/index.scss +0 -31
- package/dist/components/toggle/props.d.ts +0 -9
- package/dist/components/toggle/props.js +0 -9
- package/dist/components/tooltip/index.scss +0 -82
- package/dist/composables/use-index.d.ts +0 -2
- package/dist/composables/use-index.js +0 -17
- package/dist/composables/use-size.d.ts +0 -9
- package/dist/composables/use-size.js +0 -25
- package/dist/css/grid.scss +0 -50
- package/dist/css/mixins/field.scss +0 -432
- package/dist/css/mixins.scss +0 -136
- package/dist/css/states.scss +0 -75
- package/dist/css/theme/bridge.scss +0 -15
- package/dist/css/theme/colors.module.scss +0 -180
- package/dist/css/theme/page.scss +0 -16
- package/dist/css/theme/theme.dark.scss +0 -37
- package/dist/css/theme/theme.light.scss +0 -37
- package/dist/css/theme/theme.scss +0 -11
- package/dist/css/theme/tokens.scss +0 -266
- package/dist/css/variables-sass.scss +0 -16
- package/dist/helpers/activationHandler.d.ts +0 -9
- package/dist/helpers/activationHandler.js +0 -23
- package/dist/stores/QTheme.d.ts +0 -42
- package/dist/stores/QTheme.js +0 -53
- package/dist/stores/Quaff.d.ts +0 -32
- package/dist/stores/Quaff.js +0 -53
- package/dist/utils/fields.d.ts +0 -1
- package/dist/utils/fields.js +0 -14
- package/dist/utils/watchable.d.ts +0 -3
- package/dist/utils/watchable.js +0 -22
- /package/dist/css/mixins/{table.scss → _table.scss} +0 -0
- /package/dist/css/theme/{elevate.scss → _elevate.scss} +0 -0
- /package/dist/css/theme/{typography.module.scss → _typography-classes.scss} +0 -0
- /package/dist/css/theme/{typography.scss → _typography.scss} +0 -0
package/dist/utils/colors.d.ts
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
export type Mode = "light" | "dark";
|
|
2
|
+
export type HexValue = `#${string}`;
|
|
3
|
+
type BaseColorNames = [
|
|
4
|
+
"error",
|
|
5
|
+
"error-container",
|
|
6
|
+
"on-error",
|
|
7
|
+
"on-error-container",
|
|
8
|
+
"on-primary",
|
|
9
|
+
"on-primary-container",
|
|
10
|
+
"on-secondary",
|
|
11
|
+
"on-secondary-container",
|
|
12
|
+
"on-tertiary",
|
|
13
|
+
"on-tertiary-container",
|
|
14
|
+
"primary",
|
|
15
|
+
"primary-container",
|
|
16
|
+
"secondary",
|
|
17
|
+
"secondary-container",
|
|
18
|
+
"tertiary",
|
|
19
|
+
"tertiary-container"
|
|
20
|
+
];
|
|
21
|
+
type BaseColors = Record<BaseColorNames[number], HexValue>;
|
|
22
|
+
type ToneColorNames = [
|
|
23
|
+
"background",
|
|
24
|
+
"inverse-on-surface",
|
|
25
|
+
"inverse-primary",
|
|
26
|
+
"inverse-surface",
|
|
27
|
+
"on-background",
|
|
28
|
+
"on-primary-fixed",
|
|
29
|
+
"on-primary-fixed-variant",
|
|
30
|
+
"on-secondary-fixed",
|
|
31
|
+
"on-secondary-fixed-variant",
|
|
32
|
+
"on-surface",
|
|
33
|
+
"on-surface-variant",
|
|
34
|
+
"on-tertiary-fixed",
|
|
35
|
+
"on-tertiary-fixed-variant",
|
|
36
|
+
"outline",
|
|
37
|
+
"outline-variant",
|
|
38
|
+
"primary-fixed",
|
|
39
|
+
"primary-fixed-dim",
|
|
40
|
+
"scrim",
|
|
41
|
+
"secondary-fixed",
|
|
42
|
+
"secondary-fixed-dim",
|
|
43
|
+
"shadow",
|
|
44
|
+
"surface",
|
|
45
|
+
"surface-bright",
|
|
46
|
+
"surface-container",
|
|
47
|
+
"surface-container-high",
|
|
48
|
+
"surface-container-highest",
|
|
49
|
+
"surface-container-low",
|
|
50
|
+
"surface-container-lowest",
|
|
51
|
+
"surface-dim",
|
|
52
|
+
"surface-tint",
|
|
53
|
+
"surface-variant",
|
|
54
|
+
"tertiary-fixed",
|
|
55
|
+
"tertiary-fixed-dim"
|
|
56
|
+
];
|
|
57
|
+
type ToneColors = Record<ToneColorNames[number], HexValue>;
|
|
58
|
+
export type QuaffColorNames = [...BaseColorNames, ...ToneColorNames];
|
|
59
|
+
export type QuaffColors = BaseColors & ToneColors;
|
|
60
|
+
export declare function generateColors(from: string): {
|
|
61
|
+
light: QuaffColors;
|
|
62
|
+
dark: QuaffColors;
|
|
63
|
+
};
|
|
1
64
|
declare class QColors {
|
|
2
65
|
private static hexRegex;
|
|
3
66
|
private static isValidRgb;
|
|
@@ -6,5 +69,11 @@ declare class QColors {
|
|
|
6
69
|
static hexToRgb(hex: string): number[];
|
|
7
70
|
static rgbToHsl(r: string | number, g: string | number, b: string | number): number[];
|
|
8
71
|
static hslToRgb(h: string | number, s: string | number, l: string | number): number[];
|
|
72
|
+
static hexToHsl(hex: HexValue): {
|
|
73
|
+
h: number;
|
|
74
|
+
s: number;
|
|
75
|
+
l: number;
|
|
76
|
+
};
|
|
77
|
+
static calculateHueRotate(fromHex: HexValue, toHex: HexValue): number;
|
|
9
78
|
}
|
|
10
79
|
export default QColors;
|
package/dist/utils/colors.js
CHANGED
|
@@ -1,10 +1,89 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { argbFromHex, hexFromArgb, themeFromSourceColor, } from "@material/material-color-utilities";
|
|
2
|
+
import { isNumeric } from "./number.js";
|
|
3
|
+
import { convertCase } from "./string.js";
|
|
4
|
+
const COLOR_TONES = {
|
|
5
|
+
background: { fromColor: "neutral", light: 98, dark: 6 },
|
|
6
|
+
"inverse-on-surface": { fromColor: "neutral", light: 95, dark: 20 },
|
|
7
|
+
"inverse-primary": { fromColor: "primary", light: 80, dark: 40 },
|
|
8
|
+
"inverse-surface": { fromColor: "neutral", light: 20, dark: 90 },
|
|
9
|
+
"on-background": { fromColor: "neutral", light: 10, dark: 90 },
|
|
10
|
+
"on-primary-fixed": { fromColor: "primary", light: 10, dark: 10 },
|
|
11
|
+
"on-primary-fixed-variant": { fromColor: "primary", light: 30, dark: 30 },
|
|
12
|
+
"on-secondary-fixed": { fromColor: "secondary", light: 10, dark: 10 },
|
|
13
|
+
"on-secondary-fixed-variant": { fromColor: "secondary", light: 30, dark: 30 },
|
|
14
|
+
"on-surface": { fromColor: "neutral", light: 10, dark: 90 },
|
|
15
|
+
"on-surface-variant": { fromColor: "neutralVariant", light: 30, dark: 80 },
|
|
16
|
+
"on-tertiary-fixed": { fromColor: "tertiary", light: 10, dark: 10 },
|
|
17
|
+
"on-tertiary-fixed-variant": { fromColor: "tertiary", light: 30, dark: 30 },
|
|
18
|
+
outline: { fromColor: "neutralVariant", light: 50, dark: 60 },
|
|
19
|
+
"outline-variant": { fromColor: "neutralVariant", light: 80, dark: 30 },
|
|
20
|
+
"primary-fixed": { fromColor: "primary", light: 90, dark: 90 },
|
|
21
|
+
"primary-fixed-dim": { fromColor: "primary", light: 80, dark: 80 },
|
|
22
|
+
scrim: { fromColor: "neutral", light: 0, dark: 0 },
|
|
23
|
+
"secondary-fixed": { fromColor: "secondary", light: 90, dark: 90 },
|
|
24
|
+
"secondary-fixed-dim": { fromColor: "secondary", light: 80, dark: 80 },
|
|
25
|
+
shadow: { fromColor: "neutral", light: 0, dark: 0 },
|
|
26
|
+
surface: { fromColor: "neutral", light: 98, dark: 6 },
|
|
27
|
+
"surface-bright": { fromColor: "neutral", light: 98, dark: 24 },
|
|
28
|
+
"surface-container": { fromColor: "neutral", light: 94, dark: 12 },
|
|
29
|
+
"surface-container-high": { fromColor: "neutral", light: 92, dark: 17 },
|
|
30
|
+
"surface-container-highest": { fromColor: "neutral", light: 90, dark: 22 },
|
|
31
|
+
"surface-container-low": { fromColor: "neutral", light: 96, dark: 10 },
|
|
32
|
+
"surface-container-lowest": { fromColor: "neutral", light: 100, dark: 4 },
|
|
33
|
+
"surface-dim": { fromColor: "neutral", light: 87, dark: 6 },
|
|
34
|
+
"surface-tint": { fromColor: "primary", light: 40, dark: 80 },
|
|
35
|
+
"surface-variant": { fromColor: "neutralVariant", light: 90, dark: 30 },
|
|
36
|
+
"tertiary-fixed": { fromColor: "tertiary", light: 90, dark: 90 },
|
|
37
|
+
"tertiary-fixed-dim": { fromColor: "tertiary", light: 80, dark: 80 },
|
|
38
|
+
};
|
|
39
|
+
export function generateColors(from) {
|
|
40
|
+
const argb = argbFromHex(from);
|
|
41
|
+
const palettes = themeFromSourceColor(argb).palettes;
|
|
42
|
+
return {
|
|
43
|
+
light: getColors(palettes, "light"),
|
|
44
|
+
dark: getColors(palettes, "dark"),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getColors(palettes, mode) {
|
|
48
|
+
const tones = mode === "light"
|
|
49
|
+
? {
|
|
50
|
+
base: 40,
|
|
51
|
+
onBase: 100,
|
|
52
|
+
baseContainer: 90,
|
|
53
|
+
onBaseContainer: 30,
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
base: 80,
|
|
57
|
+
onBase: 20,
|
|
58
|
+
baseContainer: 30,
|
|
59
|
+
onBaseContainer: 90,
|
|
60
|
+
};
|
|
61
|
+
const getColor = (color, palette) => {
|
|
62
|
+
color = convertCase(color, "pascal", "kebab");
|
|
63
|
+
return [
|
|
64
|
+
[color, palette.tone(tones.base)],
|
|
65
|
+
[`on-${color}`, palette.tone(tones.onBase)],
|
|
66
|
+
[`${color}-container`, palette.tone(tones.baseContainer)],
|
|
67
|
+
[`on-${color}-container`, palette.tone(tones.onBaseContainer)],
|
|
68
|
+
];
|
|
69
|
+
};
|
|
70
|
+
const results = Object.fromEntries(Object.entries(palettes)
|
|
71
|
+
.filter(([color]) => !["neutral", "neutralVariant"].includes(color))
|
|
72
|
+
.map(([color, palette]) => getColor(color, palette))
|
|
73
|
+
.flat(1));
|
|
74
|
+
let toneColor;
|
|
75
|
+
for (toneColor in COLOR_TONES) {
|
|
76
|
+
const toneInfo = COLOR_TONES[toneColor];
|
|
77
|
+
results[toneColor] = palettes[toneInfo.fromColor].tone(toneInfo[mode]);
|
|
78
|
+
}
|
|
79
|
+
return Object.fromEntries(Object.entries(results).map(([color, value]) => [color, hexFromArgb(value)]));
|
|
80
|
+
}
|
|
2
81
|
class QColors {
|
|
3
82
|
static hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
4
83
|
static isValidRgb(r, g, b) {
|
|
5
|
-
return (
|
|
6
|
-
|
|
7
|
-
|
|
84
|
+
return (isNumeric(r) &&
|
|
85
|
+
isNumeric(g) &&
|
|
86
|
+
isNumeric(b) &&
|
|
8
87
|
+r >= 0 &&
|
|
9
88
|
+r <= 255 &&
|
|
10
89
|
+g >= 0 &&
|
|
@@ -13,9 +92,9 @@ class QColors {
|
|
|
13
92
|
+b <= 255);
|
|
14
93
|
}
|
|
15
94
|
static isValidHsl(h, s, l) {
|
|
16
|
-
return (
|
|
17
|
-
|
|
18
|
-
|
|
95
|
+
return (isNumeric(h) &&
|
|
96
|
+
isNumeric(s) &&
|
|
97
|
+
isNumeric(l) &&
|
|
19
98
|
+h >= 0 &&
|
|
20
99
|
+h <= 360 &&
|
|
21
100
|
+s >= 0 &&
|
|
@@ -42,9 +121,12 @@ class QColors {
|
|
|
42
121
|
if (!QColors.isValidRgb(r, g, b)) {
|
|
43
122
|
throw new Error("Invalid RGB values. They should be in the range 0-255.");
|
|
44
123
|
}
|
|
45
|
-
|
|
124
|
+
r = +r / 255;
|
|
125
|
+
g = +g / 255;
|
|
126
|
+
b = +b / 255;
|
|
46
127
|
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
47
|
-
|
|
128
|
+
const l = (max + min) / 2;
|
|
129
|
+
let h, s;
|
|
48
130
|
if (max === min) {
|
|
49
131
|
h = s = 0; // achromatic
|
|
50
132
|
}
|
|
@@ -72,22 +154,29 @@ class QColors {
|
|
|
72
154
|
throw new Error("Invalid HSL values. Hue should be in the range 0-360, saturation and lightness in the range 0-100.");
|
|
73
155
|
}
|
|
74
156
|
let r, g, b;
|
|
75
|
-
|
|
157
|
+
h = +h / 360;
|
|
158
|
+
s = +s / 100;
|
|
159
|
+
l = +l / 100;
|
|
76
160
|
if (s === 0) {
|
|
77
161
|
r = g = b = l; // achromatic
|
|
78
162
|
}
|
|
79
163
|
else {
|
|
80
164
|
const hue2rgb = (p, q, t) => {
|
|
81
|
-
if (t < 0)
|
|
165
|
+
if (t < 0) {
|
|
82
166
|
t += 1;
|
|
83
|
-
|
|
167
|
+
}
|
|
168
|
+
if (t > 1) {
|
|
84
169
|
t -= 1;
|
|
85
|
-
|
|
170
|
+
}
|
|
171
|
+
if (t < 1 / 6) {
|
|
86
172
|
return p + (q - p) * 6 * t;
|
|
87
|
-
|
|
173
|
+
}
|
|
174
|
+
if (t < 1 / 2) {
|
|
88
175
|
return q;
|
|
89
|
-
|
|
176
|
+
}
|
|
177
|
+
if (t < 2 / 3) {
|
|
90
178
|
return p + (q - p) * (2 / 3 - t) * 6;
|
|
179
|
+
}
|
|
91
180
|
return p;
|
|
92
181
|
};
|
|
93
182
|
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
@@ -98,5 +187,42 @@ class QColors {
|
|
|
98
187
|
}
|
|
99
188
|
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
|
|
100
189
|
}
|
|
190
|
+
static hexToHsl(hex) {
|
|
191
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
192
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
193
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
194
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
195
|
+
let h = 0, s;
|
|
196
|
+
const l = (max + min) / 2;
|
|
197
|
+
if (max === min) {
|
|
198
|
+
h = s = 0; // achromatic
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const d = max - min;
|
|
202
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
203
|
+
switch (max) {
|
|
204
|
+
case r:
|
|
205
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
206
|
+
break;
|
|
207
|
+
case g:
|
|
208
|
+
h = (b - r) / d + 2;
|
|
209
|
+
break;
|
|
210
|
+
case b:
|
|
211
|
+
h = (r - g) / d + 4;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
h *= 60;
|
|
215
|
+
}
|
|
216
|
+
return { h, s: s * 100, l: l * 100 };
|
|
217
|
+
}
|
|
218
|
+
static calculateHueRotate(fromHex, toHex) {
|
|
219
|
+
const from = QColors.hexToHsl(fromHex);
|
|
220
|
+
const to = QColors.hexToHsl(toHex);
|
|
221
|
+
let rotate = to.h - from.h;
|
|
222
|
+
if (rotate < 0) {
|
|
223
|
+
rotate += 360;
|
|
224
|
+
}
|
|
225
|
+
return Math.round(rotate);
|
|
226
|
+
}
|
|
101
227
|
}
|
|
102
228
|
export default QColors;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const QBreadcrumbsCtxName: {
|
|
2
|
+
activeColor: symbol;
|
|
3
|
+
separator: symbol;
|
|
4
|
+
};
|
|
5
|
+
export declare const QDocsCtxName: {
|
|
6
|
+
snippets: symbol;
|
|
7
|
+
};
|
|
8
|
+
export declare const QItemCtxName: {
|
|
9
|
+
activeClass: symbol;
|
|
10
|
+
multiline: symbol;
|
|
11
|
+
};
|
|
12
|
+
export declare const QLayoutCtxName: {
|
|
13
|
+
view: symbol;
|
|
14
|
+
header: symbol;
|
|
15
|
+
footer: symbol;
|
|
16
|
+
railbar: {
|
|
17
|
+
left: symbol;
|
|
18
|
+
right: symbol;
|
|
19
|
+
};
|
|
20
|
+
drawer: {
|
|
21
|
+
left: symbol;
|
|
22
|
+
right: symbol;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const QListCtxName: {
|
|
26
|
+
activeClass: symbol;
|
|
27
|
+
separator: symbol;
|
|
28
|
+
};
|
|
29
|
+
export declare const QTabsCtxName: {
|
|
30
|
+
request: symbol;
|
|
31
|
+
value: symbol;
|
|
32
|
+
variant: symbol;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const QBreadcrumbsCtxName = {
|
|
2
|
+
activeColor: Symbol("activeColor"),
|
|
3
|
+
separator: Symbol("separator"),
|
|
4
|
+
};
|
|
5
|
+
export const QDocsCtxName = {
|
|
6
|
+
snippets: Symbol("snippets"),
|
|
7
|
+
};
|
|
8
|
+
export const QItemCtxName = {
|
|
9
|
+
activeClass: Symbol("activeClass"),
|
|
10
|
+
multiline: Symbol("multiline"),
|
|
11
|
+
};
|
|
12
|
+
export const QLayoutCtxName = {
|
|
13
|
+
view: Symbol("layoutView"),
|
|
14
|
+
header: Symbol("QHeader"),
|
|
15
|
+
footer: Symbol("QFooter"),
|
|
16
|
+
railbar: {
|
|
17
|
+
left: Symbol("QRailbar-left"),
|
|
18
|
+
right: Symbol("QRailbar-right"),
|
|
19
|
+
},
|
|
20
|
+
drawer: {
|
|
21
|
+
left: Symbol("QDrawer-left"),
|
|
22
|
+
right: Symbol("QDrawer-right"),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const QListCtxName = {
|
|
26
|
+
activeClass: Symbol("activeClass"),
|
|
27
|
+
separator: Symbol("separator"),
|
|
28
|
+
};
|
|
29
|
+
export const QTabsCtxName = {
|
|
30
|
+
request: Symbol("request"),
|
|
31
|
+
value: Symbol("value"),
|
|
32
|
+
variant: Symbol("variant"),
|
|
33
|
+
};
|
package/dist/utils/dom.d.ts
CHANGED
|
@@ -6,3 +6,6 @@ export declare function getFocusableChildren<T extends HTMLElement>(el: T): T[];
|
|
|
6
6
|
export declare function getClosestFocusableChild(el: HTMLElement): HTMLElement;
|
|
7
7
|
export declare function getClosestFocusableSibling<T extends HTMLElement>(el: T, direction: Direction): HTMLElement;
|
|
8
8
|
export declare function getClosestFocusableBlock(el: HTMLElement, direction: Direction): HTMLElement;
|
|
9
|
+
export declare function movementDirection(from: HTMLElement, to: HTMLElement): Direction;
|
|
10
|
+
export declare function shouldReduceMotion(): boolean;
|
|
11
|
+
export declare function elFromSelector<T extends HTMLElement>(selector: string | T | null | typeof window | Document): Document | (Window & typeof globalThis) | T | null;
|
package/dist/utils/dom.js
CHANGED
|
@@ -21,14 +21,14 @@ export function getFocusableChildren(el) {
|
|
|
21
21
|
return Array.from(el.querySelectorAll(focusableElements));
|
|
22
22
|
}
|
|
23
23
|
export function getClosestFocusableChild(el) {
|
|
24
|
-
|
|
24
|
+
const children = Array.from(el.querySelectorAll(focusableElements));
|
|
25
25
|
const focusableChildren = children.filter(isFocusable);
|
|
26
26
|
return focusableChildren[0] || null;
|
|
27
27
|
}
|
|
28
28
|
export function getClosestFocusableSibling(el, direction) {
|
|
29
29
|
const parent = getParentElement(el);
|
|
30
30
|
const allSiblings = Array.from(parent.childNodes);
|
|
31
|
-
|
|
31
|
+
const filtered = allSiblings.filter(isFocusable);
|
|
32
32
|
const indexOfEl = filtered.indexOf(el);
|
|
33
33
|
if (direction === "next") {
|
|
34
34
|
const i = indexOfEl + 1 === filtered.length ? 0 : indexOfEl + 1;
|
|
@@ -48,8 +48,8 @@ export function getClosestFocusableSibling(el, direction) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
export function getClosestFocusableBlock(el, direction) {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const parent = getParentElement(el);
|
|
52
|
+
const parentFocusableChildren = getFocusableChildren(parent);
|
|
53
53
|
function getNextFocusableBlock(parentBlock) {
|
|
54
54
|
const grandParent = getParentElement(parentBlock);
|
|
55
55
|
const grandParentChildren = getAllChildren(grandParent);
|
|
@@ -69,3 +69,13 @@ export function getClosestFocusableBlock(el, direction) {
|
|
|
69
69
|
}
|
|
70
70
|
return targetBlock;
|
|
71
71
|
}
|
|
72
|
+
export function movementDirection(from, to) {
|
|
73
|
+
const relativePosition = from.compareDocumentPosition(to);
|
|
74
|
+
return relativePosition === 2 ? "previous" : "next";
|
|
75
|
+
}
|
|
76
|
+
export function shouldReduceMotion() {
|
|
77
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
78
|
+
}
|
|
79
|
+
export function elFromSelector(selector) {
|
|
80
|
+
return typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
81
|
+
}
|
package/dist/utils/events.d.ts
CHANGED
|
@@ -11,3 +11,27 @@ export declare function isTabKey(e: KeyboardEvent): e is KeyboardEvent & {
|
|
|
11
11
|
export declare function getDirection(e: KeyboardEvent & {
|
|
12
12
|
code: "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight";
|
|
13
13
|
}): Direction;
|
|
14
|
+
type EventMap<T> = T extends HTMLElement ? HTMLElementEventMap : T extends typeof window ? WindowEventMap : DocumentEventMap;
|
|
15
|
+
/**
|
|
16
|
+
* Adds an event listener to an element.
|
|
17
|
+
*
|
|
18
|
+
* @param el The element to add the event listener to. If `null` or `undefined`, nothing is added.
|
|
19
|
+
* @param event The event to listen for.
|
|
20
|
+
* @param callback The function to call when the event is triggered.
|
|
21
|
+
* @returns An object with a single method, `remove()`, which removes the event listener.
|
|
22
|
+
*/
|
|
23
|
+
export declare function addEventListener<T extends HTMLElement | typeof window | typeof document, K extends keyof EventMap<T>>(el: T | undefined | null, event: K, callback: (e: EventMap<T>[K]) => void): {
|
|
24
|
+
remove: () => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Adds multiple event listeners to an element.
|
|
28
|
+
*
|
|
29
|
+
* @param el The element to add the event listener to. If `null` or `undefined`, nothing is added.
|
|
30
|
+
* @param events The events to listen for.
|
|
31
|
+
* @param callback The function to call when any of the events are triggered.
|
|
32
|
+
* @returns An object with a single method, `remove()`, which removes the event listeners.
|
|
33
|
+
*/
|
|
34
|
+
export declare function addEventListener<T extends HTMLElement | typeof window | typeof document, K extends keyof EventMap<T>>(el: T | undefined | null, events: K[], callback: (e: EventMap<T>[K]) => void): {
|
|
35
|
+
remove: () => void;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
package/dist/utils/events.js
CHANGED
|
@@ -11,3 +11,27 @@ export function isTabKey(e) {
|
|
|
11
11
|
export function getDirection(e) {
|
|
12
12
|
return ["ArrowDown", "ArrowRight"].includes(e.code) ? "next" : "previous";
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Adds one or more event listeners to an element.
|
|
16
|
+
*
|
|
17
|
+
* @param el The element to add the event listener(s) to. If `null` or `undefined`, no action is taken.
|
|
18
|
+
* @param events An event or an array of events to listen for.
|
|
19
|
+
* @param callback The function to call when the event(s) are triggered.
|
|
20
|
+
* @returns An object with a `remove()` method to remove the event listener(s) added.
|
|
21
|
+
*/
|
|
22
|
+
export function addEventListener(el, events, callback) {
|
|
23
|
+
if (!el) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(events)) {
|
|
27
|
+
const listeners = events.map((event) => addEventListener(el, event, callback));
|
|
28
|
+
return {
|
|
29
|
+
remove: () => listeners.forEach((listener) => listener.remove()),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Type casting to align with the broader compatibility between HTMLElement, Window, and Document
|
|
33
|
+
el.addEventListener(events, callback);
|
|
34
|
+
return {
|
|
35
|
+
remove: () => el.removeEventListener(events, callback),
|
|
36
|
+
};
|
|
37
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./clipboard";
|
|
2
|
+
export * from "./colors";
|
|
3
|
+
export { default as QColors } from "./colors";
|
|
4
|
+
export * from "./context";
|
|
5
|
+
export * from "./dom";
|
|
6
|
+
export * from "./events";
|
|
7
|
+
export * from "./number";
|
|
8
|
+
export * from "./props";
|
|
9
|
+
export * from "./router";
|
|
10
|
+
export * from "./string";
|
|
11
|
+
export * from "./types";
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "./clipboard";
|
|
2
|
+
export * from "./colors";
|
|
3
|
+
export { default as QColors } from "./colors";
|
|
4
|
+
export * from "./context";
|
|
5
|
+
export * from "./dom";
|
|
6
|
+
export * from "./events";
|
|
7
|
+
export * from "./number";
|
|
8
|
+
export * from "./props";
|
|
9
|
+
export * from "./router";
|
|
10
|
+
export * from "./string";
|
|
11
|
+
export * from "./types";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function isNumeric(input) {
|
|
2
|
+
return typeof input === "number" || !isNaN(Number(input));
|
|
3
|
+
}
|
|
4
|
+
export function between(value, min, max) {
|
|
5
|
+
if (max < min) {
|
|
6
|
+
console.warn(`max (${max}) should not be smaller than min (${min}).`);
|
|
7
|
+
}
|
|
8
|
+
return max <= min ? min : Math.min(max, Math.max(min, value));
|
|
9
|
+
}
|
package/dist/utils/props.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare function createStyles(styleObj: Record<string, string | number | boolean | null | undefined>, userStyles?: string): string | null;
|
|
1
|
+
export declare function createStyles(styleObj: Record<string, string | number | boolean | null | undefined>, userStyles?: string | null): string | null;
|
|
2
2
|
interface CreateClassesOptions {
|
|
3
3
|
component?: string;
|
|
4
4
|
element?: string;
|
|
5
|
-
userClasses?: string;
|
|
6
|
-
quaffClasses?:
|
|
5
|
+
userClasses?: string | null;
|
|
6
|
+
quaffClasses?: unknown[];
|
|
7
7
|
}
|
|
8
|
-
export declare function createClasses(modifiers:
|
|
8
|
+
export declare function createClasses(modifiers: unknown[], options?: CreateClassesOptions): string;
|
|
9
9
|
export {};
|
package/dist/utils/props.js
CHANGED
|
@@ -2,14 +2,15 @@ import { convertCase } from "./string";
|
|
|
2
2
|
export function createStyles(styleObj, userStyles) {
|
|
3
3
|
const stylesArray = Object.entries(styleObj);
|
|
4
4
|
const toJoin = [];
|
|
5
|
-
for (
|
|
5
|
+
for (const [styleName, styleVal] of stylesArray) {
|
|
6
6
|
if (styleVal === undefined || styleVal === null || styleVal === false) {
|
|
7
7
|
continue;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
toJoin.push(`${convertCase(styleName, "camel", "kebab")}: ${styleVal}`);
|
|
10
|
+
}
|
|
11
|
+
if (userStyles) {
|
|
12
|
+
toJoin.push(userStyles);
|
|
11
13
|
}
|
|
12
|
-
userStyles && toJoin.push(userStyles);
|
|
13
14
|
if (toJoin.length === 0) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
@@ -19,12 +20,13 @@ export function createClasses(modifiers, options = { userClasses: "", quaffClass
|
|
|
19
20
|
const userClasses = options.userClasses?.trim();
|
|
20
21
|
const quaffClasses = options.quaffClasses?.length && createClasses(options.quaffClasses);
|
|
21
22
|
const baseClasses = `${quaffClasses || ""} ${userClasses || ""}`.trim();
|
|
22
|
-
|
|
23
|
+
const component = options.component;
|
|
24
|
+
let element;
|
|
23
25
|
if (component && options.element) {
|
|
24
26
|
element = `${component}__${options.element}`;
|
|
25
27
|
}
|
|
26
28
|
const filteredModifiers = modifiers.filter(Boolean);
|
|
27
|
-
|
|
29
|
+
const withModifiers = component
|
|
28
30
|
? filteredModifiers.map((modifier) => `${element || component}--${modifier}`)
|
|
29
31
|
: filteredModifiers;
|
|
30
32
|
return [element || component, ...withModifiers, baseClasses].filter(Boolean).join(" ").trim();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RouterProps {
|
|
2
|
+
activeClass?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
href?: string;
|
|
5
|
+
replace?: boolean;
|
|
6
|
+
to?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function isRouteActive(route?: string): boolean;
|
|
9
|
+
export declare function getRouterInfo<T extends RouterProps>(props: T): {
|
|
10
|
+
hasLink: boolean;
|
|
11
|
+
linkAttributes: {
|
|
12
|
+
href: string | undefined;
|
|
13
|
+
"data-sveltekit-reload": boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
linkClasses: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { page } from "$app/state";
|
|
2
|
+
export function isRouteActive(route) {
|
|
3
|
+
if (!route) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
return page.url.pathname === route || page.url.pathname.startsWith(`${route}/`);
|
|
7
|
+
}
|
|
8
|
+
export function getRouterInfo(props) {
|
|
9
|
+
const hasLink = [props.to, props.href].some((entry) => entry !== undefined);
|
|
10
|
+
const linkClasses = `${hasLink ? "q-link" : ""} ${props.disabled ? "disabled" : ""}`.trim();
|
|
11
|
+
const linkAttributes = {
|
|
12
|
+
href: props.to || props.href,
|
|
13
|
+
"data-sveltekit-reload": props.replace ? true : undefined,
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
hasLink,
|
|
17
|
+
linkAttributes,
|
|
18
|
+
linkClasses,
|
|
19
|
+
};
|
|
20
|
+
}
|
package/dist/utils/string.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ declare const cases: {
|
|
|
7
7
|
snake: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function convertCase(str: string, fromCase: keyof typeof cases, toCase: keyof typeof cases): string;
|
|
10
|
+
export declare function extractImgSrc(prop?: string): string | undefined;
|
|
11
|
+
export declare function escape(str: string): string;
|
|
10
12
|
export {};
|
package/dist/utils/string.js
CHANGED
|
@@ -31,6 +31,7 @@ function convertToKebabSnakeCase(str, caseType) {
|
|
|
31
31
|
.join("");
|
|
32
32
|
}
|
|
33
33
|
export function convertCase(str, fromCase, toCase) {
|
|
34
|
+
const uncap = uncapitalize(str);
|
|
34
35
|
switch (fromCase) {
|
|
35
36
|
case "camel":
|
|
36
37
|
if (toCase === "pascal") {
|
|
@@ -41,7 +42,6 @@ export function convertCase(str, fromCase, toCase) {
|
|
|
41
42
|
}
|
|
42
43
|
break;
|
|
43
44
|
case "pascal":
|
|
44
|
-
let uncap = uncapitalize(str);
|
|
45
45
|
if (toCase === "camel") {
|
|
46
46
|
return uncap;
|
|
47
47
|
}
|
|
@@ -76,3 +76,14 @@ export function convertCase(str, fromCase, toCase) {
|
|
|
76
76
|
}
|
|
77
77
|
return str;
|
|
78
78
|
}
|
|
79
|
+
export function extractImgSrc(prop) {
|
|
80
|
+
return prop?.startsWith("img:") ? prop.slice(4) : undefined;
|
|
81
|
+
}
|
|
82
|
+
export function escape(str) {
|
|
83
|
+
return str
|
|
84
|
+
.replace("&", "&")
|
|
85
|
+
.replace('"', """)
|
|
86
|
+
.replace("'", "'")
|
|
87
|
+
.replace("<", "<")
|
|
88
|
+
.replace(">", ">");
|
|
89
|
+
}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
1
|
+
import { ParsedProp, ParsedSnippet } from "../../../docgen/props/parseInterface";
|
|
1
2
|
export interface NativeProps {
|
|
2
|
-
userClasses?: string;
|
|
3
|
-
userStyles?: string;
|
|
3
|
+
userClasses?: string | null;
|
|
4
|
+
userStyles?: string | null;
|
|
4
5
|
}
|
|
5
6
|
export declare const NativePropsDefaults: NativeProps;
|
|
6
|
-
export type QuaffSizes = "xs" | "sm" | "md" | "lg" | "xl";
|
|
7
|
+
export type QuaffSizes = "none" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
7
8
|
export type CssUnit = "px" | "%" | "em" | "ex" | "ch" | "rem" | "vw" | "vh" | "vmin" | "vmax";
|
|
8
9
|
export type CssValue = `${number}${CssUnit}`;
|
|
9
10
|
export interface QComponentDocs {
|
|
10
11
|
name: string;
|
|
11
12
|
description: string;
|
|
12
13
|
docs: {
|
|
13
|
-
props:
|
|
14
|
-
|
|
14
|
+
props: ParsedProp[];
|
|
15
|
+
snippets: ParsedSnippet[];
|
|
15
16
|
methods: QComponentMethod[];
|
|
16
17
|
events: QComponentEvent[];
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
export interface QComponentProp {
|
|
20
|
-
name: string;
|
|
21
|
-
type: string;
|
|
22
|
-
default?: any;
|
|
23
|
-
description: string;
|
|
24
|
-
clickableType?: boolean;
|
|
25
|
-
optional?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface QComponentSlot {
|
|
28
|
-
name: string;
|
|
29
|
-
description: string;
|
|
30
|
-
}
|
|
31
20
|
export interface QComponentType {
|
|
32
21
|
name: string;
|
|
33
22
|
description: string;
|
|
@@ -42,4 +31,9 @@ export interface QComponentMethod {
|
|
|
42
31
|
type: string;
|
|
43
32
|
description: string;
|
|
44
33
|
}
|
|
45
|
-
export
|
|
34
|
+
export type Entries<T> = {
|
|
35
|
+
[K in keyof T]: [K, T[K]];
|
|
36
|
+
}[keyof T][];
|
|
37
|
+
export type QEvent<T, E> = T & {
|
|
38
|
+
currentTarget: EventTarget & E;
|
|
39
|
+
};
|