@balikjs/mobile 0.0.1 → 0.1.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 (104) hide show
  1. package/dist/index.js +3537 -0
  2. package/dist/styles.css +1 -1
  3. package/package.json +209 -10
  4. package/dist/mobile.js +0 -3062
  5. package/src/Alert/Alert.jsx +0 -67
  6. package/src/Alert/Alert.module.css +0 -87
  7. package/src/Alert/index.js +0 -1
  8. package/src/Avatar/Avatar.jsx +0 -77
  9. package/src/Avatar/Avatar.module.css +0 -74
  10. package/src/Avatar/index.js +0 -1
  11. package/src/Badge/Badge.jsx +0 -83
  12. package/src/Badge/Badge.module.css +0 -141
  13. package/src/Badge/index.js +0 -1
  14. package/src/BottomNavigation/BottomNavigation.jsx +0 -61
  15. package/src/BottomNavigation/BottomNavigation.module.css +0 -53
  16. package/src/BottomNavigation/index.js +0 -1
  17. package/src/BottomSheet/BottomSheet.jsx +0 -51
  18. package/src/BottomSheet/BottomSheet.module.css +0 -56
  19. package/src/BottomSheet/index.js +0 -1
  20. package/src/Button/Button.jsx +0 -77
  21. package/src/Button/Button.module.css +0 -124
  22. package/src/Button/index.js +0 -1
  23. package/src/Card/Card.jsx +0 -31
  24. package/src/Card/Card.module.css +0 -4
  25. package/src/Card/index.js +0 -1
  26. package/src/Checkbox/Checkbox.jsx +0 -64
  27. package/src/Checkbox/Checkbox.module.css +0 -146
  28. package/src/Checkbox/index.js +0 -1
  29. package/src/Clipboard/Clipboard.jsx +0 -82
  30. package/src/Clipboard/Clipboard.module.css +0 -126
  31. package/src/Clipboard/index.js +0 -1
  32. package/src/CloseButton/CloseButton.jsx +0 -51
  33. package/src/CloseButton/CloseButton.module.css +0 -94
  34. package/src/Confirm/Confirm.jsx +0 -52
  35. package/src/Confirm/Confirm.module.css +0 -5
  36. package/src/Confirm/index.js +0 -1
  37. package/src/Dialog/Dialog.jsx +0 -63
  38. package/src/Dialog/Dialog.module.css +0 -111
  39. package/src/Dialog/index.js +0 -1
  40. package/src/Divider/Divider.jsx +0 -38
  41. package/src/Divider/Divider.module.css +0 -16
  42. package/src/Divider/index.js +0 -1
  43. package/src/Drawer/Drawer.jsx +0 -55
  44. package/src/Drawer/Drawer.module.css +0 -68
  45. package/src/Drawer/index.js +0 -1
  46. package/src/Empty/Empty.jsx +0 -35
  47. package/src/Empty/Empty.module.css +0 -17
  48. package/src/Empty/index.js +0 -1
  49. package/src/Fab/Fab.jsx +0 -91
  50. package/src/Fab/Fab.module.css +0 -94
  51. package/src/Fab/index.js +0 -1
  52. package/src/Input/Input.jsx +0 -53
  53. package/src/Input/Input.module.css +0 -97
  54. package/src/Input/index.js +0 -1
  55. package/src/Link/Link.jsx +0 -31
  56. package/src/Link/Link.module.css +0 -18
  57. package/src/Link/index.js +0 -1
  58. package/src/Popover/Popover.jsx +0 -162
  59. package/src/Popover/Popover.module.css +0 -63
  60. package/src/Popover/index.js +0 -1
  61. package/src/RadioGroup/Radio.jsx +0 -52
  62. package/src/RadioGroup/Radio.module.css +0 -133
  63. package/src/RadioGroup/RadioGroup.jsx +0 -36
  64. package/src/RadioGroup/RadioGroup.module.css +0 -23
  65. package/src/RadioGroup/index.js +0 -2
  66. package/src/SearchInput/SearchInput.jsx +0 -89
  67. package/src/SearchInput/SearchInput.module.css +0 -169
  68. package/src/SearchInput/index.js +0 -1
  69. package/src/Select/Select.jsx +0 -101
  70. package/src/Select/Select.module.css +0 -174
  71. package/src/Select/index.js +0 -1
  72. package/src/SelectPc/Select.jsx +0 -88
  73. package/src/SelectPc/SelectPc.module.css +0 -132
  74. package/src/SelectPc/index.js +0 -1
  75. package/src/Skeleton/Skeleton.jsx +0 -55
  76. package/src/Skeleton/Skeleton.module.css +0 -33
  77. package/src/Skeleton/index.js +0 -1
  78. package/src/Slider/Slider.jsx +0 -50
  79. package/src/Slider/Slider.module.css +0 -77
  80. package/src/Slider/index.js +0 -1
  81. package/src/Spinner/Spinner.jsx +0 -45
  82. package/src/Spinner/Spinner.module.css +0 -35
  83. package/src/Spinner/index.js +0 -1
  84. package/src/Switch/Switch.jsx +0 -51
  85. package/src/Switch/Switch.module.css +0 -156
  86. package/src/Switch/index.js +0 -1
  87. package/src/Tabs/Tabs.jsx +0 -75
  88. package/src/Tabs/Tabs.module.css +0 -45
  89. package/src/Tabs/index.js +0 -1
  90. package/src/Tag/Tag.jsx +0 -74
  91. package/src/Tag/Tag.module.css +0 -128
  92. package/src/Tag/index.js +0 -1
  93. package/src/Textarea/Textarea.jsx +0 -52
  94. package/src/Textarea/Textarea.module.css +0 -89
  95. package/src/Textarea/index.js +0 -1
  96. package/src/Toast/Toast.jsx +0 -169
  97. package/src/Toast/Toast.module.css +0 -152
  98. package/src/Toast/index.js +0 -1
  99. package/src/Tooltip/Tooltip.jsx +0 -42
  100. package/src/Tooltip/Tooltip.module.css +0 -41
  101. package/src/Tooltip/index.js +0 -1
  102. package/src/index.js +0 -34
  103. package/src/styles/index.css +0 -90
  104. package/src/styles/tokens.css +0 -227
@@ -1,56 +0,0 @@
1
- .backdrop {
2
- position: fixed;
3
- inset: 0;
4
- z-index: var(--b-z-index-modal);
5
- background-color: rgba(0, 0, 0, 0.35);
6
- opacity: 0;
7
- pointer-events: none;
8
- transition: opacity 0.3s ease;
9
- }
10
-
11
- .backdrop[data-open] {
12
- opacity: 1;
13
- pointer-events: auto;
14
- }
15
-
16
- .sheet {
17
- position: fixed;
18
- inset-inline: 0;
19
- bottom: 0;
20
- z-index: var(--b-z-index-modal);
21
- background-color: var(--base-bg);
22
- border-radius: 16px 16px 0 0;
23
- max-height: 70vh;
24
- display: flex;
25
- flex-direction: column;
26
- transform: translateY(100%);
27
- pointer-events: none;
28
- transition: transform 0.3s ease;
29
- }
30
-
31
- .sheet[data-open] {
32
- transform: translateY(0);
33
- pointer-events: auto;
34
- }
35
-
36
- .header {
37
- display: flex;
38
- align-items: center;
39
- padding: 16px;
40
- border-bottom: 1px solid color-mix(in oklch, var(--base-fg) 6%, var(--base-bg));
41
- flex-shrink: 0;
42
- }
43
-
44
- .title {
45
- margin: 0;
46
- font-size: var(--b-comp-font-size-lg);
47
- font-weight: 600;
48
- color: var(--base-fg);
49
- }
50
-
51
- .body {
52
- overflow-y: auto;
53
- padding: 16px;
54
- flex: 1;
55
- -webkit-overflow-scrolling: touch;
56
- }
@@ -1 +0,0 @@
1
- export { BottomSheet } from './BottomSheet.jsx'
@@ -1,77 +0,0 @@
1
- import { splitProps, mergeProps } from 'solid-js'
2
- import { ark } from '@ark-ui/solid/factory'
3
- import { Loader2 } from 'lucide-solid'
4
- import styles from './Button.module.css'
5
-
6
- const roles = {
7
- outline: styles.outline,
8
- primary: styles.primary,
9
- }
10
-
11
- const intents = {
12
- default: styles.intentDefault,
13
- danger: styles.intentDanger,
14
- }
15
-
16
- const sizes = {
17
- xs: styles.sizeXs,
18
- sm: styles.sizeSm,
19
- md: styles.sizeMd,
20
- lg: styles.sizeLg,
21
- xl: styles.sizeXl,
22
- }
23
-
24
- const DEFAULT_PROPS = {
25
- solid: false,
26
- danger: false,
27
- size: 'md',
28
- disabled: false,
29
- loading: false,
30
- }
31
-
32
- /**
33
- * @param {import('solid-js').JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
34
- * solid?: boolean
35
- * danger?: boolean
36
- * size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
37
- * loading?: boolean
38
- * }} props
39
- */
40
- export function Button(props) {
41
- const [local, rest] = splitProps(
42
- mergeProps(DEFAULT_PROPS, props),
43
- ['solid', 'danger', 'size', 'class', 'loading', 'disabled', 'children'],
44
- )
45
-
46
- const roleKey = local.solid ? 'primary' : 'outline'
47
- const intentKey = local.danger ? 'danger' : 'default'
48
-
49
- return (
50
- <ark.button
51
- {...rest}
52
- disabled={local.disabled}
53
- aria-disabled={local.loading || local.disabled}
54
- class={[
55
- 'balik-button',
56
- `balik-button--${roleKey}`,
57
- `balik-button--${intentKey}`,
58
- `balik-button--${local.size}`,
59
- styles.base,
60
- roles[roleKey],
61
- intents[intentKey],
62
- sizes[local.size],
63
- local.loading && styles.loadingButton,
64
- local.class,
65
- ]
66
- .filter(Boolean)
67
- .join(' ')}
68
- >
69
- {local.children}
70
- {local.loading && (
71
- <span class={styles.loadingOverlay}>
72
- <Loader2 class={styles.spinner} aria-hidden="true" />
73
- </span>
74
- )}
75
- </ark.button>
76
- )
77
- }
@@ -1,124 +0,0 @@
1
- .base {
2
- position: relative;
3
- display: inline-flex;
4
- align-items: center;
5
- justify-content: center;
6
- border: 1px solid transparent;
7
- cursor: pointer;
8
- font-family: inherit;
9
- white-space: nowrap;
10
- user-select: none;
11
- touch-action: manipulation;
12
- transition: background-color var(--b-transition-fast),
13
- border-color var(--b-transition-fast),
14
- opacity var(--b-transition-fast);
15
-
16
- --_current-intent: var(--base-edge);
17
- }
18
-
19
- .base:disabled {
20
- background-color: var(--color-disabled-bg);
21
- border-color: var(--color-disabled-border);
22
- color: var(--color-disabled-fg);
23
- cursor: not-allowed;
24
- }
25
-
26
- .loadingOverlay {
27
- position: absolute;
28
- inset: -1px;
29
- display: flex;
30
- align-items: center;
31
- justify-content: center;
32
- background-color: color-mix(in oklch, var(--base-bg) 50%, transparent);
33
- border-radius: inherit;
34
- pointer-events: none;
35
- }
36
-
37
- .loadingButton {
38
- pointer-events: none;
39
- }
40
-
41
- .outline {
42
- background-color: var(--base-bg);
43
- border-color: var(--_current-intent);
44
- color: var(--base-fg);
45
- --_spinner-color: var(--_current-intent);
46
- }
47
-
48
- .outline:active:not(:disabled) {
49
- background-color: oklch(from var(--_current-intent) 0.96 0.03 h);
50
- border-color: oklch(from var(--_current-intent) calc(l - 0.08) c h);
51
- }
52
-
53
- .primary {
54
- background-color: var(--_current-intent);
55
- border-color: var(--_current-intent);
56
- color: var(--base-bg);
57
- --_spinner-color: var(--_current-intent);
58
- }
59
-
60
- .primary:active:not(:disabled) {
61
- background-color: oklch(from var(--_current-intent) calc(l + 0.08) calc(c - 0.02) h);
62
- border-color: oklch(from var(--_current-intent) calc(l + 0.08) calc(c - 0.02) h);
63
- }
64
-
65
- .intentDefault {
66
- --_current-intent: var(--base-edge);
67
- }
68
-
69
- .intentDanger {
70
- --_current-intent: var(--color-danger);
71
- }
72
-
73
- .sizeXs {
74
- height: var(--b-comp-height-xs);
75
- line-height: var(--b-comp-line-height-xs);
76
- padding: var(--b-comp-padding-y-xs) var(--b-comp-padding-x-xs);
77
- font-size: var(--b-comp-font-size-xs);
78
- border-radius: var(--b-radius-l1-xs);
79
- }
80
-
81
- .sizeSm {
82
- height: var(--b-comp-height-sm);
83
- line-height: var(--b-comp-line-height-sm);
84
- padding: var(--b-comp-padding-y-sm) var(--b-comp-padding-x-sm);
85
- font-size: var(--b-comp-font-size-sm);
86
- border-radius: var(--b-radius-l1-sm);
87
- }
88
-
89
- .sizeMd {
90
- height: var(--b-comp-height-md);
91
- line-height: var(--b-comp-line-height-md);
92
- padding: var(--b-comp-padding-y-md) var(--b-comp-padding-x-md);
93
- font-size: var(--b-comp-font-size-md);
94
- border-radius: var(--b-radius-l1-md);
95
- }
96
-
97
- .sizeLg {
98
- height: var(--b-comp-height-lg);
99
- line-height: var(--b-comp-line-height-lg);
100
- padding: var(--b-comp-padding-y-lg) var(--b-comp-padding-x-lg);
101
- font-size: var(--b-comp-font-size-lg);
102
- border-radius: var(--b-radius-l1-lg);
103
- }
104
-
105
- .sizeXl {
106
- height: var(--b-comp-height-xl);
107
- line-height: var(--b-comp-line-height-xl);
108
- padding: var(--b-comp-padding-y-xl) var(--b-comp-padding-x-xl);
109
- font-size: var(--b-comp-font-size-xl);
110
- border-radius: var(--b-radius-l1-xl);
111
- }
112
-
113
- .spinner {
114
- width: 1em;
115
- height: 1em;
116
- color: var(--_spinner-color);
117
- animation: balik-button-spin 0.6s linear infinite;
118
- }
119
-
120
- @keyframes balik-button-spin {
121
- to {
122
- transform: rotate(360deg);
123
- }
124
- }
@@ -1 +0,0 @@
1
- export { Button } from './Button.jsx'
package/src/Card/Card.jsx DELETED
@@ -1,31 +0,0 @@
1
- import { splitProps, mergeProps } from 'solid-js'
2
- import styles from './Card.module.css'
3
-
4
- const DEFAULT_PROPS = {}
5
-
6
- /**
7
- * @param {import('solid-js').JSX.HTMLAttributes<HTMLDivElement> & {
8
- * class?: string
9
- * }} props
10
- */
11
- export function Card(props) {
12
- const [local, rest] = splitProps(
13
- mergeProps(DEFAULT_PROPS, props),
14
- ['class', 'children'],
15
- )
16
-
17
- return (
18
- <div
19
- {...rest}
20
- class={[
21
- 'balik-card',
22
- styles.base,
23
- local.class,
24
- ]
25
- .filter(Boolean)
26
- .join(' ')}
27
- >
28
- {local.children}
29
- </div>
30
- )
31
- }
@@ -1,4 +0,0 @@
1
- .base {
2
- background-color: var(--base-bg);
3
- border-radius: var(--b-radius-l2-md);
4
- }
package/src/Card/index.js DELETED
@@ -1 +0,0 @@
1
- export { Card } from './Card.jsx'
@@ -1,64 +0,0 @@
1
- import { splitProps, mergeProps } from 'solid-js'
2
- import { Checkbox as ArkCheckbox, useCheckboxContext } from '@ark-ui/solid'
3
- import { Minus, Check } from 'lucide-solid'
4
- import styles from './Checkbox.module.css'
5
-
6
- const sizes = {
7
- xs: styles.sizeXs,
8
- sm: styles.sizeSm,
9
- md: styles.sizeMd,
10
- lg: styles.sizeLg,
11
- xl: styles.sizeXl,
12
- '2xl': styles.size2xl,
13
- }
14
-
15
- function IndicatorIcon() {
16
- const api = useCheckboxContext()
17
-
18
- return (
19
- <>
20
- {api().checked === 'indeterminate'
21
- ? <Minus size="100%" aria-hidden="true" />
22
- : <Check size="100%" aria-hidden="true" />}
23
- </>
24
- )
25
- }
26
-
27
- /**
28
- * @param {import('@ark-ui/solid').CheckboxRootProps & {
29
- * size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
30
- * class?: string
31
- * }} props
32
- */
33
- export function Checkbox(props) {
34
- const [local, rest] = splitProps(
35
- mergeProps({ size: 'md' }, props),
36
- ['class', 'children', 'size'],
37
- )
38
-
39
- return (
40
- <ArkCheckbox.Root
41
- {...rest}
42
- class={[
43
- 'balik-checkbox',
44
- styles.root,
45
- sizes[local.size],
46
- local.class,
47
- ]
48
- .filter(Boolean)
49
- .join(' ')}
50
- >
51
- <ArkCheckbox.Control class={styles.control}>
52
- <ArkCheckbox.Indicator indeterminate class={styles.indicator}>
53
- <IndicatorIcon />
54
- </ArkCheckbox.Indicator>
55
- </ArkCheckbox.Control>
56
- <ArkCheckbox.Label class={styles.label}>
57
- {local.children}
58
- </ArkCheckbox.Label>
59
- <ArkCheckbox.HiddenInput />
60
- </ArkCheckbox.Root>
61
- )
62
- }
63
-
64
- Checkbox.Original = ArkCheckbox
@@ -1,146 +0,0 @@
1
- .root {
2
- display: inline-flex;
3
- align-items: center;
4
- gap: var(--_ctrl-gap, 10px);
5
- min-height: var(--_ctrl-min-height, var(--b-comp-height-md));
6
- cursor: pointer;
7
- font-family: inherit;
8
- user-select: none;
9
- touch-action: manipulation;
10
- }
11
-
12
- .root[data-disabled] {
13
- cursor: not-allowed;
14
- }
15
-
16
- .control {
17
- width: var(--_ctrl-size, var(--b-comp-secondary-height-md));
18
- height: var(--_ctrl-size, var(--b-comp-secondary-height-md));
19
- display: flex;
20
- align-items: center;
21
- justify-content: center;
22
- flex-shrink: 0;
23
- border-radius: var(--_ctrl-radius, var(--b-radius-l1-md));
24
- border: 1px solid var(--base-edge);
25
- background-color: var(--base-bg);
26
- color: transparent;
27
- transition: background-color var(--b-transition-fast),
28
- border-color var(--b-transition-fast),
29
- color var(--b-transition-fast);
30
- }
31
-
32
- .control[data-state="checked"],
33
- .control[data-state="indeterminate"] {
34
- background-color: var(--base-edge);
35
- border-color: var(--base-edge);
36
- color: var(--base-bg);
37
- }
38
-
39
- .root[data-disabled] .control {
40
- background-color: var(--color-disabled-bg);
41
- border-color: var(--color-disabled-border);
42
- color: var(--base-bg);
43
- }
44
-
45
- .root[data-disabled] .control[data-state="checked"],
46
- .root[data-disabled] .control[data-state="indeterminate"] {
47
- color: var(--color-disabled-fg);
48
- }
49
-
50
- .root[data-invalid] .control {
51
- border-color: var(--color-danger);
52
- }
53
-
54
- .root[data-invalid] .control[data-state="checked"],
55
- .root[data-invalid] .control[data-state="indeterminate"] {
56
- background-color: var(--color-danger);
57
- border-color: var(--color-danger);
58
- }
59
-
60
- .control:active:not([data-disabled]) {
61
- transform: scale(0.88);
62
- }
63
-
64
- .indicator {
65
- display: flex;
66
- align-items: center;
67
- justify-content: center;
68
- font-size: var(--_ctrl-icon-size, 12px);
69
- }
70
-
71
- .indicator svg {
72
- width: 1em;
73
- height: 1em;
74
- }
75
-
76
- .label {
77
- font-size: var(--_ctrl-font-size, var(--b-comp-font-size-md));
78
- line-height: var(--_ctrl-line-height, var(--b-comp-line-height-md));
79
- color: var(--base-fg);
80
- }
81
-
82
- .root[data-disabled] .label {
83
- color: var(--color-disabled-fg);
84
- }
85
-
86
- /* ─── Size Overrides ─── */
87
-
88
- .sizeXs {
89
- --_ctrl-size: var(--b-comp-secondary-height-xs);
90
- --_ctrl-radius: var(--b-radius-l1-xs);
91
- --_ctrl-gap: 8px;
92
- --_ctrl-min-height: var(--b-comp-height-xs);
93
- --_ctrl-font-size: var(--b-comp-font-size-xs);
94
- --_ctrl-line-height: var(--b-comp-line-height-xs);
95
- --_ctrl-icon-size: 10px;
96
- }
97
-
98
- .sizeSm {
99
- --_ctrl-size: var(--b-comp-secondary-height-sm);
100
- --_ctrl-radius: var(--b-radius-l1-sm);
101
- --_ctrl-gap: 9px;
102
- --_ctrl-min-height: var(--b-comp-height-sm);
103
- --_ctrl-font-size: var(--b-comp-font-size-sm);
104
- --_ctrl-line-height: var(--b-comp-line-height-sm);
105
- --_ctrl-icon-size: 11px;
106
- }
107
-
108
- .sizeMd {
109
- --_ctrl-size: var(--b-comp-secondary-height-md);
110
- --_ctrl-radius: var(--b-radius-l1-md);
111
- --_ctrl-gap: 10px;
112
- --_ctrl-min-height: var(--b-comp-height-md);
113
- --_ctrl-font-size: var(--b-comp-font-size-md);
114
- --_ctrl-line-height: var(--b-comp-line-height-md);
115
- --_ctrl-icon-size: 12px;
116
- }
117
-
118
- .sizeLg {
119
- --_ctrl-size: var(--b-comp-secondary-height-lg);
120
- --_ctrl-radius: var(--b-radius-l1-lg);
121
- --_ctrl-gap: 11px;
122
- --_ctrl-min-height: var(--b-comp-height-lg);
123
- --_ctrl-font-size: var(--b-comp-font-size-lg);
124
- --_ctrl-line-height: var(--b-comp-line-height-lg);
125
- --_ctrl-icon-size: 13px;
126
- }
127
-
128
- .sizeXl {
129
- --_ctrl-size: var(--b-comp-secondary-height-xl);
130
- --_ctrl-radius: var(--b-radius-l1-xl);
131
- --_ctrl-gap: 12px;
132
- --_ctrl-min-height: var(--b-comp-height-xl);
133
- --_ctrl-font-size: var(--b-comp-font-size-xl);
134
- --_ctrl-line-height: var(--b-comp-line-height-xl);
135
- --_ctrl-icon-size: 14px;
136
- }
137
-
138
- .size2xl {
139
- --_ctrl-size: var(--b-comp-secondary-height-2xl);
140
- --_ctrl-radius: var(--b-radius-l1-2xl);
141
- --_ctrl-gap: 16px;
142
- --_ctrl-min-height: var(--b-comp-height-2xl);
143
- --_ctrl-font-size: var(--b-comp-font-size-2xl);
144
- --_ctrl-line-height: var(--b-comp-line-height-2xl);
145
- --_ctrl-icon-size: 18px;
146
- }
@@ -1 +0,0 @@
1
- export { Checkbox } from './Checkbox.jsx'
@@ -1,82 +0,0 @@
1
- import { splitProps, mergeProps, createSignal, onCleanup } from 'solid-js'
2
- import { Copy, Check } from 'lucide-solid'
3
- import styles from './Clipboard.module.css'
4
-
5
- const sizes = {
6
- xs: styles.sizeXs,
7
- sm: styles.sizeSm,
8
- md: styles.sizeMd,
9
- lg: styles.sizeLg,
10
- xl: styles.sizeXl,
11
- }
12
-
13
- const DEFAULT_PROPS = {
14
- size: 'md',
15
- copiedDuration: 2000,
16
- toastOnCopy: false,
17
- }
18
-
19
- /**
20
- * @param {import('solid-js').JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
21
- * value: string
22
- * size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
23
- * copiedDuration?: number
24
- * toastOnCopy?: boolean
25
- * class?: string
26
- * }} props
27
- */
28
- export function Clipboard(props) {
29
- const [local, rest] = splitProps(
30
- mergeProps(DEFAULT_PROPS, props),
31
- ['value', 'size', 'class', 'copiedDuration', 'toastOnCopy', 'children'],
32
- )
33
-
34
- const [copied, setCopied] = createSignal(false)
35
- let timer = null
36
-
37
- const handleCopy = async () => {
38
- try {
39
- await navigator.clipboard.writeText(local.value)
40
- } catch {
41
- const textarea = document.createElement('textarea')
42
- textarea.value = local.value
43
- textarea.style.position = 'fixed'
44
- textarea.style.opacity = '0'
45
- document.body.appendChild(textarea)
46
- textarea.select()
47
- document.execCommand('copy')
48
- document.body.removeChild(textarea)
49
- }
50
-
51
- setCopied(true)
52
- clearTimeout(timer)
53
- timer = setTimeout(() => setCopied(false), local.copiedDuration)
54
- }
55
-
56
- onCleanup(() => clearTimeout(timer))
57
-
58
- return (
59
- <button
60
- {...rest}
61
- type="button"
62
- onClick={handleCopy}
63
- class={[
64
- 'balik-clipboard',
65
- `balik-clipboard--${local.size}`,
66
- styles.base,
67
- sizes[local.size],
68
- copied() && styles.copied,
69
- local.class,
70
- ]
71
- .filter(Boolean)
72
- .join(' ')}
73
- >
74
- {copied() ? (
75
- <Check aria-hidden="true" class={styles.icon} />
76
- ) : (
77
- <Copy aria-hidden="true" class={styles.icon} />
78
- )}
79
- {local.children}
80
- </button>
81
- )
82
- }