zabi-components 7.0.0 → 7.0.2

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.
@@ -1,19 +1,17 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
+ import type { HTMLButtonAttributes } from "svelte/elements";
3
4
  import type { ButtonVariant, SizeVariant } from "../types/variants.js";
4
5
 
5
- interface Props {
6
+ type Props = Omit<HTMLButtonAttributes, "class"> & {
6
7
  variant?: ButtonVariant;
7
8
  size?: SizeVariant;
8
- disabled?: boolean;
9
9
  loading?: boolean;
10
- type?: "button" | "submit" | "reset";
11
10
  text?: string;
12
11
  isFullWidth?: boolean;
13
12
  class?: string;
14
- onclick?: (event: MouseEvent) => void;
15
13
  children?: Snippet;
16
- }
14
+ };
17
15
 
18
16
  let {
19
17
  variant = "primary",
@@ -1,17 +1,15 @@
1
1
  import type { Snippet } from "svelte";
2
+ import type { HTMLButtonAttributes } from "svelte/elements";
2
3
  import type { ButtonVariant, SizeVariant } from "../types/variants.js";
3
- interface Props {
4
+ type Props = Omit<HTMLButtonAttributes, "class"> & {
4
5
  variant?: ButtonVariant;
5
6
  size?: SizeVariant;
6
- disabled?: boolean;
7
7
  loading?: boolean;
8
- type?: "button" | "submit" | "reset";
9
8
  text?: string;
10
9
  isFullWidth?: boolean;
11
10
  class?: string;
12
- onclick?: (event: MouseEvent) => void;
13
11
  children?: Snippet;
14
- }
12
+ };
15
13
  declare const Button: import("svelte").Component<Props, {}, "">;
16
14
  type Button = ReturnType<typeof Button>;
17
15
  export default Button;
@@ -1,19 +1,17 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
+ import type { HTMLButtonAttributes } from "svelte/elements";
3
4
  import type { ButtonVariant, SizeVariant } from "../types/variants.js";
4
5
 
5
- interface Props {
6
+ type Props = Omit<HTMLButtonAttributes, "class"> & {
6
7
  variant?: ButtonVariant;
7
8
  size?: SizeVariant;
8
- disabled?: boolean;
9
9
  loading?: boolean;
10
- type?: "button" | "submit" | "reset";
11
10
  /** Required for icon-only usage (no visible text). */
12
11
  label?: string;
13
12
  class?: string;
14
- onclick?: (event: MouseEvent) => void;
15
13
  children?: Snippet;
16
- }
14
+ };
17
15
 
18
16
  let {
19
17
  variant = "primary",
@@ -1,17 +1,15 @@
1
1
  import type { Snippet } from "svelte";
2
+ import type { HTMLButtonAttributes } from "svelte/elements";
2
3
  import type { ButtonVariant, SizeVariant } from "../types/variants.js";
3
- interface Props {
4
+ type Props = Omit<HTMLButtonAttributes, "class"> & {
4
5
  variant?: ButtonVariant;
5
6
  size?: SizeVariant;
6
- disabled?: boolean;
7
7
  loading?: boolean;
8
- type?: "button" | "submit" | "reset";
9
8
  /** Required for icon-only usage (no visible text). */
10
9
  label?: string;
11
10
  class?: string;
12
- onclick?: (event: MouseEvent) => void;
13
11
  children?: Snippet;
14
- }
12
+ };
15
13
  declare const IconButton: import("svelte").Component<Props, {}, "">;
16
14
  type IconButton = ReturnType<typeof IconButton>;
17
15
  export default IconButton;
@@ -1,13 +1,17 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLAttributes } from "svelte/elements";
2
4
  import { onDestroy } from "svelte";
3
5
  import { generateId } from "../util/ssr-safe.js";
4
6
 
5
- interface Props {
7
+ type Props = Omit<HTMLAttributes<HTMLDivElement>, "class"> & {
6
8
  content?: string;
7
9
  placement?: "top" | "bottom" | "left" | "right";
8
10
  delay?: number;
9
11
  disabled?: boolean;
10
- }
12
+ class?: string;
13
+ children?: Snippet;
14
+ };
11
15
 
12
16
  /** First matching focusable inside the slot receives `aria-describedby` (wrapper div is skipped). */
13
17
  const FOCUSABLE_SELECTOR =
@@ -20,7 +24,7 @@
20
24
  disabled = false,
21
25
  children,
22
26
  ...restProps
23
- }: Props & { children?: any } = $props();
27
+ }: Props = $props();
24
28
 
25
29
  const triggerId = generateId("tooltip-trigger");
26
30
  const tooltipId = generateId("tooltip");
@@ -60,8 +64,7 @@
60
64
 
61
65
  $effect(() => {
62
66
  const root = triggerElement;
63
- const describe =
64
- isVisible && content && !disabled ? tooltipId : null;
67
+ const describe = isVisible && content && !disabled ? tooltipId : null;
65
68
  if (!root) {
66
69
  return;
67
70
  }
@@ -158,7 +161,7 @@
158
161
  {#if content && !disabled}
159
162
  <div
160
163
  id={tooltipId}
161
- class="tooltip"
164
+ class="tooltip pointer-events-none invisible absolute z-tooltip whitespace-normal wrap-break-word rounded-lg bg-tooltip-bg px-3 py-2 text-sm leading-5 text-tooltip-fg opacity-0 transition-[opacity,visibility,transform] duration-200 ease-in-out"
162
165
  role="tooltip"
163
166
  aria-hidden={!isVisible}
164
167
  data-visible={isVisible}
@@ -171,40 +174,17 @@
171
174
 
172
175
  <style>
173
176
  :root {
174
- --tooltip-bg: var(--color-base-800);
175
- --tooltip-color: var(--color-base-50);
176
- --tooltip-padding: 0.5rem 0.75rem;
177
- --tooltip-radius: 0.5rem;
178
- --tooltip-font-size: 0.875rem;
179
- --tooltip-line-height: 1.25rem;
180
- --tooltip-max-width: 200px;
177
+ /* Cap only very long copy; width:max-content keeps typical sentences on one line until this limit */
178
+ --tooltip-max-width: min(24rem, calc(100vw - 2rem));
181
179
  --tooltip-gap: 0.5rem;
182
180
  --tooltip-arrow-size: 4px;
183
- --tooltip-transition: opacity 0.2s ease-in-out,
184
- visibility 0.2s ease-in-out, transform 0.2s ease-in-out;
185
- }
186
-
187
- .tooltip-container {
188
- position: relative;
189
- display: inline-block;
190
181
  }
191
182
 
183
+ /* max-width: policy forbids max-w-* utilities on packaged atoms; variable used by sm: override */
192
184
  .tooltip {
193
- position: absolute;
194
- z-index: var(--z-tooltip, 1070);
195
- padding: var(--tooltip-padding);
196
- background-color: var(--tooltip-bg);
197
- color: var(--tooltip-color);
198
- border-radius: var(--tooltip-radius);
199
- font-size: var(--tooltip-font-size);
200
- line-height: var(--tooltip-line-height);
201
- max-width: var(--tooltip-max-width);
202
- white-space: normal;
203
- word-wrap: break-word;
204
- opacity: 0;
205
- visibility: hidden;
206
- transition: var(--tooltip-transition);
207
- pointer-events: none;
185
+ width: -moz-max-content;
186
+ width: max-content;
187
+ max-width: var(--tooltip-max-width, min(24rem, calc(100vw - 2rem)));
208
188
  }
209
189
 
210
190
  .tooltip-container[data-placement="top"] .tooltip {
@@ -264,7 +244,7 @@
264
244
  position: absolute;
265
245
  width: calc(var(--tooltip-arrow-size) * 2);
266
246
  height: calc(var(--tooltip-arrow-size) * 2);
267
- background-color: var(--tooltip-bg);
247
+ background-color: var(--color-tooltip-bg);
268
248
  }
269
249
 
270
250
  .tooltip-container[data-placement="top"] .tooltip::before {
@@ -318,10 +298,8 @@
318
298
  }
319
299
 
320
300
  @media (prefers-contrast: high) {
321
- :root {
322
- --tooltip-bg: CanvasText;
323
- --tooltip-color: Canvas;
324
- --tooltip-padding: 0.75rem 1rem;
301
+ .tooltip {
302
+ padding: 0.75rem 1rem;
325
303
  }
326
304
  }
327
305
 
@@ -350,6 +328,6 @@
350
328
  box-shadow:
351
329
  0 0 0 2px var(--color-focus-ring-offset),
352
330
  0 0 0 4px var(--color-focus-ring);
353
- border-radius: var(--tooltip-radius);
331
+ border-radius: 0.5rem;
354
332
  }
355
333
  </style>
@@ -1,12 +1,13 @@
1
- interface Props {
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ type Props = Omit<HTMLAttributes<HTMLDivElement>, "class"> & {
2
4
  content?: string;
3
5
  placement?: "top" | "bottom" | "left" | "right";
4
6
  delay?: number;
5
7
  disabled?: boolean;
6
- }
7
- type $$ComponentProps = Props & {
8
- children?: any;
8
+ class?: string;
9
+ children?: Snippet;
9
10
  };
10
- declare const Tooltip: import("svelte").Component<$$ComponentProps, {}, "">;
11
+ declare const Tooltip: import("svelte").Component<Props, {}, "">;
11
12
  type Tooltip = ReturnType<typeof Tooltip>;
12
13
  export default Tooltip;