frappe-ui 0.1.38 → 0.1.40

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -1,22 +1,29 @@
1
1
  <template>
2
- <div class="flex items-center px-2 py-1.5">
3
- <button @click="toggleGroup" class="-ml-[1px] rounded-sm hover:bg-gray-50">
2
+ <div class="flex items-center">
3
+ <button
4
+ @click="toggleGroup"
5
+ class="ml-[3px] mr-[11px] rounded p-1 hover:bg-gray-100"
6
+ >
4
7
  <DownSolid
5
8
  class="h-4 w-4 text-gray-900 transition-transform duration-200"
6
9
  :class="[group.collapsed ? '-rotate-90' : '']"
7
10
  />
8
11
  </button>
9
- <div class="ml-[15px] w-full">
10
- <slot>
11
- <span class="text-base font-medium leading-6">
12
- {{ group.group }}
13
- </span>
14
- </slot>
12
+ <div class="w-full py-1.5 pr-2">
13
+ <component
14
+ v-if="list.slots['group-header']"
15
+ :is="list.slots['group-header']"
16
+ v-bind="{ group }"
17
+ />
18
+ <span v-else class="text-base font-medium leading-6">
19
+ {{ group.group }}
20
+ </span>
15
21
  </div>
16
22
  </div>
17
23
  <div class="mx-2 h-px border-t border-gray-200"></div>
18
24
  </template>
19
25
  <script setup>
26
+ import { inject } from 'vue'
20
27
  import DownSolid from '../../icons/DownSolid.vue'
21
28
 
22
29
  const props = defineProps({
@@ -26,6 +33,8 @@ const props = defineProps({
26
33
  },
27
34
  })
28
35
 
36
+ const list = inject('list')
37
+
29
38
  function toggleGroup() {
30
39
  if (props.group.collapsed == null) {
31
40
  props.group.collapsed = false
@@ -43,7 +43,18 @@
43
43
  ]"
44
44
  >
45
45
  <slot v-bind="{ idx: i, column, item: row[column.key] }">
46
+ <component
47
+ v-if="list.slots.cell"
48
+ :is="list.slots.cell"
49
+ v-bind="{
50
+ column,
51
+ row,
52
+ item: row[column.key],
53
+ align: column.align,
54
+ }"
55
+ />
46
56
  <ListRowItem
57
+ v-else
47
58
  :column="column"
48
59
  :row="row"
49
60
  :item="row[column.key]"
@@ -22,7 +22,7 @@ import ListHeader from './ListHeader.vue'
22
22
  import ListRows from './ListRows.vue'
23
23
  import ListGroups from './ListGroups.vue'
24
24
  import ListSelectBanner from './ListSelectBanner.vue'
25
- import { reactive, computed, provide, watch } from 'vue'
25
+ import { reactive, computed, provide, watch, useSlots } from 'vue'
26
26
 
27
27
  defineOptions({
28
28
  inheritAttrs: false,
@@ -58,6 +58,8 @@ const props = defineProps({
58
58
  },
59
59
  })
60
60
 
61
+ const slots = useSlots()
62
+
61
63
  let selections = reactive(new Set())
62
64
 
63
65
  const emit = defineEmits(['update:selections'])
@@ -122,6 +124,7 @@ provide(
122
124
  options: _options.value,
123
125
  selections: selections,
124
126
  allRowsSelected: allRowsSelected.value,
127
+ slots: slots,
125
128
  toggleRow,
126
129
  toggleAllRows,
127
130
  }))
@@ -372,20 +372,35 @@ const custom_rows = [
372
372
  resizeColumn: state.resizeColumn,
373
373
  }"
374
374
  row-key="id"
375
- v-slot="{ showGroupedRows, selectable }"
376
375
  >
377
- <ListHeader />
378
- <ListGroups v-if="showGroupedRows">
379
- <template #group-header="{ group }">
380
- <span class="text-base font-medium leading-6 text-gray-900">
381
- {{ group.group }} ({{ group.rows.length }})
382
- </span>
383
- </template>
384
- </ListGroups>
385
- <ListRows v-else />
386
- <ListSelectBanner v-if="selectable" />
376
+ <template #group-header="{ group }">
377
+ <span class="text-base font-medium leading-6 text-gray-900">
378
+ {{ group.group }} ({{ group.rows.length }})
379
+ </span>
380
+ </template>
387
381
  </ListView>
388
382
  </Variant>
383
+ <Variant title="Cell Slot">
384
+ <div>
385
+ <ListView
386
+ class="h-[250px]"
387
+ :columns="simple_columns"
388
+ :rows="simple_rows"
389
+ :options="{
390
+ selectable: state.selectable,
391
+ showTooltip: state.showTooltip,
392
+ resizeColumn: state.resizeColumn,
393
+ emptyState: state.emptyState,
394
+ }"
395
+ row-key="id"
396
+ >
397
+ <template #cell="{ item, row, column }">
398
+ <Badge v-if="column.key == 'status'">{{ item }}</Badge>
399
+ <span class="font-medium text-gray-700" v-else>{{ item }}</span>
400
+ </template>
401
+ </ListView>
402
+ </div>
403
+ </Variant>
389
404
  <Variant title="Empty List">
390
405
  <div>
391
406
  <ListView