@poveste/controls 0.6.1 → 0.7.0

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 (49) hide show
  1. package/package.json +16 -3
  2. package/postcss.config.cjs +0 -7
  3. package/src/components/HstCopyIcon.story.vue +0 -26
  4. package/src/components/HstCopyIcon.vue +0 -38
  5. package/src/components/HstWrapper.vue +0 -41
  6. package/src/components/button/HstButton.story.vue +0 -30
  7. package/src/components/button/HstButton.vue +0 -26
  8. package/src/components/button/HstButtonGroup.story.vue +0 -79
  9. package/src/components/button/HstButtonGroup.vue +0 -71
  10. package/src/components/checkbox/HstCheckbox.spec.ts +0 -28
  11. package/src/components/checkbox/HstCheckbox.story.vue +0 -47
  12. package/src/components/checkbox/HstCheckbox.vue +0 -56
  13. package/src/components/checkbox/HstCheckboxList.story.vue +0 -49
  14. package/src/components/checkbox/HstCheckboxList.vue +0 -82
  15. package/src/components/checkbox/HstSimpleCheckbox.story.vue +0 -28
  16. package/src/components/checkbox/HstSimpleCheckbox.vue +0 -82
  17. package/src/components/checkbox/__snapshots__/HstCheckbox.spec.ts.snap +0 -5
  18. package/src/components/colorselect/HstColorSelect.story.vue +0 -28
  19. package/src/components/colorselect/HstColorSelect.vue +0 -89
  20. package/src/components/design-tokens/HstColorShades.story.vue +0 -392
  21. package/src/components/design-tokens/HstColorShades.vue +0 -101
  22. package/src/components/design-tokens/HstTokenGrid.story.vue +0 -36
  23. package/src/components/design-tokens/HstTokenGrid.vue +0 -88
  24. package/src/components/design-tokens/HstTokenList.story.vue +0 -81
  25. package/src/components/design-tokens/HstTokenList.vue +0 -62
  26. package/src/components/json/HstJson.story.vue +0 -41
  27. package/src/components/json/HstJson.vue +0 -167
  28. package/src/components/json/serialize.spec.ts +0 -85
  29. package/src/components/json/serialize.ts +0 -54
  30. package/src/components/number/HstNumber.story.vue +0 -42
  31. package/src/components/number/HstNumber.vue +0 -95
  32. package/src/components/radio/HstRadio.story.vue +0 -51
  33. package/src/components/radio/HstRadio.vue +0 -109
  34. package/src/components/select/CustomSelect.vue +0 -126
  35. package/src/components/select/HstSelect.story.vue +0 -161
  36. package/src/components/select/HstSelect.vue +0 -40
  37. package/src/components/slider/HstSlider.story.vue +0 -37
  38. package/src/components/slider/HstSlider.vue +0 -106
  39. package/src/components/text/HstText.story.vue +0 -63
  40. package/src/components/text/HstText.vue +0 -44
  41. package/src/components/textarea/HstTextarea.story.vue +0 -35
  42. package/src/components/textarea/HstTextarea.vue +0 -44
  43. package/src/end.d.ts +0 -8
  44. package/src/index.ts +0 -54
  45. package/src/style/main.css +0 -65
  46. package/src/types.ts +0 -4
  47. package/src/utils.ts +0 -12
  48. package/tsconfig.json +0 -53
  49. package/vite.config.ts +0 -46
@@ -1,106 +0,0 @@
1
- <script lang="ts">
2
- export default {
3
- name: 'HstSlider',
4
- inheritAttrs: false,
5
- }
6
- </script>
7
-
8
- <script lang="ts" setup>
9
- import type { CSSProperties } from 'vue'
10
- import { VTooltip as vTooltip } from 'floating-vue'
11
- import { computed, ref } from 'vue'
12
- import HstWrapper from '../HstWrapper.vue'
13
-
14
- const props = defineProps<{
15
- title?: string
16
- modelValue?: number | null
17
- min: number
18
- max: number
19
- }>()
20
-
21
- const emit = defineEmits({
22
- 'update:modelValue': (newValue: number) => true,
23
- })
24
-
25
- const showTooltip = ref(false)
26
- const input = ref<HTMLInputElement>(null)
27
-
28
- const numberModel = computed({
29
- get: () => props.modelValue,
30
- set: (value) => {
31
- emit('update:modelValue', value)
32
- },
33
- })
34
-
35
- const percentage = computed(() => {
36
- return (props.modelValue - props.min) / (props.max - props.min)
37
- })
38
-
39
- const tooltipStyle = computed<CSSProperties>(() => {
40
- const gap = 8
41
- if (input.value) {
42
- const position = gap + ((input.value.clientWidth - 2 * gap) * percentage.value)
43
- return {
44
- left: `${position}px`,
45
- }
46
- }
47
- return {}
48
- })
49
- </script>
50
-
51
- <template>
52
- <HstWrapper
53
- class="poveste-slider items-center"
54
- :title="title"
55
- :class="$attrs.class"
56
- :style="$attrs.style"
57
- >
58
- <div class="relative w-full flex items-center">
59
- <div class="absolute inset-0 flex items-center">
60
- <div class="border border-black/25 dark:border-white/25 h-1 w-full rounded-full" />
61
- </div>
62
- <input
63
- ref="input"
64
- v-model.number="numberModel"
65
- class="range-input appearance-none border-0 bg-transparent cursor-pointer relative w-full m-0 text-gray-700"
66
- type="range"
67
- v-bind="{ ...$attrs, class: null, style: null, min, max }"
68
- @mouseover="showTooltip = true"
69
- @mouseleave="showTooltip = false"
70
- >
71
- <div
72
- v-if="showTooltip"
73
- v-tooltip="{ content: modelValue.toString(), shown: true, distance: 16, delay: 0 }"
74
- class="absolute"
75
- :style="tooltipStyle"
76
- />
77
- </div>
78
- </HstWrapper>
79
- </template>
80
-
81
- <style lang="pcss">
82
- /* v4: @apply in a component <style> needs the theme referenced explicitly. */
83
- @reference "../../style/main.css";
84
-
85
- .range-input {
86
- &::-webkit-slider-thumb {
87
- @apply appearance-none h-3 w-3 bg-white dark:bg-gray-700 border border-solid border-black/25 dark:border-white/25 rounded-full;
88
- }
89
-
90
- &:hover::-webkit-slider-thumb {
91
- @apply bg-primary-500! border-primary-500!;
92
- }
93
- }
94
-
95
- /* Separate rules for -moz-range-thumb to prevent a bug with Safari that causes it to ignore custom style */
96
-
97
- .range-input {
98
- &::-moz-range-thumb {
99
- @apply appearance-none h-3 w-3 bg-white dark:bg-gray-700 border border-solid border-black/25 dark:border-white/25 rounded-full;
100
- }
101
-
102
- &:hover::-moz-range-thumb {
103
- @apply bg-primary-500! border-primary-500!;
104
- }
105
- }
106
- </style>
@@ -1,63 +0,0 @@
1
- <script lang="ts" setup>
2
- import HstText from './HstText.vue'
3
-
4
- function initState() {
5
- return {
6
- label: 'My really long label',
7
- text: '',
8
- }
9
- }
10
- </script>
11
-
12
- <template>
13
- <Story
14
- title="HstText"
15
- group="controls"
16
- :layout="{
17
- type: 'grid',
18
- width: '100%',
19
- }"
20
- >
21
- <Variant
22
- title="default"
23
- :init-state="initState"
24
- >
25
- <template #default="{ state }">
26
- <HstText
27
- v-model="state.text"
28
- :title="state.label"
29
- />
30
- </template>
31
-
32
- <template #controls="{ state }">
33
- <HstText
34
- v-model="state.label"
35
- title="Label"
36
- />
37
- <HstText
38
- v-model="state.text"
39
- title="Text"
40
- />
41
- </template>
42
- </Variant>
43
-
44
- <Variant
45
- title="no-label"
46
- :init-state="initState"
47
- >
48
- <template #default="{ state }">
49
- <HstText
50
- v-model="state.text"
51
- placeholder="Enter some text..."
52
- />
53
- </template>
54
-
55
- <template #controls="{ state }">
56
- <HstText
57
- v-model="state.text"
58
- title="Text"
59
- />
60
- </template>
61
- </Variant>
62
- </Story>
63
- </template>
@@ -1,44 +0,0 @@
1
- <script lang="ts">
2
- export default {
3
- name: 'HstText',
4
- }
5
- </script>
6
-
7
- <script lang="ts" setup>
8
- import { ref } from 'vue'
9
- import HstWrapper from '../HstWrapper.vue'
10
-
11
- defineProps<{
12
- title?: string
13
- modelValue?: string | null
14
- }>()
15
-
16
- const emit = defineEmits({
17
- 'update:modelValue': (newValue: string) => true,
18
- })
19
-
20
- const input = ref<HTMLInputElement>()
21
- </script>
22
-
23
- <template>
24
- <HstWrapper
25
- :title="title"
26
- class="poveste-text cursor-text items-center"
27
- :class="$attrs.class"
28
- :style="$attrs.style"
29
- @click="input.focus()"
30
- >
31
- <input
32
- ref="input"
33
- v-bind="{ ...$attrs, class: null, style: null }"
34
- type="text"
35
- :value="modelValue"
36
- class="text-inherit bg-transparent w-full outline-none px-2 py-1 -my-1 border border-solid border-black/25 dark:border-white/25 focus:border-primary-500 dark:focus:border-primary-500 rounded-sm"
37
- @input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
38
- >
39
-
40
- <template #actions>
41
- <slot name="actions" />
42
- </template>
43
- </HstWrapper>
44
- </template>
@@ -1,35 +0,0 @@
1
- <script lang="ts" setup>
2
- import HstTextarea from './HstTextarea.vue'
3
-
4
- function initState() {
5
- return {
6
- text: '',
7
- }
8
- }
9
- </script>
10
-
11
- <template>
12
- <Story
13
- title="HstTextarea"
14
- group="controls"
15
- >
16
- <Variant
17
- title="default"
18
- :init-state="initState"
19
- >
20
- <template #default="{ state }">
21
- <HstTextarea
22
- v-model="state.text"
23
- title="Textarea"
24
- />
25
- </template>
26
-
27
- <template #controls="{ state }">
28
- <HstTextarea
29
- v-model="state.text"
30
- title="Text"
31
- />
32
- </template>
33
- </Variant>
34
- </Story>
35
- </template>
@@ -1,44 +0,0 @@
1
- <script lang="ts">
2
- export default {
3
- name: 'HstTextarea',
4
- inheritAttrs: false,
5
- }
6
- </script>
7
-
8
- <script lang="ts" setup>
9
- import { ref } from 'vue'
10
- import HstWrapper from '../HstWrapper.vue'
11
-
12
- defineProps<{
13
- title?: string
14
- modelValue?: string | null
15
- }>()
16
-
17
- const emit = defineEmits({
18
- 'update:modelValue': (newValue: string) => true,
19
- })
20
-
21
- const input = ref<HTMLInputElement>()
22
- </script>
23
-
24
- <template>
25
- <HstWrapper
26
- :title="title"
27
- class="poveste-textarea cursor-text"
28
- :class="$attrs.class"
29
- :style="$attrs.style"
30
- @click="input.focus()"
31
- >
32
- <textarea
33
- ref="input"
34
- v-bind="{ ...$attrs, class: null, style: null }"
35
- :value="modelValue"
36
- class="text-inherit bg-transparent w-full outline-none px-2 py-1 -my-1 border border-solid border-black/25 dark:border-white/25 focus:border-primary-500 dark:focus:border-primary-500 rounded-sm box-border resize-y min-h-[26px]"
37
- @input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
38
- />
39
-
40
- <template #actions>
41
- <slot name="actions" />
42
- </template>
43
- </HstWrapper>
44
- </template>
package/src/end.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { Ref } from '@poveste/vendors/vue'
2
-
3
- global {
4
- interface Window {
5
- __pvt_controls_dark: Ref<boolean>[]
6
- __pvt_controls_dark_ready: () => void
7
- }
8
- }
package/src/index.ts DELETED
@@ -1,54 +0,0 @@
1
- import HstButtonVue from './components/button/HstButton.vue'
2
- import HstButtonGroupVue from './components/button/HstButtonGroup.vue'
3
- import HstCheckboxVue from './components/checkbox/HstCheckbox.vue'
4
- import HstCheckboxListVue from './components/checkbox/HstCheckboxList.vue'
5
- import HstColorSelectVue from './components/colorselect/HstColorSelect.vue'
6
- import HstColorShadesVue from './components/design-tokens/HstColorShades.vue'
7
- import HstTokenGridVue from './components/design-tokens/HstTokenGrid.vue'
8
- import HstTokenListVue from './components/design-tokens/HstTokenList.vue'
9
- import HstCopyIconVue from './components/HstCopyIcon.vue'
10
- import HstJsonVue from './components/json/HstJson.vue'
11
- import HstNumberVue from './components/number/HstNumber.vue'
12
- import HstRadioVue from './components/radio/HstRadio.vue'
13
- import HstSelectVue from './components/select/HstSelect.vue'
14
- import HstSliderVue from './components/slider/HstSlider.vue'
15
- import HstTextVue from './components/text/HstText.vue'
16
- import HstTextareaVue from './components/textarea/HstTextarea.vue'
17
-
18
- export const HstButton = HstButtonVue
19
- export const HstButtonGroup = HstButtonGroupVue
20
- export const HstCheckbox = HstCheckboxVue
21
- export const HstCheckboxList = HstCheckboxListVue
22
- export const HstText = HstTextVue
23
- export const HstNumber = HstNumberVue
24
- export const HstSlider = HstSliderVue
25
- export const HstTextarea = HstTextareaVue
26
- export const HstSelect = HstSelectVue
27
- export const HstColorShades = HstColorShadesVue
28
- export const HstTokenList = HstTokenListVue
29
- export const HstTokenGrid = HstTokenGridVue
30
- export const HstCopyIcon = HstCopyIconVue
31
- export const HstRadio = HstRadioVue
32
- export const HstJson = HstJsonVue
33
- export const HstColorSelect = HstColorSelectVue
34
-
35
- export const components = {
36
- HstButton,
37
- HstButtonGroup,
38
- HstCheckbox,
39
- HstCheckboxList,
40
- HstText,
41
- HstNumber,
42
- HstSlider,
43
- HstTextarea,
44
- HstSelect,
45
- HstRadio,
46
- HstJson,
47
- HstColorShades,
48
- HstTokenList,
49
- HstTokenGrid,
50
- HstCopyIcon,
51
- HstColorSelect,
52
- }
53
-
54
- export * from './types'
@@ -1,65 +0,0 @@
1
- @import 'floating-vue/dist/style.css';
2
-
3
- /*
4
- * Tailwind v4. Preflight is intentionally omitted (was `corePlugins.preflight:
5
- * false` in v3) by importing the theme + utilities layers individually. The
6
- * `ptw-` utility prefix is gone — chrome/story isolation is handled by @scope (#27).
7
- */
8
- @layer theme, base, components, utilities;
9
- @import 'tailwindcss/theme.css' layer(theme);
10
- @import 'tailwindcss/utilities.css' layer(utilities);
11
-
12
- /* Chrome dark mode. Deliberately a distinct class from the story-side
13
- `theme.darkClass` default (`dark`) so chrome and story themes stay independent —
14
- in v3 the `ptw-` prefix applied to the dark class and kept them separate. */
15
- @custom-variant dark (&:where(.ptw-dark, .ptw-dark *));
16
-
17
- @theme {
18
- /* primary = emerald (ported from the root v3 config) */
19
- --color-primary-50: var(--color-emerald-50);
20
- --color-primary-100: var(--color-emerald-100);
21
- --color-primary-200: var(--color-emerald-200);
22
- --color-primary-300: var(--color-emerald-300);
23
- --color-primary-400: var(--color-emerald-400);
24
- --color-primary-500: var(--color-emerald-500);
25
- --color-primary-600: var(--color-emerald-600);
26
- --color-primary-700: var(--color-emerald-700);
27
- --color-primary-800: var(--color-emerald-800);
28
- --color-primary-900: var(--color-emerald-900);
29
- --color-primary-950: var(--color-emerald-950);
30
-
31
- /* gray = zinc, plus the custom 750/850/950 shades from the root v3 config */
32
- --color-gray-50: var(--color-zinc-50);
33
- --color-gray-100: var(--color-zinc-100);
34
- --color-gray-200: var(--color-zinc-200);
35
- --color-gray-300: var(--color-zinc-300);
36
- --color-gray-400: var(--color-zinc-400);
37
- --color-gray-500: var(--color-zinc-500);
38
- --color-gray-600: var(--color-zinc-600);
39
- --color-gray-700: var(--color-zinc-700);
40
- --color-gray-750: #323238;
41
- --color-gray-800: var(--color-zinc-800);
42
- --color-gray-850: #1f1f21;
43
- --color-gray-900: var(--color-zinc-900);
44
- --color-gray-950: #101012;
45
-
46
- /* border radius (ported from the root v3 config) */
47
- --radius-sm: 0.25rem;
48
- --radius: 0.375rem;
49
- --radius-md: 0.5rem;
50
- --radius-lg: 0.75rem;
51
- --radius-xl: 1rem;
52
- --radius-2xl: 1.5rem;
53
- --radius-3xl: 2rem;
54
- }
55
-
56
- body {
57
- font-size: 1.125rem;
58
- @apply dark:text-gray-100;
59
- }
60
-
61
- @media (min-width: 640px) {
62
- body {
63
- font-size: .875rem;
64
- }
65
- }
package/src/types.ts DELETED
@@ -1,4 +0,0 @@
1
- export interface HstControlOption {
2
- label: string
3
- value: any
4
- }
package/src/utils.ts DELETED
@@ -1,12 +0,0 @@
1
- import { ref } from 'vue'
2
-
3
- export const isDark = ref(false)
4
-
5
- if (!window.__pvt_controls_dark) {
6
- window.__pvt_controls_dark = []
7
- }
8
-
9
- // There could be multiple instances of the controls lib (in the controls book https://controls.poveste.dev)
10
- window.__pvt_controls_dark.push(isDark)
11
-
12
- window.__pvt_controls_dark_ready?.()
package/tsconfig.json DELETED
@@ -1,53 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- // Volar
5
- "jsx": "preserve",
6
- "lib": [
7
- "ESNext",
8
- "DOM"
9
- ],
10
- "baseUrl": ".",
11
- "rootDir": "src",
12
- "module": "ESNext",
13
- "moduleResolution": "bundler",
14
- // Alias
15
- "paths": {
16
- "floating-vue": ["./node_modules/@poveste/vendors/floating-vue"],
17
- "@iconify/vue": ["./node_modules/@poveste/vendors/iconify"],
18
- "pinia": ["./node_modules/@poveste/vendors/pinia"],
19
- "scroll-into-view-if-needed": ["./node_modules/@poveste/vendors/scroll"],
20
- "vue-router": ["./node_modules/@poveste/vendors/vue-router"],
21
- "@vueuse/core": ["./node_modules/@poveste/vendors/vue-use"],
22
- "vue": ["./node_modules/@poveste/vendors/vue"]
23
- },
24
- "resolveJsonModule": true,
25
- "types": [
26
- "node"
27
- ],
28
- "strictBindCallApply": true,
29
- "strictFunctionTypes": true,
30
- "alwaysStrict": true,
31
- // Strict
32
- "noImplicitAny": false,
33
- "noImplicitThis": true,
34
- // Output
35
- "outDir": "dist",
36
- "removeComments": false,
37
- "sourceMap": false,
38
- "allowSyntheticDefaultImports": true,
39
- "esModuleInterop": true,
40
- "preserveSymlinks": true,
41
- "skipLibCheck": true,
42
- "preserveWatchOutput": true
43
- },
44
- "include": [
45
- "src"
46
- ],
47
- "exclude": [
48
- "node_modules",
49
- "generated/**/*",
50
- "dist/**/*",
51
- "src/**/*.spec.ts"
52
- ]
53
- }
package/vite.config.ts DELETED
@@ -1,46 +0,0 @@
1
- /// <reference types="vitest" />
2
-
3
- import vue from '@vitejs/plugin-vue'
4
- import { defineConfig } from 'vite'
5
-
6
- export default defineConfig({
7
- plugins: [
8
- vue(),
9
- ],
10
- resolve: {
11
- alias: process.env.VITEST
12
- ? {}
13
- : {
14
- 'floating-vue': '@poveste/vendors/floating-vue',
15
- '@iconify/vue': '@poveste/vendors/iconify',
16
- 'pinia': '@poveste/vendors/pinia',
17
- 'scroll-into-view-if-needed': '@poveste/vendors/scroll',
18
- 'vue-router': '@poveste/vendors/vue-router',
19
- '@vueuse/core': '@poveste/vendors/vue-use',
20
- 'vue': '@poveste/vendors/vue',
21
- },
22
- },
23
-
24
- build: {
25
- emptyOutDir: false,
26
-
27
- lib: {
28
- entry: 'src/index.ts',
29
- formats: [
30
- 'es',
31
- ],
32
- fileName: 'index.es',
33
- },
34
-
35
- rollupOptions: {
36
- external: [
37
- /@poveste/,
38
- ],
39
- },
40
- },
41
-
42
- test: {
43
- environment: 'jsdom',
44
- globals: true,
45
- },
46
- })