@naptics/vue-collection 1.0.0-beta.1 → 1.0.0-beta.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.
Files changed (200) hide show
  1. package/lib/components/NAlert.d.ts +29 -0
  2. package/lib/components/NAlert.js +84 -0
  3. package/lib/components/NBadge.d.ts +73 -0
  4. package/lib/components/NBadge.js +64 -0
  5. package/lib/components/NBreadcrub.d.ts +69 -0
  6. package/lib/components/NBreadcrub.js +71 -0
  7. package/lib/components/NButton.d.ts +64 -0
  8. package/lib/components/NButton.js +70 -0
  9. package/lib/components/NCheckbox.d.ts +20 -0
  10. package/lib/components/NCheckbox.js +43 -0
  11. package/lib/components/NCheckboxLabel.d.ts +26 -0
  12. package/lib/components/NCheckboxLabel.js +42 -0
  13. package/lib/components/NCrudModal.d.ts +118 -0
  14. package/lib/components/NCrudModal.js +120 -0
  15. package/lib/components/NDialog.d.ts +81 -0
  16. package/lib/components/NDialog.js +161 -0
  17. package/lib/components/NDropdown.d.ts +67 -0
  18. package/lib/components/NDropdown.js +115 -0
  19. package/lib/components/NDropzone.d.ts +61 -0
  20. package/lib/components/NDropzone.js +218 -0
  21. package/lib/components/NForm.d.ts +21 -0
  22. package/lib/components/NForm.js +29 -0
  23. package/lib/components/NFormModal.d.ts +75 -0
  24. package/lib/components/NFormModal.js +59 -0
  25. package/lib/components/NIconButton.d.ts +83 -0
  26. package/lib/components/NIconButton.js +88 -0
  27. package/lib/components/NIconCircle.d.ts +49 -0
  28. package/lib/components/NIconCircle.js +67 -0
  29. package/lib/components/NInput.d.ts +94 -0
  30. package/lib/components/NInput.js +110 -0
  31. package/lib/components/NInputPhone.d.ts +58 -0
  32. package/lib/components/NInputPhone.js +47 -0
  33. package/lib/components/NInputSelect.d.ts +103 -0
  34. package/lib/components/NInputSelect.js +115 -0
  35. package/lib/components/NInputSuggestion.d.ts +79 -0
  36. package/lib/components/NInputSuggestion.js +64 -0
  37. package/lib/components/NLink.d.ts +47 -0
  38. package/lib/components/NLink.js +67 -0
  39. package/lib/components/NList.d.ts +37 -0
  40. package/lib/components/NList.js +40 -0
  41. package/lib/components/NLoadingIndicator.d.ts +29 -0
  42. package/lib/components/NLoadingIndicator.js +54 -0
  43. package/lib/components/NModal.d.ts +133 -0
  44. package/lib/components/NModal.js +235 -0
  45. package/{src/lib → lib}/components/NPagination.css +1 -1
  46. package/lib/components/NPagination.d.ts +37 -0
  47. package/lib/components/NPagination.js +105 -0
  48. package/lib/components/NSearchbar.d.ts +39 -0
  49. package/lib/components/NSearchbar.js +64 -0
  50. package/lib/components/NSearchbarList.d.ts +33 -0
  51. package/lib/components/NSearchbarList.js +41 -0
  52. package/lib/components/NSelect.d.ts +82 -0
  53. package/lib/components/NSelect.js +101 -0
  54. package/lib/components/NSuggestionList.d.ts +153 -0
  55. package/lib/components/NSuggestionList.js +160 -0
  56. package/{src/lib → lib}/components/NTable.css +1 -1
  57. package/lib/components/NTable.d.ts +97 -0
  58. package/lib/components/NTable.js +128 -0
  59. package/lib/components/NTableAction.d.ts +30 -0
  60. package/lib/components/NTableAction.js +50 -0
  61. package/lib/components/NTextArea.d.ts +96 -0
  62. package/lib/components/NTextArea.js +133 -0
  63. package/{src/lib → lib}/components/NTooltip.css +1 -1
  64. package/lib/components/NTooltip.d.ts +152 -0
  65. package/lib/components/NTooltip.js +241 -0
  66. package/lib/components/NValInput.d.ts +156 -0
  67. package/lib/components/NValInput.js +113 -0
  68. package/lib/components/ValidatedForm.d.ts +39 -0
  69. package/lib/components/ValidatedForm.js +35 -0
  70. package/{src/lib/i18n/index.ts → lib/i18n/index.d.ts} +9 -23
  71. package/lib/i18n/index.js +31 -0
  72. package/lib/index.d.ts +2 -0
  73. package/lib/index.js +2 -0
  74. package/lib/utils/breakpoints.d.ts +18 -0
  75. package/lib/utils/breakpoints.js +40 -0
  76. package/lib/utils/component.d.ts +57 -0
  77. package/lib/utils/component.js +79 -0
  78. package/lib/utils/deferred.d.ts +13 -0
  79. package/lib/utils/deferred.js +17 -0
  80. package/lib/utils/identifiable.d.ts +56 -0
  81. package/lib/utils/identifiable.js +81 -0
  82. package/lib/utils/stringMaxLength.d.ts +14 -0
  83. package/lib/utils/stringMaxLength.js +23 -0
  84. package/lib/utils/tailwind.d.ts +4 -0
  85. package/lib/utils/tailwind.js +1 -0
  86. package/lib/utils/utils.d.ts +47 -0
  87. package/lib/utils/utils.js +56 -0
  88. package/{src/lib/utils/vModel.ts → lib/utils/vModel.d.ts} +48 -126
  89. package/lib/utils/vModel.js +224 -0
  90. package/lib/utils/validation.d.ts +90 -0
  91. package/lib/utils/validation.js +147 -0
  92. package/lib/utils/vue.d.ts +13 -0
  93. package/lib/utils/vue.js +21 -0
  94. package/package.json +6 -2
  95. package/.github/workflows/build.yml +0 -26
  96. package/.github/workflows/deploy-demo.yml +0 -46
  97. package/.github/workflows/deploy-lib.yml +0 -59
  98. package/.gitlab-ci.yml +0 -57
  99. package/.nvmrc +0 -1
  100. package/.prettierrc +0 -8
  101. package/.vscode/extensions.json +0 -10
  102. package/.vscode/launch.json +0 -23
  103. package/.vscode/settings.json +0 -13
  104. package/babel.config.json +0 -3
  105. package/env.d.ts +0 -15
  106. package/eslint.config.cjs +0 -27
  107. package/index.html +0 -13
  108. package/postcss.config.js +0 -3
  109. package/public/favicon.ico +0 -0
  110. package/scripts/build-lib.sh +0 -52
  111. package/scripts/sync-node-types.js +0 -70
  112. package/src/demo/App.css +0 -53
  113. package/src/demo/App.tsx +0 -5
  114. package/src/demo/components/ColorGrid.tsx +0 -26
  115. package/src/demo/components/ComponentGrid.tsx +0 -26
  116. package/src/demo/components/ComponentSection.tsx +0 -30
  117. package/src/demo/components/VariantSection.tsx +0 -18
  118. package/src/demo/i18n/de.ts +0 -7
  119. package/src/demo/i18n/en.ts +0 -7
  120. package/src/demo/i18n/index.ts +0 -24
  121. package/src/demo/main.ts +0 -13
  122. package/src/demo/router/index.ts +0 -21
  123. package/src/demo/views/HomeView.tsx +0 -94
  124. package/src/demo/views/NavigationView.tsx +0 -43
  125. package/src/demo/views/presentation/AlertView.tsx +0 -40
  126. package/src/demo/views/presentation/BadgeView.tsx +0 -61
  127. package/src/demo/views/presentation/BreadcrumbView.tsx +0 -52
  128. package/src/demo/views/presentation/ButtonView.tsx +0 -49
  129. package/src/demo/views/presentation/CheckboxView.tsx +0 -59
  130. package/src/demo/views/presentation/DropdownView.tsx +0 -59
  131. package/src/demo/views/presentation/DropzoneView.tsx +0 -39
  132. package/src/demo/views/presentation/IconButtonView.tsx +0 -47
  133. package/src/demo/views/presentation/IconCircleView.tsx +0 -38
  134. package/src/demo/views/presentation/InputView.tsx +0 -179
  135. package/src/demo/views/presentation/LinkView.tsx +0 -60
  136. package/src/demo/views/presentation/ListView.tsx +0 -29
  137. package/src/demo/views/presentation/LoadingIndicatorView.tsx +0 -38
  138. package/src/demo/views/presentation/ModalView.tsx +0 -210
  139. package/src/demo/views/presentation/PaginationView.tsx +0 -25
  140. package/src/demo/views/presentation/SearchbarView.tsx +0 -80
  141. package/src/demo/views/presentation/TableView.tsx +0 -146
  142. package/src/demo/views/presentation/TooltipView.tsx +0 -92
  143. package/src/lib/components/NAlert.tsx +0 -85
  144. package/src/lib/components/NBadge.tsx +0 -75
  145. package/src/lib/components/NBreadcrub.tsx +0 -97
  146. package/src/lib/components/NButton.tsx +0 -82
  147. package/src/lib/components/NCheckbox.tsx +0 -55
  148. package/src/lib/components/NCheckboxLabel.tsx +0 -51
  149. package/src/lib/components/NCrudModal.tsx +0 -133
  150. package/src/lib/components/NDialog.tsx +0 -182
  151. package/src/lib/components/NDropdown.tsx +0 -169
  152. package/src/lib/components/NDropzone.tsx +0 -265
  153. package/src/lib/components/NForm.tsx +0 -32
  154. package/src/lib/components/NFormModal.tsx +0 -66
  155. package/src/lib/components/NIconButton.tsx +0 -92
  156. package/src/lib/components/NIconCircle.tsx +0 -78
  157. package/src/lib/components/NInput.tsx +0 -139
  158. package/src/lib/components/NInputPhone.tsx +0 -53
  159. package/src/lib/components/NInputSelect.tsx +0 -126
  160. package/src/lib/components/NInputSuggestion.tsx +0 -80
  161. package/src/lib/components/NLink.tsx +0 -82
  162. package/src/lib/components/NList.tsx +0 -67
  163. package/src/lib/components/NLoadingIndicator.tsx +0 -63
  164. package/src/lib/components/NModal.tsx +0 -243
  165. package/src/lib/components/NPagination.tsx +0 -131
  166. package/src/lib/components/NSearchbar.tsx +0 -78
  167. package/src/lib/components/NSearchbarList.tsx +0 -47
  168. package/src/lib/components/NSelect.tsx +0 -128
  169. package/src/lib/components/NSuggestionList.tsx +0 -216
  170. package/src/lib/components/NTable.tsx +0 -247
  171. package/src/lib/components/NTableAction.tsx +0 -49
  172. package/src/lib/components/NTextArea.tsx +0 -159
  173. package/src/lib/components/NTooltip.tsx +0 -289
  174. package/src/lib/components/NValInput.tsx +0 -163
  175. package/src/lib/components/ValidatedForm.ts +0 -71
  176. package/src/lib/components/__tests__/NButton.spec.tsx +0 -26
  177. package/src/lib/components/__tests__/NCheckbox.spec.tsx +0 -39
  178. package/src/lib/index.ts +0 -2
  179. package/src/lib/jsx.d.ts +0 -13
  180. package/src/lib/utils/__tests__/identifiable.spec.ts +0 -72
  181. package/src/lib/utils/__tests__/validation.spec.ts +0 -92
  182. package/src/lib/utils/breakpoints.ts +0 -47
  183. package/src/lib/utils/component.tsx +0 -131
  184. package/src/lib/utils/deferred.ts +0 -28
  185. package/src/lib/utils/identifiable.ts +0 -87
  186. package/src/lib/utils/stringMaxLength.ts +0 -25
  187. package/src/lib/utils/tailwind.ts +0 -41
  188. package/src/lib/utils/utils.ts +0 -90
  189. package/src/lib/utils/validation.ts +0 -189
  190. package/src/lib/utils/vue.ts +0 -25
  191. package/tsconfig.config.json +0 -9
  192. package/tsconfig.demo.json +0 -19
  193. package/tsconfig.json +0 -16
  194. package/tsconfig.lib.json +0 -19
  195. package/tsconfig.vitest.json +0 -8
  196. package/vite.config.ts +0 -30
  197. /package/{src/lib → lib}/components/NInput.css +0 -0
  198. /package/{src/lib → lib}/components/NLoadingIndicator.css +0 -0
  199. /package/{src/lib → lib}/i18n/de/vue-collection.json +0 -0
  200. /package/{src/lib → lib}/i18n/en/vue-collection.json +0 -0
@@ -1,53 +0,0 @@
1
- import { createComponent } from '../utils/component'
2
- import { external } from '../utils/validation'
3
- import { computed, Suspense } from 'vue'
4
- import NValInput, { nValInputProps } from './NValInput'
5
- import { trsl } from '../i18n'
6
-
7
- export const nInputPhoneProps = nValInputProps
8
-
9
- /**
10
- * The `NInputPhone` autoformats phone numbers and checks if they are valid.
11
- */
12
- const Component = createComponent('NInputPhoneSuspended', nInputPhoneProps, props => {
13
- // Async components have to be wrapped in a suspense component.
14
- return () => (
15
- <Suspense>
16
- <NPhoneInput {...props} />
17
- </Suspense>
18
- )
19
- })
20
-
21
- export { Component as NInputPhone, Component as default }
22
-
23
- const NPhoneInput = createComponent('NInputPhone', nInputPhoneProps, async props => {
24
- // import dynamically for better codesplitting as the library is pretty large
25
- const { parsePhoneNumber } = await import('awesome-phonenumber')
26
- const DEFAULT_COUNTRY_CODE = 'CH'
27
-
28
- const formattedToPlain = (number: string) =>
29
- parsePhoneNumber(number, { regionCode: DEFAULT_COUNTRY_CODE }).number?.e164
30
- const plainToFormatted = (number: string) =>
31
- parsePhoneNumber(number, { regionCode: DEFAULT_COUNTRY_CODE }).number?.international
32
-
33
- const onUpdateValue = (newValue: string) => {
34
- const plain = formattedToPlain(newValue)
35
- props.onUpdateValue?.(plain || newValue)
36
- }
37
-
38
- const value = computed(() => {
39
- const formatted = plainToFormatted(props.value || '')
40
- return formatted || props.value
41
- })
42
-
43
- const isValid = computed(() => parsePhoneNumber(props.value || '').valid)
44
-
45
- return () => (
46
- <NValInput
47
- {...{ ...props, onUpdateValue }}
48
- value={value.value}
49
- rules={external(isValid.value, trsl('vue-collection.validation.rules.phone'))}
50
- type="tel"
51
- />
52
- )
53
- })
@@ -1,126 +0,0 @@
1
- import { createComponentWithSlots } from '../utils/component'
2
- import { Id, type Identifiable } from '../utils/identifiable'
3
- import { option } from '../utils/validation'
4
- import { vModelForRef } from '../utils/vModel'
5
- import { watchRef } from '../utils/vue'
6
- import { computed, ref, watch, type PropType } from 'vue'
7
- import { nInputProps } from './NInput'
8
- import NSuggestionList, { nSuggestionListProps } from './NSuggestionList'
9
- import NValInput, { nValInputProps, type NValInputExposed } from './NValInput'
10
- import type { AnyObject } from '../utils/utils'
11
-
12
- export const nInputSelectProps = {
13
- ...nInputProps,
14
- /**
15
- * The id of the currently selected option of this input.
16
- */
17
- value: String,
18
- /**
19
- * This is called with the newly selected id when the selection has changed.
20
- * This happens, when an item from the suggestion list is selected or the
21
- * input matches a selection option exactly.
22
- * If no id is selected, the empty string is passed, in order to
23
- * match the API of all other inputs who never pass `undefined`.
24
- */
25
- onUpdateValue: Function as PropType<(newValue: string) => void>,
26
- /**
27
- * The options which are allowed and suggested for this input.
28
- * The options are filtered based on the user input.
29
- */
30
- options: {
31
- type: Array as PropType<InputSelectOption[]>,
32
- default: () => [],
33
- },
34
- /**
35
- * @see {@link nValInputProps.optional}
36
- */
37
- optional: nValInputProps.optional,
38
- /**
39
- * @see {@link nValInputProps.form}
40
- */
41
- form: nValInputProps.form,
42
- /**
43
- * @see {@link nValInputProps.error}
44
- */
45
- error: nValInputProps.error,
46
- /**
47
- * @see {@link nValInputProps.errorMessage}
48
- */
49
- errorMessage: nValInputProps.errorMessage,
50
- /**
51
- * If set to `true` the list is hidden even if there are still matching items in the list.
52
- */
53
- hideList: nSuggestionListProps.hideList,
54
- /**
55
- * @see {@link nSuggestionListProps.maxItems}
56
- */
57
- maxItems: nSuggestionListProps.maxItems,
58
- /**
59
- * @see {@link nSuggestionListProps.listItem}
60
- */
61
- listItem: nSuggestionListProps.listItem,
62
- } as const
63
-
64
- export type InputSelectOption = Identifiable & { label: string } & AnyObject
65
-
66
- /**
67
- * The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
68
- * The user is forced to use a value from the specified options of the input.
69
- * While they type, the list of options is shown to them and filtered based on their input.
70
- */
71
- const Component = createComponentWithSlots('NInputSelect', nInputSelectProps, ['listItem'], props => {
72
- const inputRef = ref<NValInputExposed>()
73
-
74
- const inputValue = ref('')
75
- watch(
76
- () => props.value,
77
- newValue => {
78
- if (newValue) {
79
- const chosenOption = Id.find(props.options, newValue)
80
- if (chosenOption) inputValue.value = chosenOption.label
81
- }
82
- },
83
- { immediate: true }
84
- )
85
-
86
- const filteredOptions = computed(() =>
87
- props.options.filter(option => option.label.includes(inputValue.value || ''))
88
- )
89
-
90
- const matchedOption = computed(() => {
91
- const matches = props.options.filter(option => option.label === inputValue.value)
92
- return matches.length > 0 ? matches[0] : null
93
- })
94
- watchRef(matchedOption, newOption => props.onUpdateValue?.(newOption?.id || ''))
95
-
96
- return () => (
97
- <NSuggestionList
98
- items={filteredOptions.value}
99
- onSelect={props.onUpdateValue}
100
- inputValue={inputValue.value}
101
- hideList={props.hideList || matchedOption.value != null || filteredOptions.value.length == 0}
102
- maxItems={props.maxItems}
103
- listItem={props.listItem}
104
- input={({ onFocus, onBlur }) => (
105
- <NValInput
106
- ref={inputRef}
107
- {...{ ...props, ...vModelForRef(inputValue) }}
108
- rules={option(props.options.map(opt => opt.label))}
109
- onFocus={() => {
110
- onFocus()
111
- props.onFocus?.()
112
- }}
113
- onBlur={onBlur}
114
- disableBlurValidation
115
- />
116
- )}
117
- onRequestInputFocus={() => inputRef.value?.focus()}
118
- onRealBlur={() => {
119
- props.onBlur?.()
120
- inputRef?.value?.validate()
121
- }}
122
- />
123
- )
124
- })
125
-
126
- export { Component as NInputSelect, Component as default }
@@ -1,80 +0,0 @@
1
- import { createComponent } from '../utils/component'
2
- import { Id } from '../utils/identifiable'
3
- import { computed, ref, type PropType } from 'vue'
4
- import NSuggestionList, { nSuggestionListProps } from './NSuggestionList'
5
- import NValInput, { nValInputProps, type NValInputExposed } from './NValInput'
6
-
7
- export const nInputSuggestionProps = {
8
- ...nValInputProps,
9
- /**
10
- * If set to `true` the list is hidden even if there are still matching items in the list.
11
- */
12
- hideList: nSuggestionListProps.hideList,
13
- /**
14
- * @see {@link nSuggestionListProps.maxItems}
15
- */
16
- maxItems: nSuggestionListProps.maxItems,
17
- /**
18
- * The suggestions which are shown to the user for this input.
19
- * The suggestions are filtered based on the user input.
20
- */
21
- suggestions: {
22
- type: Array as PropType<string[]>,
23
- default: () => [],
24
- },
25
- } as const
26
-
27
- /**
28
- * `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
29
- * which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
30
- */
31
- const Component = createComponent('NInputSuggestion', nInputSuggestionProps, props => {
32
- const suggestionItems = computed(() =>
33
- props.suggestions
34
- .filter(suggestion => suggestion.includes(props.value || ''))
35
- .map((value, index) => ({
36
- id: index.toString(),
37
- label: value,
38
- }))
39
- )
40
-
41
- const select = (id: string) => props.onUpdateValue?.(Id.find(suggestionItems.value, id)?.label || '')
42
-
43
- const hideList = computed(
44
- () =>
45
- props.hideList ||
46
- suggestionItems.value.length == 0 ||
47
- suggestionItems.value.filter(suggestion => suggestion.label !== props.value).length == 0
48
- )
49
-
50
- const inputRef = ref<NValInputExposed>()
51
-
52
- return () => (
53
- <NSuggestionList
54
- items={suggestionItems.value}
55
- onSelect={id => select(id)}
56
- inputValue={props.value || ''}
57
- hideList={hideList.value}
58
- maxItems={props.maxItems}
59
- input={({ onFocus, onBlur }) => (
60
- <NValInput
61
- ref={inputRef}
62
- {...props}
63
- onFocus={() => {
64
- onFocus()
65
- props.onFocus?.()
66
- }}
67
- onBlur={onBlur}
68
- disableBlurValidation
69
- />
70
- )}
71
- onRequestInputFocus={() => inputRef.value?.focus()}
72
- onRealBlur={() => {
73
- props.onBlur?.()
74
- inputRef?.value?.validate()
75
- }}
76
- />
77
- )
78
- })
79
-
80
- export { Component as NInputSuggestion, Component as default }
@@ -1,82 +0,0 @@
1
- import { createComponent } from '../utils/component'
2
- import type { TWTextSize } from '../utils/tailwind'
3
- import { computed, type PropType } from 'vue'
4
- import { RouterLink, type RouteLocationRaw } from 'vue-router'
5
-
6
- export const nLinkProps = {
7
- /**
8
- * The text of the link. Can also be set in the default slot.
9
- */
10
- text: String,
11
- /**
12
- * The route of the link. If this is set,
13
- * the link becomes a {@link RouterLink} and does not emit the `onClick` event.
14
- */
15
- route: [Object, String] as PropType<RouteLocationRaw>,
16
- /**
17
- * The color of the link.
18
- */
19
- color: {
20
- type: String,
21
- default: 'primary',
22
- },
23
- /**
24
- * The text size, a standard tailwind text-size class.
25
- */
26
- textSize: String as PropType<TWTextSize>,
27
- /**
28
- * The shade of the link.
29
- */
30
- shade: {
31
- type: Number,
32
- default: 500,
33
- },
34
-
35
- /**
36
- * If set to `true` the link is disabled and no interaction is possible.
37
- * Note: If the `route` prop is set, the link will still be clickable, because it becomes a {@link RouterLink}.
38
- */
39
- disabled: Boolean,
40
- /**
41
- * This is called when the link is clicked but only, if the `route` prop is not set.
42
- * If the `route` prop is not set, the link will act as a regular button.
43
- */
44
- onClick: Function as PropType<() => void>,
45
- } as const
46
-
47
- /**
48
- * The `NLink` is a styled text which can be used as a {@link RouterLink} or a regular button.
49
- */
50
- const Component = createComponent('NLink', nLinkProps, (props, { slots }) => {
51
- const hoverShade = computed(() => {
52
- const shade = props.shade
53
- if (shade <= 500) return shade + 100
54
- else return shade - 200
55
- })
56
-
57
- const classes = computed(() => [
58
- 'font-medium focus:outline-hidden focus-visible:ring-2 rounded-xs ring-offset-2 hover:underline text-left cursor-pointer',
59
- `${props.textSize} text-${props.color}-${props.shade} hover:text-${props.color}-${hoverShade.value} focus-visible:ring-${props.color}-${props.shade}`,
60
- ])
61
- const disabledClasses = computed(() => [
62
- 'font-medium text-left cursor-not-allowed',
63
- `${props.textSize} text-${props.color}-200`,
64
- ])
65
-
66
- return () =>
67
- props.route ? (
68
- <RouterLink to={props.route} class={classes.value}>
69
- {slots.default?.() || props.text}
70
- </RouterLink>
71
- ) : (
72
- <button
73
- onClick={props.onClick}
74
- class={props.disabled ? disabledClasses.value : classes.value}
75
- disabled={props.disabled}
76
- >
77
- {slots.default?.() || props.text}
78
- </button>
79
- )
80
- })
81
-
82
- export { Component as NLink, Component as default }
@@ -1,67 +0,0 @@
1
- import { createComponent } from '../utils/component'
2
- import type { PropType } from 'vue'
3
-
4
- export type ListItem = {
5
- /**
6
- * The title of the item. Accepts either string or a function returning a JSX element.
7
- */
8
- title: string | (() => JSX.Element)
9
- /**
10
- * The text of the item. Accepts either string or a function returning a JSX element.
11
- */
12
- text?: string | (() => JSX.Element)
13
- }
14
-
15
- export const nListProps = {
16
- /**
17
- * The items which are displayed in the list.
18
- */
19
- items: {
20
- type: Array as PropType<ListItem[]>,
21
- default: () => [],
22
- },
23
- /**
24
- * Adds the classes to all title elements (on the left side).
25
- */
26
- titleClass: String,
27
- /**
28
- * Adds the classes to all text elements (on the right side).
29
- */
30
- textClass: String,
31
- /**
32
- * Adds the classes to each row.
33
- */
34
- rowClass: String,
35
- } as const
36
-
37
- /**
38
- * The `NList` displays key-value data in an appealing way.
39
- */
40
- const Component = createComponent('NList', nListProps, props => {
41
- return () => (
42
- <dl>
43
- {props.items.map((item, index) => (
44
- <div
45
- key={index}
46
- class={[
47
- 'py-5 px-4 sm:grid sm:grid-cols-3 sm:gap-4',
48
- index % 2 === 1 ? 'bg-white' : 'bg-default-50',
49
- props.rowClass,
50
- ]}
51
- >
52
- <dt class={`text-sm font-medium text-default-500 ${props.titleClass}`}>
53
- {buildElement(item.title)}
54
- </dt>
55
- <dd class={`mt-1 text-sm sm:mt-0 sm:col-span-2 ${props.textClass}`}>{buildElement(item.text)}</dd>
56
- </div>
57
- ))}
58
- </dl>
59
- )
60
- })
61
-
62
- export { Component as NList, Component as default }
63
-
64
- function buildElement(element: string | undefined | (() => JSX.Element)): JSX.Element {
65
- if (typeof element === 'function') return element()
66
- else return <>{element}</>
67
- }
@@ -1,63 +0,0 @@
1
- import { createComponent } from '../utils/component'
2
- import { computed, useCssVars } from 'vue'
3
- import './NLoadingIndicator.css'
4
-
5
- export const nLoadingIndicator = {
6
- /**
7
- * The color of the loading-indicator.
8
- */
9
- color: {
10
- type: String,
11
- default: 'primary',
12
- },
13
- /**
14
- * The shade of the loading-indicator.
15
- */
16
- shade: {
17
- type: Number,
18
- default: 400,
19
- },
20
- /**
21
- * The height of the loading-indicator in px.
22
- */
23
- size: {
24
- type: Number,
25
- default: 10,
26
- },
27
- } as const
28
-
29
- /**
30
- * The `NLoadingIndicator` is a styled loading indicator.
31
- */
32
- const Component = createComponent('NLoadingIndicator', nLoadingIndicator, props => {
33
- const gap = computed(() => (props.size / 13) * 24)
34
-
35
- const totalWidth = computed(() => gap.value * 2 + props.size)
36
-
37
- useCssVars(() => ({
38
- 'n-loading-indicator-gap': `${gap.value}px`,
39
- }))
40
-
41
- return () => (
42
- <div class="lds-ellipsis" style={`height:${props.size}px;width:${totalWidth.value}px`}>
43
- <div
44
- class={`bg-${props.color}-${props.shade}`}
45
- style={`height:${props.size}px;width:${props.size}px;left:0px`}
46
- />
47
- <div
48
- class={`bg-${props.color}-${props.shade}`}
49
- style={`height:${props.size}px;width:${props.size}px;left:0px`}
50
- />
51
- <div
52
- class={`bg-${props.color}-${props.shade}`}
53
- style={`height:${props.size}px;width:${props.size}px;left:${gap.value}px`}
54
- />
55
- <div
56
- class={`bg-${props.color}-${props.shade}`}
57
- style={`height:${props.size}px;width:${props.size}px;left:${2 * gap.value}px`}
58
- />
59
- </div>
60
- )
61
- })
62
-
63
- export { Component as NLoadingIndicator, Component as default }