@insymetri/styleguide 0.1.20 → 0.1.22

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.
@@ -2,6 +2,7 @@
2
2
  import {cn} from '../utils/cn'
3
3
  import type {IconName} from '../icons'
4
4
  import {IIIcon} from '../IIIcon'
5
+ import {IIPillTabs} from '../IIPillTabs'
5
6
 
6
7
  import type {Severity, AuditEvent, AuditFilter} from './IIAuditTrail.types'
7
8
 
@@ -88,21 +89,7 @@
88
89
  </script>
89
90
 
90
91
  {#if filters.length > 0}
91
- <div class="flex gap-8 flex-wrap mb-16">
92
- {#each filters as f (f.value)}
93
- <button
94
- class={cn(
95
- 'flex items-center gap-4 px-12 py-8 rounded-full text-small-emphasis cursor-default',
96
- activeFilter === f.value
97
- ? 'bg-gray-100 text-body border border-strong'
98
- : 'bg-surface text-secondary border border-primary hover:bg-gray-100 hover:border-strong'
99
- )}
100
- onclick={() => (activeFilter = f.value)}
101
- >
102
- {f.label}
103
- </button>
104
- {/each}
105
- </div>
92
+ <IIPillTabs tabs={filters} bind:value={activeFilter} class="mb-16" />
106
93
  {/if}
107
94
 
108
95
  {#if loading}
@@ -45,7 +45,7 @@
45
45
  class={cn(
46
46
  'flex items-center justify-center border-2 rounded-4 transition-all duration-fast motion-reduce:transition-none',
47
47
  size === 'sm' ? 'w-16 h-16' : 'w-18 h-18',
48
- checked ? 'bg-primary border-primary' : 'border-strong bg-surface',
48
+ checked ? 'bg-primary border-accent' : 'border-strong bg-surface',
49
49
  disabled && 'opacity-50'
50
50
  )}
51
51
  >
@@ -127,7 +127,7 @@
127
127
  {#snippet comboboxItem(item: T, i: number)}
128
128
  <Combobox.Item
129
129
  value={getItemValue(item)}
130
- label=""
130
+ label={isSimpleItem(item) ? item.label : getItemValue(item)}
131
131
  disabled={getItemDisabled?.(item) ?? false}
132
132
  class="flex items-center gap-8 py-6 px-12 text-small text-dropdown-item rounded-6 cursor-default transition-all duration-fast outline-none hover:bg-dropdown-item-hover data-[highlighted]:bg-dropdown-item-hover data-[selected]:bg-dropdown-item-selected data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed motion-reduce:transition-none"
133
133
  >
@@ -0,0 +1,134 @@
1
+ <script lang="ts">
2
+ import {DatePicker} from 'bits-ui'
3
+ import type {DateValue} from '@internationalized/date'
4
+ import {IIIcon} from '../IIIcon'
5
+ import {IIIconButton} from '../IIIconButton'
6
+ import {cn} from '../utils/cn'
7
+
8
+ type Props = {
9
+ value: DateValue | undefined
10
+ label?: string
11
+ errorMessage?: string
12
+ helperText?: string
13
+ error?: boolean
14
+ disabled?: boolean
15
+ onValueChange?: (value: DateValue | undefined) => void
16
+ class?: string
17
+ }
18
+
19
+ let {
20
+ value = $bindable(),
21
+ label,
22
+ errorMessage,
23
+ helperText,
24
+ error = false,
25
+ disabled = false,
26
+ onValueChange,
27
+ class: className,
28
+ }: Props = $props()
29
+
30
+ const showError = $derived(error || !!errorMessage)
31
+ </script>
32
+
33
+ <div class={cn('flex flex-col gap-4', className)}>
34
+ <DatePicker.Root bind:value {onValueChange} {disabled}>
35
+ {#if label}
36
+ <DatePicker.Label class="text-small-emphasis text-body">{label}</DatePicker.Label>
37
+ {/if}
38
+ <DatePicker.Input
39
+ class={cn(
40
+ 'flex items-center gap-4 py-5 px-12 border rounded-control text-small bg-input-bg border-input-border transition-all duration-fast hover:border-input-border-hover [&:has(:focus)]:border-input-border-hover motion-reduce:transition-none',
41
+ showError && 'border-input-border-error [&:has(:focus)]:border-input-border-error',
42
+ disabled && 'bg-input-bg-disabled cursor-not-allowed'
43
+ )}
44
+ >
45
+ {#snippet children({segments})}
46
+ {#each segments as { part, value: segValue }, i (`${part}-${i}`)}
47
+ <DatePicker.Segment
48
+ {part}
49
+ class="py-4 min-w-[2ch] text-center text-input-text outline-none cursor-text rounded-4 transition-all duration-fast focus:bg-primary focus:text-inverse data-[placeholder]:text-input-placeholder motion-reduce:transition-none"
50
+ >
51
+ {segValue}
52
+ </DatePicker.Segment>
53
+ {/each}
54
+ <DatePicker.Trigger asChild>
55
+ {#snippet child({props})}
56
+ <IIIconButton {...props} iconName="calendar" variant="ghost" size="sm" disabled={disabled} />
57
+ {/snippet}
58
+ </DatePicker.Trigger>
59
+ {/snippet}
60
+ </DatePicker.Input>
61
+ <DatePicker.Content class="bg-surface border border-primary rounded-10 shadow-dropdown p-12 z-12 min-w-280">
62
+ <DatePicker.Calendar>
63
+ {#snippet children({months, weekdays})}
64
+ <div class="flex items-center justify-between gap-16 mb-12">
65
+ <DatePicker.MonthSelect aria-label="Select month" monthFormat="long">
66
+ {#snippet child({props, monthItems, selectedMonthItem})}
67
+ <select
68
+ {...props}
69
+ class="appearance-none bg-transparent border-0 py-4 pr-16 pl-0 text-small-emphasis text-body cursor-pointer focus:outline-none flex-1"
70
+ style="background-image: url(&quot;data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E&quot;); background-repeat: no-repeat; background-position: right center"
71
+ >
72
+ {#each monthItems as month (month.value)}
73
+ <option value={month.value} selected={month.value === selectedMonthItem.value}>
74
+ {month.label}
75
+ </option>
76
+ {/each}
77
+ </select>
78
+ {/snippet}
79
+ </DatePicker.MonthSelect>
80
+ <DatePicker.YearSelect aria-label="Select year">
81
+ {#snippet child({props, yearItems, selectedYearItem})}
82
+ <select
83
+ {...props}
84
+ class="appearance-none bg-transparent border-0 py-4 pr-16 pl-0 text-small-emphasis text-body cursor-pointer focus:outline-none"
85
+ style="background-image: url(&quot;data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E&quot;); background-repeat: no-repeat; background-position: right center"
86
+ >
87
+ {#each yearItems as year (year.value)}
88
+ <option value={year.value} selected={year.value === selectedYearItem.value}>
89
+ {year.label}
90
+ </option>
91
+ {/each}
92
+ </select>
93
+ {/snippet}
94
+ </DatePicker.YearSelect>
95
+ </div>
96
+
97
+ {#each months as month (month.value.toString())}
98
+ <DatePicker.Grid class="w-full border-collapse">
99
+ <DatePicker.GridHead>
100
+ <DatePicker.GridRow class="flex w-full">
101
+ {#each weekdays as day, i (`day-${i}`)}
102
+ <DatePicker.HeadCell class="flex-1 text-center text-tiny-emphasis text-secondary p-4 uppercase">
103
+ {day.slice(0, 2)}
104
+ </DatePicker.HeadCell>
105
+ {/each}
106
+ </DatePicker.GridRow>
107
+ </DatePicker.GridHead>
108
+ <DatePicker.GridBody>
109
+ {#each month.weeks as weekDates, weekIndex (weekIndex)}
110
+ <DatePicker.GridRow class="flex w-full">
111
+ {#each weekDates as date (date.toString())}
112
+ <DatePicker.Cell {date} month={month.value} class="flex-1 aspect-square p-2">
113
+ <DatePicker.Day
114
+ class="[all:unset] flex items-center justify-center w-full h-full rounded-4 text-small text-body cursor-default transition-all duration-fast hover:bg-gray-100 data-[selected]:bg-primary data-[selected]:text-inverse data-[selected]:font-semibold data-[today]:border data-[today]:border-primary data-[outside-month]:text-tertiary data-[outside-month]:opacity-50 data-[disabled]:text-tertiary data-[disabled]:cursor-not-allowed data-[disabled]:opacity-30 motion-reduce:transition-none"
115
+ >
116
+ {date.day}
117
+ </DatePicker.Day>
118
+ </DatePicker.Cell>
119
+ {/each}
120
+ </DatePicker.GridRow>
121
+ {/each}
122
+ </DatePicker.GridBody>
123
+ </DatePicker.Grid>
124
+ {/each}
125
+ {/snippet}
126
+ </DatePicker.Calendar>
127
+ </DatePicker.Content>
128
+ </DatePicker.Root>
129
+ {#if showError && errorMessage}
130
+ <span class="text-tiny text-error">{errorMessage}</span>
131
+ {:else if helperText}
132
+ <span class="text-tiny text-secondary">{helperText}</span>
133
+ {/if}
134
+ </div>
@@ -0,0 +1,14 @@
1
+ import type { DateValue } from '@internationalized/date';
2
+ type Props = {
3
+ value: DateValue | undefined;
4
+ label?: string;
5
+ errorMessage?: string;
6
+ helperText?: string;
7
+ error?: boolean;
8
+ disabled?: boolean;
9
+ onValueChange?: (value: DateValue | undefined) => void;
10
+ class?: string;
11
+ };
12
+ declare const IIDateInput: import("svelte").Component<Props, {}, "value">;
13
+ type IIDateInput = ReturnType<typeof IIDateInput>;
14
+ export default IIDateInput;
@@ -0,0 +1 @@
1
+ export { default as IIDateInput } from './IIDateInput.svelte';
@@ -0,0 +1 @@
1
+ export { default as IIDateInput } from './IIDateInput.svelte';
@@ -60,7 +60,7 @@
60
60
  bind:ref={triggerEl}
61
61
  {disabled}
62
62
  class={cn(
63
- 'flex items-center justify-between gap-4 py-5 pl-12 pr-8 border rounded-control bg-button-secondary cursor-default text-small text-button-secondary box-border appearance-none font-inherit outline-none transition-colors duration-base ease-in-out hover:text-button-secondary-hover hover:border-button-secondary-hover focus:border-accent focus:ring-3 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed',
63
+ 'flex items-center justify-between gap-4 py-5 pl-12 pr-8 border rounded-control bg-input-bg cursor-default text-small text-button-secondary box-border appearance-none font-inherit outline-none transition-colors duration-base ease-in-out hover:text-button-secondary-hover hover:border-button-secondary-hover focus:border-accent focus:ring-3 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed',
64
64
  open ? 'border-button-secondary-hover' : 'border-button-secondary',
65
65
  className
66
66
  )}
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type {Snippet} from 'svelte'
3
3
  import {Dialog} from 'bits-ui'
4
- import {IIIcon} from '../IIIcon'
4
+ import {IIIconButton} from '../IIIconButton'
5
5
  import {cn} from '../utils/cn'
6
6
 
7
7
  type Props = {
@@ -46,7 +46,7 @@
46
46
  className
47
47
  )}
48
48
  >
49
- <div class="flex items-center justify-between p-16 border-b border-primary shrink-0">
49
+ <div class="flex items-start justify-between p-16 border-b border-primary shrink-0">
50
50
  <div>
51
51
  <Dialog.Title class="text-h4 text-body m-0">{title}</Dialog.Title>
52
52
  {#if description}
@@ -56,10 +56,10 @@
56
56
  {/if}
57
57
  </div>
58
58
  {#if showCloseButton}
59
- <Dialog.Close
60
- class="[all:unset] cursor-default flex items-center justify-center p-4 rounded-4 text-secondary transition-all duration-fast hover:bg-background hover:text-body motion-reduce:transition-none"
61
- >
62
- <IIIcon iconName="x" class="size-20" />
59
+ <Dialog.Close asChild>
60
+ {#snippet child({props})}
61
+ <IIIconButton {...props} iconName="x" variant="ghost" size="sm" />
62
+ {/snippet}
63
63
  </Dialog.Close>
64
64
  {/if}
65
65
  </div>
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { IICard } from './IICard';
10
10
  export { IICheckbox } from './IICheckbox';
11
11
  export { IICheckboxList } from './IICheckboxList';
12
12
  export { IICombobox } from './IICombobox';
13
+ export { IIDateInput } from './IIDateInput';
13
14
  export { IIDatePicker } from './IIDatePicker';
14
15
  export { IIDropdownInput } from './IIDropdownInput';
15
16
  export { IIDropdownMenu } from './IIDropdownMenu';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export { IICard } from './IICard';
12
12
  export { IICheckbox } from './IICheckbox';
13
13
  export { IICheckboxList } from './IICheckboxList';
14
14
  export { IICombobox } from './IICombobox';
15
+ export { IIDateInput } from './IIDateInput';
15
16
  export { IIDatePicker } from './IIDatePicker';
16
17
  export { IIDropdownInput } from './IIDropdownInput';
17
18
  export { IIDropdownMenu } from './IIDropdownMenu';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insymetri/styleguide",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Insymetri shared UI component library built with Svelte 5",
5
5
  "type": "module",
6
6
  "scripts": {