@polymarbot/nuxt-layer-shadcn-ui 0.8.4 → 0.8.6

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.
@@ -137,7 +137,9 @@ function formatCellValue (value: unknown, column: DataTableColumn): string {
137
137
  return formatDateTime((value as number) * 1000).split(' ').join('\n')
138
138
 
139
139
  case 'currency':
140
- return formatCurrency(value as number | string, column.currency ?? 'JPY')
140
+ return formatCurrency(value as number | string, column.currency ?? 'USD', {
141
+ currencyDisplay: column.currencyDisplay,
142
+ })
141
143
 
142
144
  case 'empty':
143
145
  return ''
@@ -24,6 +24,8 @@ export interface DataTableColumn {
24
24
  sortable?: boolean
25
25
  /** Currency code for 'currency' type (e.g., 'USD', 'JPY'). Default: 'USD' */
26
26
  currency?: string
27
+ /** How to display the currency for 'currency' type. Default: 'symbol' */
28
+ currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name'
27
29
  /** Custom class applied to the body cell (`<td>`) container */
28
30
  class?: string
29
31
  /** Custom class applied to the header cell (`<th>`) container */
@@ -2,7 +2,7 @@
2
2
  import type { InputCurrencyProps } from './types'
3
3
 
4
4
  const props = withDefaults(defineProps<InputCurrencyProps>(), {
5
- currency: 'JPY',
5
+ currency: 'USD',
6
6
  currencyDisplay: 'symbol',
7
7
  })
8
8
 
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import EventLog from '#storybook/EventLog.vue'
3
3
  import { useArgsModel } from '#storybook/argsModel'
4
+ import InputCurrency from '../InputCurrency/index.vue'
4
5
  import InputRange from './index.vue'
5
6
 
6
7
  const meta = {
@@ -14,6 +15,7 @@ const meta = {
14
15
  startPlaceholder: { control: 'text' },
15
16
  endPlaceholder: { control: 'text' },
16
17
  disabled: { control: 'boolean' },
18
+ as: { control: false },
17
19
  },
18
20
  args: {
19
21
  start: undefined,
@@ -23,6 +25,7 @@ const meta = {
23
25
  startPlaceholder: '',
24
26
  endPlaceholder: '',
25
27
  disabled: false,
28
+ as: undefined,
26
29
  },
27
30
  render: args => {
28
31
  const onUpdateStart = useArgsModel('start')
@@ -68,6 +71,44 @@ export const Disabled: Story = {
68
71
  },
69
72
  }
70
73
 
74
+ export const CustomInput: Story = {
75
+ parameters: {
76
+ ...noControls,
77
+ docs: {
78
+ source: {
79
+ code: `
80
+ <template>
81
+ <InputRange
82
+ v-model:start="start"
83
+ v-model:end="end"
84
+ :as="InputCurrency"
85
+ currency="JPY"
86
+ />
87
+ </template>
88
+ `.trim(),
89
+ },
90
+ },
91
+ },
92
+ render: () => ({
93
+ components: { InputRange },
94
+ setup: () => ({
95
+ start: ref<number | undefined>(1000),
96
+ end: ref<number | undefined>(5000),
97
+ InputCurrency,
98
+ }),
99
+ template: `
100
+ <div class="max-w-md">
101
+ <InputRange
102
+ v-model:start="start"
103
+ v-model:end="end"
104
+ :as="InputCurrency"
105
+ currency="JPY"
106
+ />
107
+ </div>
108
+ `,
109
+ }),
110
+ }
111
+
71
112
  export const EventHandling: Story = {
72
113
  parameters: noControls,
73
114
  render: () => ({
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import InputNumber from '../InputNumber/index.vue'
2
3
  import type { InputRangeProps } from './types'
3
4
 
4
5
  defineOptions({ inheritAttrs: false })
@@ -10,8 +11,11 @@ const props = withDefaults(defineProps<InputRangeProps>(), {
10
11
  max: undefined,
11
12
  startPlaceholder: undefined,
12
13
  endPlaceholder: undefined,
14
+ as: undefined,
13
15
  })
14
16
 
17
+ const inputComponent = computed(() => props.as ?? InputNumber)
18
+
15
19
  const emit = defineEmits<{
16
20
  'update:start': [value: number | undefined]
17
21
  'update:end': [value: number | undefined]
@@ -33,7 +37,8 @@ const end = computed({
33
37
 
34
38
  <template>
35
39
  <div class="gap-2 flex items-center">
36
- <InputNumber
40
+ <component
41
+ :is="inputComponent"
37
42
  v-model="start"
38
43
  v-bind="$attrs"
39
44
  :min="min"
@@ -44,7 +49,8 @@ const end = computed({
44
49
  <span class="leading-0 text-muted-foreground">
45
50
  {{ t('common.symbols.connector') }}
46
51
  </span>
47
- <InputNumber
52
+ <component
53
+ :is="inputComponent"
48
54
  v-model="end"
49
55
  v-bind="$attrs"
50
56
  :min="start ?? min"
@@ -1,3 +1,4 @@
1
+ import type { Component } from 'vue'
1
2
  import type { InputNumberProps } from '../InputNumber/types'
2
3
 
3
4
  export interface InputRangeProps extends /* @vue-ignore */ InputNumberProps {
@@ -9,4 +10,6 @@ export interface InputRangeProps extends /* @vue-ignore */ InputNumberProps {
9
10
  startPlaceholder?: string
10
11
  /** Placeholder for end input */
11
12
  endPlaceholder?: string
13
+ /** Inner input component. Defaults to `InputNumber`; can be replaced with `InputCurrency`, `InputPercent`, etc. */
14
+ as?: Component
12
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymarbot/nuxt-layer-shadcn-ui",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Nuxt layer providing shadcn-vue based UI components",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@polymarbot/nuxt-layer-basic": "^0.1",
21
- "@polymarbot/uitls-shared": "^0.5",
21
+ "@polymarbot/uitls-shared": "^0.5.1",
22
22
  "@tanstack/vue-table": "^8.21.3",
23
23
  "@types/lodash-es": "^4.17.12",
24
24
  "@types/qrcode": "^1.5.6",
@@ -42,5 +42,5 @@
42
42
  "vue-i18n": "^11",
43
43
  "vue-router": "^4 || ^5"
44
44
  },
45
- "gitHead": "d561383c133bd4f981cc2c289fbc675bcdaec917"
45
+ "gitHead": "c2aa82c36486efc10b9d5723fcd49bb764f473d9"
46
46
  }