@invopop/popui 0.0.7 → 0.0.8

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.
@@ -151,27 +151,29 @@ function selectRange(to) {
151
151
  }}
152
152
  />
153
153
 
154
- <div class="w-full rounded-md md:border border-neutral-100 font-sans">
155
- <table class="hidden md:table w-full rounded-md">
154
+ <div class="w-full font-sans">
155
+ <table class="hidden md:table w-full">
156
156
  <thead>
157
157
  <tr class="border-b border-neutral-100 relative">
158
158
  {#if selectable}
159
159
  <!-- if table is selectable we need to add an extra header with a checkbox -->
160
- <th scope="col" class="bg-white sticky top-0 z-10 rounded-tr-md pl-1.5">
160
+ <th scope="col" class="bg-white sticky top-0 z-10 rounded-tr-md">
161
161
  {#if !hideSelectAll}
162
- <InputCheckbox
163
- checked={allChecked}
164
- {indeterminate}
165
- on:change={(event) => {
166
- toggleAllSelected(event.detail)
167
- }}
168
- />
162
+ <label class="pl-5 pr-3 h-[40px] flex items-center" for={undefined}>
163
+ <InputCheckbox
164
+ checked={allChecked}
165
+ {indeterminate}
166
+ on:change={(event) => {
167
+ toggleAllSelected(event.detail)
168
+ }}
169
+ />
170
+ </label>
169
171
  {/if}
170
172
  </th>
171
173
  {/if}
172
174
  {#each fields as field, i (i)}
173
175
  <BaseTableHeader
174
- isFirst={i === 0}
176
+ isFirst={i === 0 && !selectable}
175
177
  isLast={!addExtraCell && i === fields.length - 1}
176
178
  {sortBy}
177
179
  {sortDirection}
@@ -191,8 +193,8 @@ function selectRange(to) {
191
193
  <tr>
192
194
  <th
193
195
  scope="colgroup"
194
- colspan={fields.length + 1}
195
- class="bg-neutral-50 px-3 py-1.5 text-left text-sm font-medium text-neutral-500 sticky top-11 tracking-normal border-t border-b border-neutral-100 h-8"
196
+ colspan={fields.length + (selectable ? 2 : 1)}
197
+ class="bg-neutral-50 px-5 text-left text-sm font-medium text-neutral-500 sticky top-11 tracking-normal border-t border-b border-neutral-100 h-8"
196
198
  >
197
199
  <span>{group.label}</span>
198
200
  {#if !hideCounter}
@@ -261,7 +263,6 @@ function selectRange(to) {
261
263
  {#each fields as field, i (i)}
262
264
  <BaseTableCell
263
265
  tag="div"
264
- currentIndex={i}
265
266
  {field}
266
267
  badge={field.helperBadge ? field.helperBadge(row) : null}
267
268
  status={field.helperStatus ? field.helperStatus(row) : null}
@@ -7,23 +7,30 @@ import { getCountryName } from "./helpers.js";
7
7
  import UuidCopy from "./UuidCopy.svelte";
8
8
  import { Icon } from "@steeze-ui/svelte-icon";
9
9
  export let field;
10
- export let currentIndex;
10
+ export let isFirst = false;
11
+ export let isLast = false;
11
12
  export let badge = null;
12
13
  export let status = null;
13
14
  export let icons = null;
14
15
  export let data = "";
15
16
  export let freeWrap = false;
16
17
  export let tag = "td";
18
+ export let selectable = false;
19
+ export let hasActions = false;
17
20
  $:
18
21
  cellStyles = clsx(
19
22
  { "tabular-nums slashed-zero lining-nums": field.monospacedNums },
20
23
  { "font-mono": field.monospaced },
21
- { "text-neutral-800 font-medium": currentIndex === 0 && !field.grayed },
22
- { "text-neutral-800 md:text-neutral-500": currentIndex > 0 || field.grayed },
24
+ { "text-neutral-800 font-medium": isFirst && !field.grayed },
25
+ { "text-neutral-800 md:text-neutral-500": !isFirst || field.grayed },
23
26
  { "md:text-right": field.rightAlign },
24
27
  { "md:w-full md:max-w-0": field.fullWidth },
25
28
  { "py-2 md:py-[11.25px]": badge },
26
29
  { "py-2 md:py-[11.75px]": !badge },
30
+ { "pl-5": isFirst && !selectable },
31
+ { "pl-3": !isFirst || selectable },
32
+ { "pr-5": isLast && !hasActions },
33
+ { "pr-3": !isLast || hasActions },
27
34
  { "px-3": !field.noPadding },
28
35
  { "px-0": field.noPadding },
29
36
  { "whitespace-nowrap truncate": !freeWrap }
@@ -3,13 +3,16 @@ import type { Badge, FeedItemStatus, TableField, TableIcon } from './types.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  field: TableField;
6
- currentIndex: number;
6
+ isFirst?: boolean | undefined;
7
+ isLast?: boolean | undefined;
7
8
  badge?: Badge | null | undefined;
8
9
  status?: FeedItemStatus | null | undefined;
9
10
  icons?: TableIcon[] | null | undefined;
10
11
  data?: unknown;
11
12
  freeWrap?: boolean | undefined;
12
13
  tag?: string | undefined;
14
+ selectable?: boolean | undefined;
15
+ hasActions?: boolean | undefined;
13
16
  };
14
17
  events: {
15
18
  copied: CustomEvent<any>;
@@ -11,14 +11,16 @@ export let isFirst = false;
11
11
  export let isLast = false;
12
12
  $:
13
13
  outerStyles = clsx({
14
- "w-full": field.fullWidth,
15
- "rounded-tl-md": isFirst,
16
- "rounded-tr-md": isLast
14
+ "w-full": field.fullWidth
17
15
  });
18
16
  $:
19
17
  headerStyles = clsx({
20
18
  "justify-end": field.rightAlign,
21
- "hover:bg-neutral-50 focus:bg-neutral-100": field.sortable
19
+ "hover:bg-neutral-50 focus:bg-neutral-100": field.sortable,
20
+ "pl-5": isFirst,
21
+ "pl-3": !isFirst,
22
+ "pr-5": isLast,
23
+ "pr-3": !isLast
22
24
  });
23
25
  function handleSortBy(event) {
24
26
  sortDirection = event.detail;
@@ -38,7 +40,7 @@ function handleSortBy(event) {
38
40
  <BaseDropdown bind:this={sortDropdown} fullWidth>
39
41
  <span
40
42
  slot="trigger"
41
- class="{headerStyles} w-full p-3 flex items-center justify-start space-x-1 text-left text-base tracking-normal whitespace-nowrap font-normal"
43
+ class="{headerStyles} w-full py-3 flex items-center justify-start space-x-1 text-left text-base tracking-normal whitespace-nowrap font-normal"
42
44
  >
43
45
  <span>{field.headerLabel}</span>
44
46
  {#if sortBy === field.slug}
@@ -35,20 +35,26 @@ $:
35
35
  }}
36
36
  >
37
37
  {#if selectable}
38
- <td class="pl-1.5">
39
- <InputCheckbox
40
- {checked}
41
- on:change={(event) => {
42
- dispatch('checked', event.detail)
43
- }}
44
- />
38
+ <td>
39
+ <!-- for hack is needed in order to be used with the custom checkbox and silence the linter -->
40
+ <label class="pl-5 pr-1.5 h-[40px] flex items-center" for={undefined}>
41
+ <InputCheckbox
42
+ {checked}
43
+ on:change={(event) => {
44
+ dispatch('checked', event.detail)
45
+ }}
46
+ />
47
+ </label>
45
48
  </td>
46
49
  {/if}
47
50
  {#each fields as field, i (i)}
48
51
  <BaseTableCell
49
- currentIndex={i}
52
+ isFirst={i === 0}
53
+ isLast={i === fields.length - 1}
50
54
  {field}
51
55
  {freeWrap}
56
+ {selectable}
57
+ hasActions={!!actions.length}
52
58
  badge={field.helperBadge ? field.helperBadge(row) : null}
53
59
  status={field.helperStatus ? field.helperStatus(row) : null}
54
60
  icons={field.helperIcons ? field.helperIcons(row) : null}
@@ -57,7 +63,7 @@ $:
57
63
  />
58
64
  {/each}
59
65
  {#if actions.length}
60
- <td class="pl-1 pr-3">
66
+ <td class="pl-1 pr-5">
61
67
  <BaseTableActions
62
68
  bind:this={actionsDropdown}
63
69
  {actions}
@@ -17,7 +17,7 @@ function updateInput(event) {
17
17
  type="checkbox"
18
18
  {checked}
19
19
  {indeterminate}
20
- class="form-checkbox w-5 h-5 text-workspace-accent focus:text-workspace-accent rounded border border-neutral-200 focus:ring-0 focus:ring-offset-0"
20
+ class="form-checkbox w-5 h-5 text-workspace-accent focus:text-workspace-accent rounded border border-neutral-200 hover:border-neutral-300 focus:ring-0 focus:ring-offset-0"
21
21
  on:change={updateInput}
22
22
  on:click|stopPropagation
23
23
  />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run package",