@histoire/controls 0.10.7 → 0.11.1

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 (51) hide show
  1. package/dist/components/HstCopyIcon.vue.d.ts +1 -1
  2. package/dist/components/HstWrapper.vue.d.ts +16 -3
  3. package/dist/components/button/HstButton.story.vue.d.ts +2 -0
  4. package/dist/components/button/HstButton.vue.d.ts +15 -0
  5. package/dist/components/button/HstButtonGroup.story.vue.d.ts +2 -0
  6. package/dist/components/button/HstButtonGroup.vue.d.ts +24 -0
  7. package/dist/components/checkbox/HstCheckbox.story.vue.d.ts +1 -1
  8. package/dist/components/checkbox/HstCheckboxList.story.vue.d.ts +2 -0
  9. package/dist/components/checkbox/HstCheckboxList.vue.d.ts +24 -0
  10. package/dist/components/checkbox/HstSimpleCheckbox.story.vue.d.ts +2 -0
  11. package/dist/components/checkbox/HstSimpleCheckbox.vue.d.ts +21 -0
  12. package/dist/components/design-tokens/HstColorShades.story.vue.d.ts +1 -1
  13. package/dist/components/design-tokens/HstColorShades.vue.d.ts +1 -1
  14. package/dist/components/design-tokens/HstTokenGrid.story.vue.d.ts +1 -1
  15. package/dist/components/design-tokens/HstTokenGrid.vue.d.ts +1 -1
  16. package/dist/components/design-tokens/HstTokenList.story.vue.d.ts +1 -1
  17. package/dist/components/design-tokens/HstTokenList.vue.d.ts +1 -1
  18. package/dist/components/number/HstNumber.story.vue.d.ts +1 -1
  19. package/dist/components/radio/HstRadio.story.vue.d.ts +1 -1
  20. package/dist/components/select/HstSelect.story.vue.d.ts +1 -1
  21. package/dist/components/slider/HstSlider.story.vue.d.ts +1 -1
  22. package/dist/components/text/HstText.story.vue.d.ts +1 -1
  23. package/dist/components/textarea/HstTextarea.story.vue.d.ts +1 -1
  24. package/dist/index.d.ts +143 -8
  25. package/dist/index.es.js +706 -734
  26. package/dist/style-standalone.css +102 -70
  27. package/package.json +5 -4
  28. package/src/components/HstWrapper.vue +12 -4
  29. package/src/components/button/HstButton.story.vue +30 -0
  30. package/src/components/button/HstButton.vue +26 -0
  31. package/src/components/button/HstButtonGroup.story.vue +51 -0
  32. package/src/components/button/HstButtonGroup.vue +64 -0
  33. package/src/components/checkbox/HstCheckbox.story.vue +5 -1
  34. package/src/components/checkbox/HstCheckbox.vue +4 -50
  35. package/src/components/checkbox/HstCheckboxList.story.vue +49 -0
  36. package/src/components/checkbox/HstCheckboxList.vue +79 -0
  37. package/src/components/checkbox/HstSimpleCheckbox.story.vue +28 -0
  38. package/src/components/checkbox/HstSimpleCheckbox.vue +82 -0
  39. package/src/components/checkbox/__snapshots__/HstCheckbox.test.ts.snap +6 -6
  40. package/src/components/design-tokens/HstColorShades.story.vue +2 -1
  41. package/src/components/design-tokens/HstTokenGrid.story.vue +2 -1
  42. package/src/components/design-tokens/HstTokenList.story.vue +2 -1
  43. package/src/components/number/HstNumber.story.vue +1 -0
  44. package/src/components/number/HstNumber.vue +1 -2
  45. package/src/components/radio/HstRadio.story.vue +5 -1
  46. package/src/components/select/HstSelect.story.vue +1 -0
  47. package/src/components/slider/HstSlider.story.vue +2 -0
  48. package/src/components/text/HstText.story.vue +1 -0
  49. package/src/components/textarea/HstTextarea.story.vue +4 -1
  50. package/src/index.ts +11 -0
  51. package/vite.config.ts +1 -1
@@ -0,0 +1,79 @@
1
+ <script lang="ts">
2
+ export default {
3
+ name: 'HstCheckboxList',
4
+ }
5
+ </script>
6
+
7
+ <script lang="ts" setup>
8
+ import { computed, ComputedRef } from 'vue'
9
+ import HstWrapper from '../HstWrapper.vue'
10
+ import { HstControlOption } from '../../types'
11
+ import HstSimpleCheckbox from './HstSimpleCheckbox.vue'
12
+
13
+ const props = defineProps<{
14
+ title?: string
15
+ modelValue: Array<string>
16
+ options: HstControlOption[]
17
+ }>()
18
+
19
+ const formattedOptions: ComputedRef<Record<string, string>> = computed(() => {
20
+ if (Array.isArray(props.options)) {
21
+ return Object.fromEntries(props.options.map((value: string | HstControlOption) => {
22
+ if (typeof value === 'string') {
23
+ return [value, value]
24
+ } else {
25
+ return [value.value, value.label]
26
+ }
27
+ }))
28
+ }
29
+ return props.options
30
+ })
31
+
32
+ const emits = defineEmits<{
33
+ (e: 'update:modelValue', value: Array<string>): void
34
+ }>()
35
+
36
+ function toggleOption (value: string) {
37
+ if (props.modelValue.includes(value)) {
38
+ emits('update:modelValue', props.modelValue.filter(element => element !== value))
39
+ } else {
40
+ emits('update:modelValue', [...props.modelValue, value])
41
+ }
42
+ }
43
+ </script>
44
+
45
+ <template>
46
+ <HstWrapper
47
+ role="group"
48
+ :title="title"
49
+ class="htw-cursor-text"
50
+ :class="$attrs.class"
51
+ :style="$attrs.style"
52
+ >
53
+ <div class="-htw-my-1">
54
+ <template
55
+ v-for="( label, value ) in formattedOptions"
56
+ :key="value"
57
+ >
58
+ <label
59
+ tabindex="0"
60
+ :for="`${value}-radio`"
61
+ class="htw-cursor-pointer htw-flex htw-items-center htw-relative htw-py-1 htw-group"
62
+ @keydown.enter.prevent="toggleOption(value)"
63
+ @keydown.space.prevent="toggleOption(value)"
64
+ @click="toggleOption(value)"
65
+ >
66
+ <HstSimpleCheckbox
67
+ :model-value="modelValue.includes(value)"
68
+ class="htw-mr-2"
69
+ />
70
+ {{ label }}
71
+ </label>
72
+ </template>
73
+ </div>
74
+
75
+ <template #actions>
76
+ <slot name="actions" />
77
+ </template>
78
+ </HstWrapper>
79
+ </template>
@@ -0,0 +1,28 @@
1
+ <script lang="ts" setup>
2
+ import HstSimpleCheckbox from './HstSimpleCheckbox.vue'
3
+
4
+ function initState () {
5
+ return {
6
+ checked: true,
7
+ }
8
+ }
9
+ </script>
10
+
11
+ <template>
12
+ <Story
13
+ title="internals/HstSimpleCheckbox"
14
+ :layout="{ type: 'single', iframe: false }"
15
+ >
16
+ <Variant
17
+ title="playground"
18
+ :init-state="initState"
19
+ >
20
+ <template #default="{ state }">
21
+ <HstSimpleCheckbox
22
+ v-model="state.checked"
23
+ with-toggle
24
+ />
25
+ </template>
26
+ </Variant>
27
+ </Story>
28
+ </template>
@@ -0,0 +1,82 @@
1
+ <script lang="ts">
2
+ export default {
3
+ name: 'HstSimpleCheckbox',
4
+ }
5
+ </script>
6
+
7
+ <script setup lang="ts">
8
+ import { computed, ref, watch } from 'vue'
9
+
10
+ const props = defineProps<{
11
+ modelValue: boolean
12
+ withToggle?: boolean
13
+ }>()
14
+
15
+ const emits = defineEmits({
16
+ 'update:modelValue': (newValue: boolean) => true,
17
+ })
18
+
19
+ function toggle () {
20
+ if (!props.withToggle) {
21
+ return
22
+ }
23
+
24
+ emits('update:modelValue', !props.modelValue)
25
+ }
26
+
27
+ watch(() => props.modelValue, () => {
28
+ animationEnabled.value = true
29
+ })
30
+
31
+ // SVG check
32
+
33
+ const path = ref<SVGPathElement>()
34
+ const dasharray = ref(0)
35
+ const progress = computed(() => props.modelValue ? 1 : 0)
36
+ const dashoffset = computed(() => (1 - progress.value) * dasharray.value)
37
+
38
+ // animationEnabled prevents the animation from triggering on mounted
39
+ const animationEnabled = ref(false)
40
+
41
+ watch(path, () => {
42
+ dasharray.value = path.value.getTotalLength?.() ?? 21.21
43
+ })
44
+ </script>
45
+
46
+ <template>
47
+ <div
48
+ class="htw-group htw-text-white htw-w-[16px] htw-h-[16px] htw-relative"
49
+ :class="{'htw-cursor-pointer': withToggle}"
50
+ @click="toggle"
51
+ >
52
+ <div
53
+ class="htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out group-hover:htw-border-primary-500 group-hover:dark:htw-border-primary-500"
54
+ :class="[
55
+ modelValue
56
+ ? 'htw-border-primary-500 htw-border-8'
57
+ : 'htw-border-black/25 dark:htw-border-white/25 htw-delay-150',
58
+ ]"
59
+ />
60
+ <svg
61
+ width="16"
62
+ height="16"
63
+ viewBox="0 0 24 24"
64
+ class="htw-relative htw-z-10"
65
+ >
66
+ <path
67
+ ref="path"
68
+ d="m 4 12 l 5 5 l 10 -10"
69
+ fill="none"
70
+ class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out"
71
+ :class="[
72
+ animationEnabled ? 'htw-transition-all' : 'htw-transition-none',
73
+ {
74
+ 'htw-delay-150': modelValue,
75
+ },
76
+ ]"
77
+ :stroke-dasharray="dasharray"
78
+ :stroke-dashoffset="dashoffset"
79
+ />
80
+ </svg>
81
+ </div>
82
+ </template>
@@ -11,8 +11,8 @@ exports[`HstCheckbox toggle to checked 1`] = `
11
11
  </span>
12
12
  <span class="htw-grow htw-flex htw-items-center htw-gap-1">
13
13
  <span class="htw-block htw-grow">
14
- <div class="htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
15
- <div class="htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out htw-border-black/25 dark:htw-border-white/25 htw-delay-150">
14
+ <div class="htw-group htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
15
+ <div class="htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out group-hover:htw-border-primary-500 group-hover:dark:htw-border-primary-500 htw-border-black/25 dark:htw-border-white/25 htw-delay-150">
16
16
  </div>
17
17
  <svg
18
18
  width="16"
@@ -23,7 +23,7 @@ exports[`HstCheckbox toggle to checked 1`] = `
23
23
  <path
24
24
  d="m 4 12 l 5 5 l 10 -10"
25
25
  fill="none"
26
- class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out htw-transition-all"
26
+ class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out htw-transition-none"
27
27
  stroke-dasharray="21.21"
28
28
  stroke-dashoffset="21.21"
29
29
  >
@@ -46,8 +46,8 @@ exports[`HstCheckbox toggle to unchecked 1`] = `
46
46
  </span>
47
47
  <span class="htw-grow htw-flex htw-items-center htw-gap-1">
48
48
  <span class="htw-block htw-grow">
49
- <div class="htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
50
- <div class="htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out htw-border-primary-500 htw-border-8">
49
+ <div class="htw-group htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
50
+ <div class="htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out group-hover:htw-border-primary-500 group-hover:dark:htw-border-primary-500 htw-border-primary-500 htw-border-8">
51
51
  </div>
52
52
  <svg
53
53
  width="16"
@@ -58,7 +58,7 @@ exports[`HstCheckbox toggle to unchecked 1`] = `
58
58
  <path
59
59
  d="m 4 12 l 5 5 l 10 -10"
60
60
  fill="none"
61
- class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out htw-transition-all htw-delay-150"
61
+ class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out htw-transition-none htw-delay-150"
62
62
  stroke-dasharray="21.21"
63
63
  stroke-dashoffset="0"
64
64
  >
@@ -286,7 +286,8 @@ const colors = {
286
286
 
287
287
  <template>
288
288
  <Story
289
- title="design-tokens/HstColorShades"
289
+ title="HstColorShades"
290
+ group="design-system"
290
291
  responsive-disabled
291
292
  >
292
293
  <Variant title="default">
@@ -14,7 +14,8 @@ const tokens = {
14
14
 
15
15
  <template>
16
16
  <Story
17
- title="design-tokens/HstTokenGrid"
17
+ title="HstTokenGrid"
18
+ group="design-system"
18
19
  responsive-disabled
19
20
  >
20
21
  <Variant title="default">
@@ -55,7 +55,8 @@ const tokens = {
55
55
 
56
56
  <template>
57
57
  <Story
58
- title="design-tokens/HstTokenList"
58
+ title="HstTokenList"
59
+ group="design-system"
59
60
  responsive-disabled
60
61
  >
61
62
  <Variant title="default">
@@ -12,6 +12,7 @@ function initState () {
12
12
  <template>
13
13
  <Story
14
14
  title="HstNumber"
15
+ group="controls"
15
16
  >
16
17
  <Variant
17
18
  title="default"
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  export default {
3
3
  name: 'HstNumber',
4
-
5
4
  inheritAttrs: false,
6
5
  }
7
6
  </script>
@@ -86,7 +85,7 @@ onUnmounted(() => {
86
85
  :class="{
87
86
  'htw-select-none': isDragging,
88
87
  }"
89
- class="htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-pl-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-cursor-ew-resize"
88
+ class="htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-pl-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-cursor-ew-resize htw-box-border"
90
89
  >
91
90
 
92
91
  <template #actions>
@@ -22,7 +22,11 @@ function initState () {
22
22
  </script>
23
23
 
24
24
  <template>
25
- <Story title="HstRadio">
25
+ <Story
26
+ title="HstRadio"
27
+ group="controls"
28
+ :layout="{ type: 'single', iframe: false }"
29
+ >
26
30
  <Variant
27
31
  title="playground"
28
32
  :init-state="initState"
@@ -25,6 +25,7 @@ function initState () {
25
25
  <template>
26
26
  <Story
27
27
  title="HstSelect"
28
+ group="controls"
28
29
  :layout="{
29
30
  type: 'grid',
30
31
  width: '100%',
@@ -13,6 +13,8 @@ const state = reactive({
13
13
  <template>
14
14
  <Story
15
15
  title="HstSlider"
16
+ group="controls"
17
+ :layout="{ type: 'single', iframe: false }"
16
18
  >
17
19
  <HstSlider
18
20
  v-model="state.value"
@@ -12,6 +12,7 @@ function initState () {
12
12
  <template>
13
13
  <Story
14
14
  title="HstText"
15
+ group="controls"
15
16
  :layout="{
16
17
  type: 'grid',
17
18
  width: '100%',
@@ -9,7 +9,10 @@ function initState () {
9
9
  </script>
10
10
 
11
11
  <template>
12
- <Story title="HstTextarea">
12
+ <Story
13
+ title="HstTextarea"
14
+ group="controls"
15
+ >
13
16
  <Variant
14
17
  title="default"
15
18
  :init-state="initState"
package/src/index.ts CHANGED
@@ -1,4 +1,7 @@
1
+ import HstButtonVue from './components/button/HstButton.vue'
2
+ import HstButtonGroupVue from './components/button/HstButtonGroup.vue'
1
3
  import HstCheckboxVue from './components/checkbox/HstCheckbox.vue'
4
+ import HstCheckboxListVue from './components/checkbox/HstCheckboxList.vue'
2
5
  import HstTextVue from './components/text/HstText.vue'
3
6
  import HstNumberVue from './components/number/HstNumber.vue'
4
7
  import HstSliderVue from './components/slider/HstSlider.vue'
@@ -10,7 +13,10 @@ import HstTokenGridVue from './components/design-tokens/HstTokenGrid.vue'
10
13
  import HstCopyIconVue from './components/HstCopyIcon.vue'
11
14
  import HstRadioVue from './components/radio/HstRadio.vue'
12
15
 
16
+ export const HstButton = HstButtonVue
17
+ export const HstButtonGroup = HstButtonGroupVue
13
18
  export const HstCheckbox = HstCheckboxVue
19
+ export const HstCheckboxList = HstCheckboxListVue
14
20
  export const HstText = HstTextVue
15
21
  export const HstNumber = HstNumberVue
16
22
  export const HstSlider = HstSliderVue
@@ -23,7 +29,10 @@ export const HstCopyIcon = HstCopyIconVue
23
29
  export const HstRadio = HstRadioVue
24
30
 
25
31
  export const components = {
32
+ HstButton,
33
+ HstButtonGroup,
26
34
  HstCheckbox,
35
+ HstCheckboxList,
27
36
  HstText,
28
37
  HstNumber,
29
38
  HstSlider,
@@ -35,3 +44,5 @@ export const components = {
35
44
  HstCopyIcon,
36
45
  HstRadio,
37
46
  }
47
+
48
+ export * from './types'
package/vite.config.ts CHANGED
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
  formats: [
27
27
  'es',
28
28
  ],
29
- fileName: 'index',
29
+ fileName: 'index.es',
30
30
  },
31
31
 
32
32
  rollupOptions: {