@gild-ui/vue 0.0.0-stage → 0.1.0-alpha.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/dist/Button.cjs +238 -0
  4. package/dist/Button.d.cts +17 -0
  5. package/dist/Button.d.mts +17 -0
  6. package/dist/Button.mjs +237 -0
  7. package/dist/Button.types-BnJ28ym9.d.mts +1113 -0
  8. package/dist/Flex.cjs +25 -0
  9. package/dist/Flex.d.cts +11 -0
  10. package/dist/Flex.d.mts +11 -0
  11. package/dist/Flex.mjs +24 -0
  12. package/dist/Modal.cjs +369 -0
  13. package/dist/Modal.d.cts +23 -0
  14. package/dist/Modal.d.mts +23 -0
  15. package/dist/Modal.mjs +368 -0
  16. package/dist/TextInput.cjs +299 -0
  17. package/dist/TextInput.d.cts +37 -0
  18. package/dist/TextInput.d.mts +37 -0
  19. package/dist/TextInput.mjs +298 -0
  20. package/dist/ThemeProvider-CareN7BO.mjs +58 -0
  21. package/dist/ThemeProvider-DIeSdYou.cjs +63 -0
  22. package/dist/ThemeProvider.cjs +3 -0
  23. package/dist/ThemeProvider.d.cts +25 -0
  24. package/dist/ThemeProvider.d.mts +25 -0
  25. package/dist/ThemeProvider.mjs +1 -0
  26. package/dist/Typography.cjs +72 -0
  27. package/dist/Typography.d.cts +15 -0
  28. package/dist/Typography.d.mts +15 -0
  29. package/dist/Typography.mjs +71 -0
  30. package/dist/View.cjs +12 -0
  31. package/dist/View.d.cts +11 -0
  32. package/dist/View.d.mts +11 -0
  33. package/dist/View.mjs +11 -0
  34. package/dist/ViewRoot-CsaIxrtD.mjs +40 -0
  35. package/dist/ViewRoot-X9F9RROv.cjs +45 -0
  36. package/dist/bridge-D-x2kK4r.d.mts +36 -0
  37. package/dist/bridge-t6zHXVt-.d.cts +36 -0
  38. package/dist/engine.cjs +82 -0
  39. package/dist/engine.d.cts +46 -0
  40. package/dist/engine.d.mts +46 -0
  41. package/dist/engine.mjs +26 -0
  42. package/dist/index.cjs +57 -0
  43. package/dist/index.d.cts +37 -0
  44. package/dist/index.d.mts +37 -0
  45. package/dist/index.mjs +6 -0
  46. package/dist/props-BRLGZVjJ.d.mts +21 -0
  47. package/dist/props-Bzm7Wbdv.d.cts +21 -0
  48. package/dist/props-DDBSpAkG.mjs +49 -0
  49. package/dist/props-DxoB9cT4.cjs +72 -0
  50. package/dist/styled-Cmxvlft5.mjs +34 -0
  51. package/dist/styled-JHkZtq_1.cjs +39 -0
  52. package/dist/themes-BqxOUMCB.cjs +12 -0
  53. package/dist/themes-CgFrk0_b.d.cts +1112 -0
  54. package/dist/themes-rGHVhV5e.mjs +8 -0
  55. package/dist/useDefaultProps--fOGOSGa.mjs +18 -0
  56. package/dist/useDefaultProps-qCDgeYFm.cjs +23 -0
  57. package/dist/useTheme.cjs +8 -0
  58. package/dist/useTheme.d.cts +3 -0
  59. package/dist/useTheme.d.mts +3 -0
  60. package/dist/useTheme.mjs +1 -0
  61. package/package.json +171 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Masoud Soroush <https://soroush.tech>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,98 @@
1
- # Temporary Holding Version
1
+ [![npm version](https://img.shields.io/npm/v/@gild-ui/vue.svg?cacheSeconds=86400)](https://www.npmjs.com/package/@gild-ui/vue)
2
+ [![coverage](https://codecov.io/gh/soroush-tech/design-system/branch/main/graph/badge.svg?flag=vue)](https://app.codecov.io/gh/soroush-tech/design-system?flags%5B0%5D=vue)
3
+ [![license](https://img.shields.io/npm/l/@gild-ui/vue.svg?cacheSeconds=86400)](./LICENSE)
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ ## Gild UI for **Vue**
6
+
7
+ The components of [`@gild-ui/react`](../react) with the same names, props, slots and themes, as Vue 3
8
+ components. The markup and the classes are the web package's for the same props.
9
+
10
+ ```sh
11
+ npm install @gild-ui/vue @gild-ui/core
12
+ ```
13
+
14
+ It needs `vue` `^3.5.0`.
15
+
16
+ ```ts
17
+ // src/theme/themes.ts - the same file as for @gild-ui/react
18
+ import { baseTheme, createTheme, defineThemes } from '@gild-ui/core/theme'
19
+
20
+ export const themes = defineThemes({
21
+ light: createTheme(baseTheme, { name: 'light', colorScheme: 'light' }),
22
+ dark: createTheme(baseTheme, { name: 'dark', colorScheme: 'dark' }),
23
+ })
24
+ ```
25
+
26
+ ```ts
27
+ // src/theme/setup.ts - called first, before anything renders
28
+ import { configure } from '@gild-ui/vue/engine'
29
+ import { themes } from './themes'
30
+
31
+ export function setup(): void {
32
+ configure({ serverTheme: themes.light })
33
+ }
34
+ ```
35
+
36
+ ```vue
37
+ <!-- src/App.vue -->
38
+ <script setup lang="ts">
39
+ import { ref } from 'vue'
40
+ import { ThemeProvider } from '@gild-ui/vue/ThemeProvider'
41
+ import { Button } from '@gild-ui/vue/Button'
42
+ import { Flex } from '@gild-ui/vue/Flex'
43
+ import { TextInput } from '@gild-ui/vue/TextInput'
44
+ import { Typography } from '@gild-ui/vue/Typography'
45
+ import { themes } from './theme/themes'
46
+
47
+ const name = ref('')
48
+ </script>
49
+
50
+ <template>
51
+ <ThemeProvider :theme="themes.light">
52
+ <Flex :p="3" :gap="2">
53
+ <Typography variant="h1">Hello {{ name }}</Typography>
54
+ <TextInput v-model="name" placeholder="Name" />
55
+ <Button @click="console.log('clicked')">Go</Button>
56
+ </Flex>
57
+ </ThemeProvider>
58
+ </template>
59
+ ```
60
+
61
+ ## What is in the first round
62
+
63
+ `ThemeProvider`, `useTheme`, `useDefaultProps`, `styled` and `configure` (`@gild-ui/vue/engine`), `View`,
64
+ `Flex`, `Typography`, `Button`, `TextInput` and `Modal`. Every other component of `@gild-ui/react` comes
65
+ later. Each component's README says how its props map to Vue; [`vue.md`](./vue.md) has the rules.
66
+
67
+ ## How it maps the web's props
68
+
69
+ - **`children` and the props that are nodes** are slots: the default slot, `#startIcon`, `#endIcon`,
70
+ `#loadingIndicator`.
71
+ - **`onClick` and the other handlers** are listeners (`@click`). `TextInput` has `v-model` (and `change`, on
72
+ every edit); `Modal` has `v-model:isOpen` and `close`, `(event, reason)`.
73
+ - **`className`** is `class`. `slotProps.<slot>.className` is unchanged.
74
+ - **The style props** (`m`, `p`, `bg`, `flexDirection`, ...) are attributes in camelCase. Components' own props
75
+ also take kebab-case (`full-width`) and a bare boolean (`<Button loading>`).
76
+ - **`style`** takes entries of `StyleSheet.create`, as on the web; there is no inline style.
77
+ - **`useTheme()`** is a computed ref: `const theme = useTheme()`, then `theme.value`.
78
+
79
+ ## Server rendering
80
+
81
+ ```ts
82
+ import { createSSRApp } from 'vue'
83
+ import { renderToString } from 'vue/server-renderer'
84
+ import { extractPageStyles, styleCache } from '@gild-ui/vue/engine'
85
+
86
+ const html = await renderToString(createSSRApp(App))
87
+ const style = extractPageStyles(styleCache, html).tag // a <style> for the head
88
+ ```
89
+
90
+ ## Run the example
91
+
92
+ `apps/vue-example` is a Vite app with one page that uses all six components and the switch between two
93
+ themes. From the repository root:
94
+
95
+ ```sh
96
+ pnpm --filter @gild-ui/vue build
97
+ pnpm --filter @soroush.design/vue-example dev
98
+ ```
@@ -0,0 +1,238 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_styled = require("./styled-JHkZtq_1.cjs");
3
+ const require_props = require("./props-DxoB9cT4.cjs");
4
+ const require_useDefaultProps = require("./useDefaultProps-qCDgeYFm.cjs");
5
+ let vue = require("vue");
6
+ let _umber_style_vue = require("@umber-style/vue");
7
+ let _gild_ui_core_theme = require("@gild-ui/core/theme");
8
+ let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
9
+ let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
10
+ let _gild_ui_core_utils = require("@gild-ui/core/utils");
11
+ // src/Button/Spinner.ts
12
+ const VIEWBOX = 44;
13
+ const THICKNESS = 3.6;
14
+ const RADIUS = (VIEWBOX - THICKNESS * 2) / 2;
15
+ const rotate = (0, _umber_style_vue.keyframes)({
16
+ "0%": { transform: "rotate(0deg)" },
17
+ "100%": { transform: "rotate(360deg)" }
18
+ });
19
+ const dash = (0, _umber_style_vue.keyframes)({
20
+ "0%": {
21
+ strokeDasharray: "1px, 200px",
22
+ strokeDashoffset: "0px"
23
+ },
24
+ "50%": {
25
+ strokeDasharray: "100px, 200px",
26
+ strokeDashoffset: "-15px"
27
+ },
28
+ "100%": {
29
+ strokeDasharray: "100px, 200px",
30
+ strokeDashoffset: "-125px"
31
+ }
32
+ });
33
+ const SpinnerRoot = require_styled.styled("span", {
34
+ name: "CircularProgress",
35
+ label: "CircularProgress"
36
+ })({
37
+ display: "inline-flex",
38
+ width: 16,
39
+ height: 16,
40
+ flexShrink: 0,
41
+ verticalAlign: "middle",
42
+ animation: `${rotate} 1.4s linear infinite`
43
+ });
44
+ const SpinnerCircle = require_styled.styled("circle", {
45
+ name: "CircularProgress",
46
+ slot: "circle",
47
+ label: "CircularProgressCircle"
48
+ })({
49
+ fill: "none",
50
+ stroke: "currentColor",
51
+ strokeDasharray: "80px, 200px",
52
+ strokeDashoffset: "0px",
53
+ animation: `${dash} 1.4s ease-in-out infinite`
54
+ });
55
+ const Spinner = (0, vue.defineComponent)(() => () => (0, vue.h)(SpinnerRoot, {
56
+ role: "progressbar",
57
+ "aria-label": "Loading"
58
+ }, () => (0, vue.h)("svg", {
59
+ viewBox: `0 0 ${VIEWBOX} ${VIEWBOX}`,
60
+ width: "100%",
61
+ height: "100%",
62
+ "aria-hidden": "true"
63
+ }, [(0, vue.h)(SpinnerCircle, {
64
+ cx: VIEWBOX / 2,
65
+ cy: VIEWBOX / 2,
66
+ r: RADIUS,
67
+ "stroke-width": THICKNESS
68
+ })])));
69
+ // src/Button/Button.ts
70
+ const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
71
+ ..._soroush_tech_styled_system_should_forward_prop.props,
72
+ "variant",
73
+ "size",
74
+ "shape",
75
+ "fullWidth",
76
+ "loading",
77
+ "loadingPosition"
78
+ ]);
79
+ const ButtonLabel = require_styled.styled("span", {
80
+ name: "Button",
81
+ slot: "label",
82
+ label: "ButtonLabel",
83
+ shouldForwardProp: (prop) => prop !== "invisible"
84
+ })(({ invisible }) => ({
85
+ display: "inherit",
86
+ alignItems: "inherit",
87
+ justifyContent: "inherit",
88
+ ...invisible && { opacity: 0 }
89
+ }));
90
+ const LoadingCenter = require_styled.styled("span", {
91
+ name: "Button",
92
+ slot: "loader",
93
+ label: "ButtonLoader"
94
+ })({
95
+ position: "absolute",
96
+ left: "50%",
97
+ top: "50%",
98
+ transform: "translate(-50%, -50%)",
99
+ display: "flex",
100
+ alignItems: "center"
101
+ });
102
+ const ButtonIcon = require_styled.styled("span", {
103
+ name: "Button",
104
+ slot: "icon",
105
+ label: "ButtonIcon"
106
+ })({
107
+ display: "inline-flex",
108
+ alignItems: "center",
109
+ fontSize: "inherit",
110
+ lineHeight: "inherit",
111
+ flexShrink: 0
112
+ });
113
+ const baseStyles = {
114
+ appearance: "none",
115
+ outline: "none",
116
+ cursor: "pointer",
117
+ position: "relative",
118
+ display: "inline-flex",
119
+ alignItems: "center",
120
+ justifyContent: "center",
121
+ fontFamily: "inherit",
122
+ textTransform: "uppercase",
123
+ textDecoration: "none",
124
+ lineHeight: 1,
125
+ transition: "background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease",
126
+ "&:disabled": {
127
+ cursor: "not-allowed",
128
+ opacity: .5
129
+ }
130
+ };
131
+ const sizeVariants = ({ theme, size }) => {
132
+ const s = theme.sizes[size];
133
+ return {
134
+ paddingTop: theme.space[s.paddingTop],
135
+ paddingBottom: theme.space[s.paddingBottom],
136
+ paddingLeft: theme.space[s.paddingLeft],
137
+ paddingRight: theme.space[s.paddingRight],
138
+ fontSize: theme.fontSizes[s.fontSize]
139
+ };
140
+ };
141
+ const variantStyles = ({ variant = "contained", theme, color = (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary") }) => {
142
+ const { main, dark, contrastText } = theme.palette[color];
143
+ if (variant === "contained") return {
144
+ backgroundColor: main,
145
+ color: contrastText,
146
+ border: `${theme.borderWidths.thin} solid transparent`,
147
+ "&:hover:not(:disabled)": { backgroundColor: dark },
148
+ "&:active:not(:disabled)": { backgroundColor: dark }
149
+ };
150
+ const hoverBg = (0, _umber_style_vue.alpha)(main, .08);
151
+ const activeBg = (0, _umber_style_vue.alpha)(main, .125);
152
+ const borderColor = variant === "outlined" ? main : "transparent";
153
+ return {
154
+ backgroundColor: "transparent",
155
+ color: main,
156
+ border: `${theme.borderWidths.thin} solid ${borderColor}`,
157
+ "&:hover:not(:disabled)": { backgroundColor: hoverBg },
158
+ "&:active:not(:disabled)": { backgroundColor: activeBg }
159
+ };
160
+ };
161
+ const shapeVariants = ({ shape = "square", theme }) => {
162
+ if (shape === "pill") return { borderRadius: "9999px" };
163
+ if (shape === "rounded") return { borderRadius: theme.radii[(0, _gild_ui_core_theme.themeDefault)(theme, "borderRadius", "md")] };
164
+ return { borderRadius: 0 };
165
+ };
166
+ const fullWidthStyles = ({ fullWidth }) => fullWidth ? { width: "100%" } : {};
167
+ const focusVisibleStyles = ({ theme }) => ({ "&:focus-visible": {
168
+ outline: `2px solid ${theme.palette[(0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary")].main}`,
169
+ outlineOffset: "2px"
170
+ } });
171
+ const safeLayout = (props) => (0, _soroush_tech_styled_system.layout)({
172
+ ...props,
173
+ size: void 0
174
+ });
175
+ const ButtonRoot = require_styled.styled("button", {
176
+ name: "Button",
177
+ label: "Button",
178
+ shouldForwardProp,
179
+ systemProps: [
180
+ _soroush_tech_styled_system.space,
181
+ safeLayout,
182
+ _soroush_tech_styled_system.typography,
183
+ _soroush_tech_styled_system.border
184
+ ]
185
+ })(baseStyles, sizeVariants, variantStyles, shapeVariants, fullWidthStyles, focusVisibleStyles);
186
+ const Button = (0, vue.defineComponent)((props, { attrs, slots }) => {
187
+ const theme = (0, _umber_style_vue.useTheme)();
188
+ const defaults = require_useDefaultProps.useDefaultProps("Button");
189
+ return () => {
190
+ const { slotProps, style, href, target, rel, variant, color, size, shape, gap, fontWeight, letterSpacing, fullWidth, disabled, loading = false, loadingPosition = "center" } = props;
191
+ const dp = defaults.value;
192
+ const { value } = theme;
193
+ const indicator = slots.loadingIndicator?.() ?? (0, vue.h)(Spinner);
194
+ const isCenter = loading && loadingPosition === "center";
195
+ const start = loading && loadingPosition === "start" ? () => indicator : slots.startIcon;
196
+ const end = loading && loadingPosition === "end" ? () => indicator : slots.endIcon;
197
+ const icon = (content) => content && (0, vue.h)(ButtonIcon, require_props.mergeOverrides(slotProps?.icon), content);
198
+ return (0, vue.h)(ButtonRoot, {
199
+ as: href == null ? void 0 : "a",
200
+ href,
201
+ target,
202
+ rel: (0, _gild_ui_core_utils.getAnchorRel)(target, rel),
203
+ variant: variant ?? dp.variant ?? (0, _gild_ui_core_theme.themeDefault)(value, "buttonVariant", "contained"),
204
+ color: color ?? dp.color ?? (0, _gild_ui_core_theme.themeDefault)(value, "color", "primary"),
205
+ size: size ?? dp.size ?? (0, _gild_ui_core_theme.themeDefault)(value, "size", "md"),
206
+ shape: shape ?? dp.shape ?? "square",
207
+ gap: gap ?? 1,
208
+ fontWeight: fontWeight ?? "bold",
209
+ letterSpacing: letterSpacing ?? "tight",
210
+ fullWidth: fullWidth ?? false,
211
+ disabled: (disabled ?? false) || loading,
212
+ "aria-busy": loading || void 0,
213
+ ...require_props.rootProps({
214
+ slotProps,
215
+ style
216
+ }, attrs)
217
+ }, () => [
218
+ icon(start),
219
+ (0, vue.h)(ButtonLabel, {
220
+ invisible: isCenter,
221
+ ...require_props.mergeOverrides(slotProps?.label)
222
+ }, () => slots.default?.()),
223
+ isCenter && (0, vue.h)(LoadingCenter, require_props.mergeOverrides(slotProps?.loader), () => indicator),
224
+ icon(end)
225
+ ].filter(Boolean));
226
+ };
227
+ }, {
228
+ name: "Button",
229
+ inheritAttrs: false,
230
+ props: {
231
+ ...require_props.declare("variant", "color", "size", "shape", "gap", "fontWeight", "letterSpacing", "loadingPosition", "href", "target", "rel", "slotProps", "style"),
232
+ fullWidth: require_props.flag,
233
+ disabled: require_props.flag,
234
+ loading: require_props.flag
235
+ },
236
+ slots: {}
237
+ });
238
+ exports.Button = Button;
@@ -0,0 +1,17 @@
1
+ import { n as SharedProps, r as Slot, t as Listeners } from "./props-Bzm7Wbdv.cjs";
2
+ import { G as ButtonOwnerState, J as ButtonSize, K as ButtonProps$1, Q as GapToken, U as ButtonColor, W as ButtonLoadingPosition, X as ButtonThemeConfig, Y as ButtonSlot, Z as ButtonVariant, q as ButtonShape } from "./themes-CgFrk0_b.cjs";
3
+ import { ButtonHTMLAttributes, SlotsType } from "vue";
4
+ /**
5
+ * The props of `Button`: the shared props of `@gild-ui/react` without the icons and the loading
6
+ * indicator, which are slots, and a listener for each DOM event of the element.
7
+ */
8
+ export type ButtonProps = SharedProps<ButtonProps$1, 'startIcon' | 'endIcon' | 'loadingIndicator'> & Listeners<ButtonHTMLAttributes>;
9
+ /** The slots of the `Button` component: the label, the icons and the loading indicator. */
10
+ export interface ButtonSlots {
11
+ default?: Slot;
12
+ startIcon?: Slot;
13
+ endIcon?: Slot;
14
+ loadingIndicator?: Slot;
15
+ }
16
+ export declare const Button: import("vue").DefineSetupFnComponent<ButtonProps, Record<never, never>, SlotsType<ButtonSlots>, SharedProps<ButtonProps$1, "endIcon" | "loadingIndicator" | "startIcon"> & Pick<ButtonHTMLAttributes, "onAbort" | "onAnimationcancel" | "onAnimationend" | "onAnimationiteration" | "onAnimationstart" | "onAuxclick" | "onBeforeinput" | "onBeforetoggle" | "onBlur" | "onCanplay" | "onCanplaythrough" | "onChange" | "onClick" | "onCompositionend" | "onCompositionstart" | "onCompositionupdate" | "onContextmenu" | "onCopy" | "onCut" | "onDblclick" | "onDrag" | "onDragend" | "onDragenter" | "onDragexit" | "onDragleave" | "onDragover" | "onDragstart" | "onDrop" | "onDurationchange" | "onEmptied" | "onEncrypted" | "onEnded" | "onError" | "onFocus" | "onFocusin" | "onFocusout" | "onFormdata" | "onFullscreenchange" | "onFullscreenerror" | "onGotpointercapture" | "onInput" | "onInvalid" | "onKeydown" | "onKeypress" | "onKeyup" | "onLoad" | "onLoadeddata" | "onLoadedmetadata" | "onLoadstart" | "onLostpointercapture" | "onMousedown" | "onMouseenter" | "onMouseleave" | "onMousemove" | "onMouseout" | "onMouseover" | "onMouseup" | "onPaste" | "onPause" | "onPlay" | "onPlaying" | "onPointercancel" | "onPointerdown" | "onPointerenter" | "onPointerleave" | "onPointermove" | "onPointerout" | "onPointerover" | "onPointerup" | "onProgress" | "onRatechange" | "onReset" | "onScroll" | "onScrollend" | "onSecuritypolicyviolation" | "onSeeked" | "onSeeking" | "onSelect" | "onStalled" | "onSubmit" | "onSuspend" | "onTimeupdate" | "onToggle" | "onTouchcancel" | "onTouchend" | "onTouchmove" | "onTouchstart" | "onTransitioncancel" | "onTransitionend" | "onTransitionrun" | "onTransitionstart" | "onVolumechange" | "onWaiting" | "onWheel"> & Pick<import("vue").HTMLAttributes, "class"> & {}, import("vue").PublicProps>;
17
+ export type { ButtonColor, ButtonLoadingPosition, ButtonOwnerState, ButtonShape, ButtonSize, ButtonSlot, ButtonThemeConfig, ButtonVariant, GapToken };
@@ -0,0 +1,17 @@
1
+ import { n as SharedProps, r as Slot, t as Listeners } from "./props-BRLGZVjJ.mjs";
2
+ import { a as ButtonShape, c as ButtonThemeConfig, i as ButtonProps$1, l as ButtonVariant, n as ButtonLoadingPosition, o as ButtonSize, r as ButtonOwnerState, s as ButtonSlot, t as ButtonColor, u as GapToken } from "./Button.types-BnJ28ym9.mjs";
3
+ import { ButtonHTMLAttributes, SlotsType } from "vue";
4
+ /**
5
+ * The props of `Button`: the shared props of `@gild-ui/react` without the icons and the loading
6
+ * indicator, which are slots, and a listener for each DOM event of the element.
7
+ */
8
+ export type ButtonProps = SharedProps<ButtonProps$1, 'startIcon' | 'endIcon' | 'loadingIndicator'> & Listeners<ButtonHTMLAttributes>;
9
+ /** The slots of the `Button` component: the label, the icons and the loading indicator. */
10
+ export interface ButtonSlots {
11
+ default?: Slot;
12
+ startIcon?: Slot;
13
+ endIcon?: Slot;
14
+ loadingIndicator?: Slot;
15
+ }
16
+ export declare const Button: import("vue").DefineSetupFnComponent<ButtonProps, Record<never, never>, SlotsType<ButtonSlots>, SharedProps<ButtonProps$1, "endIcon" | "loadingIndicator" | "startIcon"> & Pick<ButtonHTMLAttributes, "onAbort" | "onAnimationcancel" | "onAnimationend" | "onAnimationiteration" | "onAnimationstart" | "onAuxclick" | "onBeforeinput" | "onBeforetoggle" | "onBlur" | "onCanplay" | "onCanplaythrough" | "onChange" | "onClick" | "onCompositionend" | "onCompositionstart" | "onCompositionupdate" | "onContextmenu" | "onCopy" | "onCut" | "onDblclick" | "onDrag" | "onDragend" | "onDragenter" | "onDragexit" | "onDragleave" | "onDragover" | "onDragstart" | "onDrop" | "onDurationchange" | "onEmptied" | "onEncrypted" | "onEnded" | "onError" | "onFocus" | "onFocusin" | "onFocusout" | "onFormdata" | "onFullscreenchange" | "onFullscreenerror" | "onGotpointercapture" | "onInput" | "onInvalid" | "onKeydown" | "onKeypress" | "onKeyup" | "onLoad" | "onLoadeddata" | "onLoadedmetadata" | "onLoadstart" | "onLostpointercapture" | "onMousedown" | "onMouseenter" | "onMouseleave" | "onMousemove" | "onMouseout" | "onMouseover" | "onMouseup" | "onPaste" | "onPause" | "onPlay" | "onPlaying" | "onPointercancel" | "onPointerdown" | "onPointerenter" | "onPointerleave" | "onPointermove" | "onPointerout" | "onPointerover" | "onPointerup" | "onProgress" | "onRatechange" | "onReset" | "onScroll" | "onScrollend" | "onSecuritypolicyviolation" | "onSeeked" | "onSeeking" | "onSelect" | "onStalled" | "onSubmit" | "onSuspend" | "onTimeupdate" | "onToggle" | "onTouchcancel" | "onTouchend" | "onTouchmove" | "onTouchstart" | "onTransitioncancel" | "onTransitionend" | "onTransitionrun" | "onTransitionstart" | "onVolumechange" | "onWaiting" | "onWheel"> & Pick<import("vue").HTMLAttributes, "class"> & {}, import("vue").PublicProps>;
17
+ export type { ButtonColor, ButtonLoadingPosition, ButtonOwnerState, ButtonShape, ButtonSize, ButtonSlot, ButtonThemeConfig, ButtonVariant, GapToken };
@@ -0,0 +1,237 @@
1
+ import { n as keyframes, r as styled$1, t as alpha } from "./styled-Cmxvlft5.mjs";
2
+ import { i as mergeOverrides, n as flag, r as rootProps, t as declare } from "./props-DDBSpAkG.mjs";
3
+ import { t as useDefaultProps } from "./useDefaultProps--fOGOSGa.mjs";
4
+ import { defineComponent, h } from "vue";
5
+ import { useTheme } from "@umber-style/vue";
6
+ import { themeDefault } from "@gild-ui/core/theme";
7
+ import { createShouldForwardProp, props } from "@soroush.tech/styled-system/should-forward-prop";
8
+ import { border, layout, space, typography } from "@soroush.tech/styled-system";
9
+ import { getAnchorRel } from "@gild-ui/core/utils";
10
+ // src/Button/Spinner.ts
11
+ const VIEWBOX = 44;
12
+ const THICKNESS = 3.6;
13
+ const RADIUS = (VIEWBOX - THICKNESS * 2) / 2;
14
+ const rotate = keyframes({
15
+ "0%": { transform: "rotate(0deg)" },
16
+ "100%": { transform: "rotate(360deg)" }
17
+ });
18
+ const dash = keyframes({
19
+ "0%": {
20
+ strokeDasharray: "1px, 200px",
21
+ strokeDashoffset: "0px"
22
+ },
23
+ "50%": {
24
+ strokeDasharray: "100px, 200px",
25
+ strokeDashoffset: "-15px"
26
+ },
27
+ "100%": {
28
+ strokeDasharray: "100px, 200px",
29
+ strokeDashoffset: "-125px"
30
+ }
31
+ });
32
+ const SpinnerRoot = styled$1("span", {
33
+ name: "CircularProgress",
34
+ label: "CircularProgress"
35
+ })({
36
+ display: "inline-flex",
37
+ width: 16,
38
+ height: 16,
39
+ flexShrink: 0,
40
+ verticalAlign: "middle",
41
+ animation: `${rotate} 1.4s linear infinite`
42
+ });
43
+ const SpinnerCircle = styled$1("circle", {
44
+ name: "CircularProgress",
45
+ slot: "circle",
46
+ label: "CircularProgressCircle"
47
+ })({
48
+ fill: "none",
49
+ stroke: "currentColor",
50
+ strokeDasharray: "80px, 200px",
51
+ strokeDashoffset: "0px",
52
+ animation: `${dash} 1.4s ease-in-out infinite`
53
+ });
54
+ const Spinner = defineComponent(() => () => h(SpinnerRoot, {
55
+ role: "progressbar",
56
+ "aria-label": "Loading"
57
+ }, () => h("svg", {
58
+ viewBox: `0 0 ${VIEWBOX} ${VIEWBOX}`,
59
+ width: "100%",
60
+ height: "100%",
61
+ "aria-hidden": "true"
62
+ }, [h(SpinnerCircle, {
63
+ cx: VIEWBOX / 2,
64
+ cy: VIEWBOX / 2,
65
+ r: RADIUS,
66
+ "stroke-width": THICKNESS
67
+ })])));
68
+ // src/Button/Button.ts
69
+ const shouldForwardProp = createShouldForwardProp([
70
+ ...props,
71
+ "variant",
72
+ "size",
73
+ "shape",
74
+ "fullWidth",
75
+ "loading",
76
+ "loadingPosition"
77
+ ]);
78
+ const ButtonLabel = styled$1("span", {
79
+ name: "Button",
80
+ slot: "label",
81
+ label: "ButtonLabel",
82
+ shouldForwardProp: (prop) => prop !== "invisible"
83
+ })(({ invisible }) => ({
84
+ display: "inherit",
85
+ alignItems: "inherit",
86
+ justifyContent: "inherit",
87
+ ...invisible && { opacity: 0 }
88
+ }));
89
+ const LoadingCenter = styled$1("span", {
90
+ name: "Button",
91
+ slot: "loader",
92
+ label: "ButtonLoader"
93
+ })({
94
+ position: "absolute",
95
+ left: "50%",
96
+ top: "50%",
97
+ transform: "translate(-50%, -50%)",
98
+ display: "flex",
99
+ alignItems: "center"
100
+ });
101
+ const ButtonIcon = styled$1("span", {
102
+ name: "Button",
103
+ slot: "icon",
104
+ label: "ButtonIcon"
105
+ })({
106
+ display: "inline-flex",
107
+ alignItems: "center",
108
+ fontSize: "inherit",
109
+ lineHeight: "inherit",
110
+ flexShrink: 0
111
+ });
112
+ const baseStyles = {
113
+ appearance: "none",
114
+ outline: "none",
115
+ cursor: "pointer",
116
+ position: "relative",
117
+ display: "inline-flex",
118
+ alignItems: "center",
119
+ justifyContent: "center",
120
+ fontFamily: "inherit",
121
+ textTransform: "uppercase",
122
+ textDecoration: "none",
123
+ lineHeight: 1,
124
+ transition: "background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease",
125
+ "&:disabled": {
126
+ cursor: "not-allowed",
127
+ opacity: .5
128
+ }
129
+ };
130
+ const sizeVariants = ({ theme, size }) => {
131
+ const s = theme.sizes[size];
132
+ return {
133
+ paddingTop: theme.space[s.paddingTop],
134
+ paddingBottom: theme.space[s.paddingBottom],
135
+ paddingLeft: theme.space[s.paddingLeft],
136
+ paddingRight: theme.space[s.paddingRight],
137
+ fontSize: theme.fontSizes[s.fontSize]
138
+ };
139
+ };
140
+ const variantStyles = ({ variant = "contained", theme, color = themeDefault(theme, "color", "primary") }) => {
141
+ const { main, dark, contrastText } = theme.palette[color];
142
+ if (variant === "contained") return {
143
+ backgroundColor: main,
144
+ color: contrastText,
145
+ border: `${theme.borderWidths.thin} solid transparent`,
146
+ "&:hover:not(:disabled)": { backgroundColor: dark },
147
+ "&:active:not(:disabled)": { backgroundColor: dark }
148
+ };
149
+ const hoverBg = alpha(main, .08);
150
+ const activeBg = alpha(main, .125);
151
+ const borderColor = variant === "outlined" ? main : "transparent";
152
+ return {
153
+ backgroundColor: "transparent",
154
+ color: main,
155
+ border: `${theme.borderWidths.thin} solid ${borderColor}`,
156
+ "&:hover:not(:disabled)": { backgroundColor: hoverBg },
157
+ "&:active:not(:disabled)": { backgroundColor: activeBg }
158
+ };
159
+ };
160
+ const shapeVariants = ({ shape = "square", theme }) => {
161
+ if (shape === "pill") return { borderRadius: "9999px" };
162
+ if (shape === "rounded") return { borderRadius: theme.radii[themeDefault(theme, "borderRadius", "md")] };
163
+ return { borderRadius: 0 };
164
+ };
165
+ const fullWidthStyles = ({ fullWidth }) => fullWidth ? { width: "100%" } : {};
166
+ const focusVisibleStyles = ({ theme }) => ({ "&:focus-visible": {
167
+ outline: `2px solid ${theme.palette[themeDefault(theme, "color", "primary")].main}`,
168
+ outlineOffset: "2px"
169
+ } });
170
+ const safeLayout = (props) => layout({
171
+ ...props,
172
+ size: void 0
173
+ });
174
+ const ButtonRoot = styled$1("button", {
175
+ name: "Button",
176
+ label: "Button",
177
+ shouldForwardProp,
178
+ systemProps: [
179
+ space,
180
+ safeLayout,
181
+ typography,
182
+ border
183
+ ]
184
+ })(baseStyles, sizeVariants, variantStyles, shapeVariants, fullWidthStyles, focusVisibleStyles);
185
+ const Button = defineComponent((props, { attrs, slots }) => {
186
+ const theme = useTheme();
187
+ const defaults = useDefaultProps("Button");
188
+ return () => {
189
+ const { slotProps, style, href, target, rel, variant, color, size, shape, gap, fontWeight, letterSpacing, fullWidth, disabled, loading = false, loadingPosition = "center" } = props;
190
+ const dp = defaults.value;
191
+ const { value } = theme;
192
+ const indicator = slots.loadingIndicator?.() ?? h(Spinner);
193
+ const isCenter = loading && loadingPosition === "center";
194
+ const start = loading && loadingPosition === "start" ? () => indicator : slots.startIcon;
195
+ const end = loading && loadingPosition === "end" ? () => indicator : slots.endIcon;
196
+ const icon = (content) => content && h(ButtonIcon, mergeOverrides(slotProps?.icon), content);
197
+ return h(ButtonRoot, {
198
+ as: href == null ? void 0 : "a",
199
+ href,
200
+ target,
201
+ rel: getAnchorRel(target, rel),
202
+ variant: variant ?? dp.variant ?? themeDefault(value, "buttonVariant", "contained"),
203
+ color: color ?? dp.color ?? themeDefault(value, "color", "primary"),
204
+ size: size ?? dp.size ?? themeDefault(value, "size", "md"),
205
+ shape: shape ?? dp.shape ?? "square",
206
+ gap: gap ?? 1,
207
+ fontWeight: fontWeight ?? "bold",
208
+ letterSpacing: letterSpacing ?? "tight",
209
+ fullWidth: fullWidth ?? false,
210
+ disabled: (disabled ?? false) || loading,
211
+ "aria-busy": loading || void 0,
212
+ ...rootProps({
213
+ slotProps,
214
+ style
215
+ }, attrs)
216
+ }, () => [
217
+ icon(start),
218
+ h(ButtonLabel, {
219
+ invisible: isCenter,
220
+ ...mergeOverrides(slotProps?.label)
221
+ }, () => slots.default?.()),
222
+ isCenter && h(LoadingCenter, mergeOverrides(slotProps?.loader), () => indicator),
223
+ icon(end)
224
+ ].filter(Boolean));
225
+ };
226
+ }, {
227
+ name: "Button",
228
+ inheritAttrs: false,
229
+ props: {
230
+ ...declare("variant", "color", "size", "shape", "gap", "fontWeight", "letterSpacing", "loadingPosition", "href", "target", "rel", "slotProps", "style"),
231
+ fullWidth: flag,
232
+ disabled: flag,
233
+ loading: flag
234
+ },
235
+ slots: {}
236
+ });
237
+ export { Button };