@casinogate/ui 1.5.1 → 1.5.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.
@@ -312,6 +312,9 @@
312
312
  .cgui\:h-\(--bits-select-anchor-height\) {
313
313
  height: var(--bits-select-anchor-height);
314
314
  }
315
+ .cgui\:h-\(--cg-ui-max-content-height\) {
316
+ height: var(--cg-ui-max-content-height);
317
+ }
315
318
  .cgui\:h-3 {
316
319
  height: calc(var(--cgui-spacing) * 3);
317
320
  }
@@ -357,6 +360,9 @@
357
360
  .cgui\:h-20 {
358
361
  height: calc(var(--cgui-spacing) * 20);
359
362
  }
363
+ .cgui\:h-30 {
364
+ height: calc(var(--cgui-spacing) * 30);
365
+ }
360
366
  .cgui\:h-34 {
361
367
  height: calc(var(--cgui-spacing) * 34);
362
368
  }
@@ -543,6 +549,9 @@
543
549
  .cgui\:justify-end {
544
550
  justify-content: flex-end;
545
551
  }
552
+ .cgui\:gap-0\.5 {
553
+ gap: calc(var(--cgui-spacing) * 0.5);
554
+ }
546
555
  .cgui\:gap-1 {
547
556
  gap: calc(var(--cgui-spacing) * 1);
548
557
  }
@@ -1044,6 +1053,9 @@
1044
1053
  .cgui\:scrollbar-thumb-rounded-md {
1045
1054
  --scrollbar-thumb-radius: calc(var(--cg-ui-number-md) * 1px);
1046
1055
  }
1056
+ .cgui\:scrollbar-thumb-stroke-default {
1057
+ --scrollbar-thumb: var(--cg-ui-palette-neutral-40);
1058
+ }
1047
1059
  .cgui\:scrollbar-thumb-surface-regular {
1048
1060
  --scrollbar-thumb: var(--cg-ui-palette-neutral-50);
1049
1061
  }
@@ -1062,6 +1074,9 @@
1062
1074
  .cgui\:scrollbar-track-surface-lightest {
1063
1075
  --scrollbar-track: var(--cg-ui-palette-neutral-10);
1064
1076
  }
1077
+ .cgui\:scrollbar-track-transparent {
1078
+ --scrollbar-track: transparent;
1079
+ }
1065
1080
  .cgui\:group-has-\[\[data-slot\=\"header\"\]\]\/appShell\:h-\[calc\(100\%-var\(--app-shell-header-height\)\)\] {
1066
1081
  &:is(:where(.cgui\:group\/appShell):has(*:is([data-slot="header"])) *) {
1067
1082
  height: calc(100% - var(--app-shell-header-height));
@@ -1336,21 +1351,6 @@
1336
1351
  opacity: 50%;
1337
1352
  }
1338
1353
  }
1339
- .cgui\:data-\[end-chevron\]\:right-2\.5 {
1340
- &[data-end-chevron] {
1341
- right: calc(var(--cgui-spacing) * 2.5);
1342
- }
1343
- }
1344
- .cgui\:data-\[end-chevron\]\:right-3 {
1345
- &[data-end-chevron] {
1346
- right: calc(var(--cgui-spacing) * 3);
1347
- }
1348
- }
1349
- .cgui\:data-\[end-chevron\]\:right-4 {
1350
- &[data-end-chevron] {
1351
- right: calc(var(--cgui-spacing) * 4);
1352
- }
1353
- }
1354
1354
  .cgui\:data-\[end-chevron\]\:pr-7 {
1355
1355
  &[data-end-chevron] {
1356
1356
  padding-right: calc(var(--cgui-spacing) * 7);
@@ -1475,21 +1475,6 @@
1475
1475
  left: calc(var(--cgui-spacing) * 2);
1476
1476
  }
1477
1477
  }
1478
- .cgui\:data-\[start-chevron\]\:left-2\.5 {
1479
- &[data-start-chevron] {
1480
- left: calc(var(--cgui-spacing) * 2.5);
1481
- }
1482
- }
1483
- .cgui\:data-\[start-chevron\]\:left-3 {
1484
- &[data-start-chevron] {
1485
- left: calc(var(--cgui-spacing) * 3);
1486
- }
1487
- }
1488
- .cgui\:data-\[start-chevron\]\:left-4 {
1489
- &[data-start-chevron] {
1490
- left: calc(var(--cgui-spacing) * 4);
1491
- }
1492
- }
1493
1478
  .cgui\:data-\[start-chevron\]\:pl-8 {
1494
1479
  &[data-start-chevron] {
1495
1480
  padding-left: calc(var(--cgui-spacing) * 8);
@@ -39,5 +39,13 @@
39
39
  {:else}
40
40
  <label {...mergedProps}>
41
41
  {@render children?.()}
42
+
43
+ {#if labelState.root.opts.required.current}
44
+ <span
45
+ class=" cgui:inline-flex cgui:items-center cgui:justify-center cgui:text-caption cgui:font-medium cgui:text-fg-error cgui:shrink-0 cgui:align-middle"
46
+ >
47
+ *
48
+ </span>
49
+ {/if}
42
50
  </label>
43
51
  {/if}
@@ -37,12 +37,19 @@
37
37
  FieldStylesContext.set(box.with(() => variants));
38
38
 
39
39
  const mergedProps = $derived(mergeProps(restProps, rootState.props, { class: cn(variants.root(), className) }));
40
+
41
+ const attrStates = $derived({
42
+ invalid: rootState.opts.invalid.current,
43
+ disabled: rootState.opts.disabled.current,
44
+ readOnly: rootState.opts.readOnly.current,
45
+ required: rootState.opts.required.current,
46
+ });
40
47
  </script>
41
48
 
42
49
  {#if child}
43
- {@render child({ props: mergedProps })}
50
+ {@render child({ props: mergedProps, ...attrStates })}
44
51
  {:else}
45
52
  <div {...mergedProps}>
46
- {@render children?.()}
53
+ {@render children?.(attrStates)}
47
54
  </div>
48
55
  {/if}
@@ -78,6 +78,8 @@ export declare class FieldControlState {
78
78
  readonly props: {
79
79
  readonly id: string;
80
80
  readonly 'aria-invalid': boolean;
81
+ readonly disabled: boolean;
82
+ readonly readOnly: boolean;
81
83
  };
82
84
  }
83
85
  export {};
@@ -122,5 +122,7 @@ export class FieldControlState {
122
122
  props = $derived.by(() => ({
123
123
  id: this.opts.id.current,
124
124
  'aria-invalid': this.root.opts.invalid.current,
125
+ disabled: this.root.opts.disabled.current,
126
+ readOnly: this.root.opts.readOnly.current,
125
127
  }));
126
128
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  const parameters: Parameters = {
9
9
  controls: {
10
- include: [],
10
+ include: ['invalid', 'disabled', 'required', 'readOnly'],
11
11
  },
12
12
  };
13
13
 
@@ -19,7 +19,12 @@
19
19
 
20
20
  type Args = ComponentProps<typeof FieldPrimitive.Root>;
21
21
 
22
- const args: Args = {};
22
+ const args: Args = {
23
+ invalid: false,
24
+ disabled: false,
25
+ required: false,
26
+ readOnly: false,
27
+ };
23
28
  </script>
24
29
 
25
30
  <Story name="Basic" {args} {parameters}>
@@ -34,7 +39,7 @@
34
39
 
35
40
  <Story name="Primitive" {args} {parameters}>
36
41
  {#snippet template(args: Args)}
37
- <FieldPrimitive.Root {...args} invalid>
42
+ <FieldPrimitive.Root {...args} invalid required>
38
43
  <FieldPrimitive.Label>Label</FieldPrimitive.Label>
39
44
 
40
45
  <FieldPrimitive.Control>
@@ -21,7 +21,7 @@ export declare const fieldStyles: import("tailwind-variants").TVReturnType<{
21
21
  };
22
22
  } | {}, {
23
23
  root: string;
24
- label: string;
24
+ label: string[];
25
25
  error: string;
26
26
  description: string;
27
27
  }, undefined, {
@@ -35,12 +35,12 @@ export declare const fieldStyles: import("tailwind-variants").TVReturnType<{
35
35
  };
36
36
  } | {}, {
37
37
  root: string;
38
- label: string;
38
+ label: string[];
39
39
  error: string;
40
40
  description: string;
41
41
  }, import("tailwind-variants").TVReturnType<unknown, {
42
42
  root: string;
43
- label: string;
43
+ label: string[];
44
44
  error: string;
45
45
  description: string;
46
46
  }, undefined, unknown, unknown, undefined>>;
@@ -4,7 +4,12 @@ import { Context } from 'runed';
4
4
  export const fieldStyles = tv({
5
5
  slots: {
6
6
  root: 'cgui:flex cgui:flex-col cgui:gap-1',
7
- label: 'cgui:text-fg-medium cgui:text-caption cgui:font-medium',
7
+ label: [
8
+ 'cgui:relative',
9
+ 'cgui:w-fit',
10
+ 'cgui:inline-flex cgui:items-center cgui:gap-0.5',
11
+ 'cgui:text-fg-medium cgui:text-caption cgui:font-medium',
12
+ ],
8
13
  error: 'cgui:text-caption cgui:text-fg-error',
9
14
  description: 'cgui:text-caption cgui:text-fg-medium',
10
15
  },
@@ -6,6 +6,11 @@ type FieldRootPropsWithoutHTML = WithElementRef<WithChild<{
6
6
  disabled?: boolean;
7
7
  readOnly?: boolean;
8
8
  required?: boolean;
9
+ }, {
10
+ invalid: boolean;
11
+ disabled: boolean;
12
+ readOnly: boolean;
13
+ required: boolean;
9
14
  }>>;
10
15
  export type FieldRootProps = FieldRootPropsWithoutHTML & Without<PrimitiveDivAttributes, FieldRootPropsWithoutHTML>;
11
16
  export type FieldControlProps = {
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import type { IconProps } from './types.js';
3
+
4
+ let { width = 24, height = 24, color = 'currentColor', ...props }: IconProps = $props();
5
+ </script>
6
+
7
+ <svg xmlns="http://www.w3.org/2000/svg" {width} {height} viewBox="0 0 24 24" {...props}>
8
+ <path
9
+ fill={color}
10
+ d="M21 13h-6.6l4.7 4.7l-1.4 1.4l-4.7-4.7V21h-2v-6.7L6.3 19l-1.4-1.4L9.4 13H3v-2h6.6L4.9 6.3l1.4-1.4L11 9.6V3h2v6.4l4.6-4.6L19 6.3L14.3 11H21z"
11
+ />
12
+ </svg>
@@ -0,0 +1,3 @@
1
+ declare const Asterisk: import("svelte").Component<import("../../internal/types/html-attributes.js").PrimitiveSVGAttributes, {}, "">;
2
+ type Asterisk = ReturnType<typeof Asterisk>;
3
+ export default Asterisk;
@@ -1,3 +1,4 @@
1
+ export { default as Asterisk } from './asterisk.svelte';
1
2
  export { default as CaretDown } from './caret-down.svelte';
2
3
  export { default as CaretUp } from './caret-up.svelte';
3
4
  export { default as Check } from './check.svelte';
@@ -1,3 +1,4 @@
1
+ export { default as Asterisk } from './asterisk.svelte';
1
2
  export { default as CaretDown } from './caret-down.svelte';
2
3
  export { default as CaretUp } from './caret-up.svelte';
3
4
  export { default as Check } from './check.svelte';
@@ -37,7 +37,7 @@
37
37
  'cgui:group-data-[state=open]/select-trigger:-rotate-180'
38
38
  )}
39
39
  >
40
- <Icon.ChevronDown width={20} height={20} />
40
+ <Icon.ChevronDown width={18} height={18} />
41
41
  </span>
42
42
  {/if}
43
43
  </SelectPrimitive.Trigger>
@@ -131,7 +131,7 @@
131
131
  <SelectPrimitive.Trigger>{selectedGroupedLabel}</SelectPrimitive.Trigger>
132
132
 
133
133
  <SelectPrimitive.Portal>
134
- <SelectPrimitive.Content>
134
+ <SelectPrimitive.Content class="cgui:h-30">
135
135
  <SelectPrimitive.Viewport>
136
136
  <SelectPrimitive.Group>
137
137
  {#each organizedGroups as group}
@@ -191,6 +191,7 @@
191
191
  <Select.Root
192
192
  {...args}
193
193
  type="multiple"
194
+ maxContentHeight="150px"
194
195
  data={[
195
196
  {
196
197
  group: 'Group 1',
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { SelectItem, SelectItemData, SelectItemGroup, SelectProps } from './types.js';
3
3
 
4
+ import type { Attachment } from 'svelte/attachments';
4
5
  import Content from './components/select.content.svelte';
5
6
  import GroupHeading from './components/select.group-heading.svelte';
6
7
  import Group from './components/select.group.svelte';
@@ -16,6 +17,8 @@
16
17
 
17
18
  empty = 'No results found',
18
19
 
20
+ maxContentHeight,
21
+
19
22
  data,
20
23
  item,
21
24
  trigger,
@@ -76,6 +79,22 @@
76
79
  const hasResults = $derived.by(() => {
77
80
  return data.length > 0;
78
81
  });
82
+
83
+ const contentStyle = $derived.by(() => {
84
+ return {
85
+ ...(maxContentHeight ? { '--cg-ui-max-content-height': maxContentHeight } : {}),
86
+ };
87
+ });
88
+
89
+ const contentMount: Attachment<HTMLDivElement> = (el) => {
90
+ $effect.pre(() => {
91
+ if (!el) return;
92
+
93
+ Object.entries(contentStyle).forEach(([key, value]) => {
94
+ el.style.setProperty(key, value);
95
+ });
96
+ });
97
+ };
79
98
  </script>
80
99
 
81
100
  {#snippet itemsString(item: string)}
@@ -116,7 +135,7 @@
116
135
  {/if}
117
136
 
118
137
  <Portal>
119
- <Content>
138
+ <Content {@attach contentMount} class="cgui:h-(--cg-ui-max-content-height)">
120
139
  <Viewport>
121
140
  {#if hasResults}
122
141
  {#each data as item (getItemKey(item))}
@@ -4,6 +4,7 @@ import { keyWithPrefix } from './../../internal/utils/common.js';
4
4
  export const selectVariants = tv({
5
5
  slots: {
6
6
  content: [
7
+ 'cgui:scrollbar-thin',
7
8
  'cgui:relative cgui:overflow-y-auto cgui:overflow-x-hidden',
8
9
  'cgui:shadow-select cgui:bg-surface-white',
9
10
  'cgui:rounded-sm',
@@ -21,6 +22,7 @@ export const selectVariants = tv({
21
22
  'cgui:[&_svg]:shrink-0 cgui:[&_svg]:pointer-events-none',
22
23
  ],
23
24
  viewport: [
25
+ ' cgui:scrollbar-track-transparent cgui:scrollbar-thumb-stroke-default cgui:scrollbar-thumb-rounded-full',
24
26
  'cgui:h-(--bits-select-anchor-height) cgui:min-w-(--bits-select-anchor-width) cgui:w-full cgui:scroll-my-1 cgui:p-1',
25
27
  ],
26
28
  group: [],
@@ -28,6 +30,7 @@ export const selectVariants = tv({
28
30
  trigger: [
29
31
  'cgui:group/select-trigger',
30
32
  'cgui:relative cgui:flex cgui:items-center cgui:justify-between cgui:flex-wrap',
33
+ 'cgui:text-body',
31
34
  'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
32
35
  ],
33
36
  },
@@ -54,7 +57,6 @@ export const selectVariants = tv({
54
57
  'cgui:px-2.5 cgui:py-1.5',
55
58
  'cgui:data-[start-chevron]:pl-8 cgui:data-[end-chevron]:pr-8',
56
59
  ],
57
- // chevron: ['cgui:data-[start-chevron]:left-2.5 cgui:data-[end-chevron]:right-2.5'],
58
60
  },
59
61
  md: {
60
62
  trigger: [
@@ -63,15 +65,14 @@ export const selectVariants = tv({
63
65
  'cgui:data-[start-chevron]:pl-10 cgui:data-[end-chevron]:pr-10',
64
66
  ],
65
67
  chevron: [],
66
- // chevron: ['cgui:data-[start-chevron]:left-3 cgui:data-[end-chevron]:right-3'],
67
68
  },
68
69
  lg: {
69
70
  trigger: [
70
71
  'cgui:min-h-11',
72
+ 'cgui:text-heading-2',
71
73
  'cgui:px-4 cgui:py-2.5',
72
74
  'cgui:data-[start-chevron]:pl-14 cgui:data-[end-chevron]:pr-14',
73
75
  ],
74
- // chevron: ['cgui:data-[start-chevron]:left-4 cgui:data-[end-chevron]:right-4'],
75
76
  },
76
77
  },
77
78
  rounded: {
@@ -37,6 +37,7 @@ export type SelectProps = SelectRootProps & {
37
37
  label: string;
38
38
  }]>;
39
39
  empty?: Snippet | string;
40
+ maxContentHeight?: string;
40
41
  side?: SelectContentProps['side'];
41
42
  sideOffset?: SelectContentProps['sideOffset'];
42
43
  align?: SelectContentProps['align'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casinogate/ui",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "svelte": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",