@proto.ui/prototypes-shadcn 0.0.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.
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/button/index.d.ts +4 -0
- package/dist/button/index.js +175 -0
- package/dist/button/types.d.ts +8 -0
- package/dist/button/types.js +1 -0
- package/dist/hover-card/content.d.ts +2 -0
- package/dist/hover-card/content.js +11 -0
- package/dist/hover-card/index.d.ts +8 -0
- package/dist/hover-card/index.js +7 -0
- package/dist/hover-card/root.d.ts +2 -0
- package/dist/hover-card/root.js +11 -0
- package/dist/hover-card/trigger.d.ts +2 -0
- package/dist/hover-card/trigger.js +47 -0
- package/dist/hover-card/types.d.ts +10 -0
- package/dist/hover-card/types.js +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +16 -0
- package/dist/switch/index.d.ts +6 -0
- package/dist/switch/index.js +5 -0
- package/dist/switch/root.d.ts +3 -0
- package/dist/switch/root.js +67 -0
- package/dist/switch/thumb.d.ts +3 -0
- package/dist/switch/thumb.js +26 -0
- package/dist/switch/types.d.ts +11 -0
- package/dist/switch/types.js +1 -0
- package/dist/tabs/content.d.ts +3 -0
- package/dist/tabs/content.js +16 -0
- package/dist/tabs/index.d.ts +10 -0
- package/dist/tabs/index.js +9 -0
- package/dist/tabs/list.d.ts +3 -0
- package/dist/tabs/list.js +11 -0
- package/dist/tabs/root.d.ts +3 -0
- package/dist/tabs/root.js +11 -0
- package/dist/tabs/trigger.d.ts +3 -0
- package/dist/tabs/trigger.js +52 -0
- package/dist/tabs/types.d.ts +18 -0
- package/dist/tabs/types.js +1 -0
- package/dist/toggle/index.d.ts +4 -0
- package/dist/toggle/index.js +82 -0
- package/dist/toggle/types.d.ts +8 -0
- package/dist/toggle/types.js +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Proto UI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @proto.ui/prototypes-shadcn
|
|
2
|
+
|
|
3
|
+
shadcn-style Proto UI prototype library for adapter-driven components.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Provides a shadcn-style Proto UI prototype library that works with Proto UI adapters.
|
|
8
|
+
|
|
9
|
+
## Package Role
|
|
10
|
+
|
|
11
|
+
Prototype library package intended to be consumed together with Proto UI adapters.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @proto.ui/prototypes-shadcn@0.0.1
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Internal Structure
|
|
20
|
+
|
|
21
|
+
- `src/button/`
|
|
22
|
+
- `src/hover-card/`
|
|
23
|
+
- `src/index.ts`
|
|
24
|
+
- `src/switch/`
|
|
25
|
+
- `src/tabs/`
|
|
26
|
+
- `src/toggle/`
|
|
27
|
+
|
|
28
|
+
## Related Internal Packages
|
|
29
|
+
|
|
30
|
+
- `@proto.ui/core`
|
|
31
|
+
- `@proto.ui/module-as-trigger`
|
|
32
|
+
- `@proto.ui/module-event`
|
|
33
|
+
- `@proto.ui/module-rule-meta`
|
|
34
|
+
- `@proto.ui/prototypes-base`
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ShadcnButtonExposes, ShadcnButtonProps, ShadcnButtonSize, ShadcnButtonVariant } from './types';
|
|
2
|
+
declare const button: import("@proto.ui/core").Prototype<ShadcnButtonProps, import("@proto.ui/prototypes-base").ButtonExposes>;
|
|
3
|
+
export type { ShadcnButtonProps, ShadcnButtonExposes, ShadcnButtonSize, ShadcnButtonVariant };
|
|
4
|
+
export default button;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asButton } from '@proto.ui/prototypes-base';
|
|
3
|
+
// Shared button skeleton copied from shadcn/ui and reduced to the plain
|
|
4
|
+
// utility tokens that Proto UI v0 can express in feedback.style today.
|
|
5
|
+
const BUTTON_BASE_TOKENS = [
|
|
6
|
+
'group/button',
|
|
7
|
+
'inline-flex',
|
|
8
|
+
'shrink-0',
|
|
9
|
+
'items-center',
|
|
10
|
+
'justify-center',
|
|
11
|
+
'rounded-lg',
|
|
12
|
+
'border',
|
|
13
|
+
'bg-clip-padding',
|
|
14
|
+
'text-sm',
|
|
15
|
+
'font-medium',
|
|
16
|
+
'whitespace-nowrap',
|
|
17
|
+
'transition-all',
|
|
18
|
+
'outline-none',
|
|
19
|
+
'select-none',
|
|
20
|
+
].join(' ');
|
|
21
|
+
// Variant rules stay composable and only encode the stable visual surface.
|
|
22
|
+
// Pseudo selectors such as hover/focus-visible/aria-invalid/dark are left to
|
|
23
|
+
// dedicated rule extensions because the current feedback token contract does
|
|
24
|
+
// not accept selector-style utilities directly.
|
|
25
|
+
const VARIANT_TOKENS = {
|
|
26
|
+
default: 'border-transparent bg-primary text-primary-foreground',
|
|
27
|
+
destructive: 'border-transparent bg-destructive/10 text-destructive',
|
|
28
|
+
outline: 'border-border bg-background text-foreground',
|
|
29
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground',
|
|
30
|
+
ghost: 'border-transparent bg-transparent text-foreground',
|
|
31
|
+
link: 'border-transparent bg-transparent text-primary underline-offset-4',
|
|
32
|
+
};
|
|
33
|
+
// Size rules cover the public API we expose right now. The upstream examples
|
|
34
|
+
// also contain xs-style variants, but those are not part of this prototype API
|
|
35
|
+
// yet, so they are intentionally left out here.
|
|
36
|
+
const SIZE_TOKENS = {
|
|
37
|
+
default: 'h-8 gap-1.5 px-2.5',
|
|
38
|
+
sm: 'h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem]',
|
|
39
|
+
lg: 'h-9 gap-1.5 px-2.5',
|
|
40
|
+
icon: 'size-8',
|
|
41
|
+
};
|
|
42
|
+
const button = definePrototype({
|
|
43
|
+
name: 'shadcn-button',
|
|
44
|
+
setup(def) {
|
|
45
|
+
def.props.define({
|
|
46
|
+
variant: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
empty: 'fallback',
|
|
49
|
+
enum: ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'],
|
|
50
|
+
},
|
|
51
|
+
size: { type: 'string', empty: 'fallback', enum: ['default', 'sm', 'lg', 'icon'] },
|
|
52
|
+
disabled: { type: 'boolean', empty: 'fallback' },
|
|
53
|
+
});
|
|
54
|
+
def.props.setDefaults({
|
|
55
|
+
variant: 'default',
|
|
56
|
+
size: 'default',
|
|
57
|
+
disabled: false,
|
|
58
|
+
});
|
|
59
|
+
asButton();
|
|
60
|
+
const disabled = def.state.fromInteraction('disabled');
|
|
61
|
+
const hovered = def.state.fromInteraction('hovered');
|
|
62
|
+
const focused = def.state.fromInteraction('focused');
|
|
63
|
+
const focusVisible = def.state.fromInteraction('focusVisible');
|
|
64
|
+
const pressed = def.state.fromInteraction('pressed');
|
|
65
|
+
const expanded = def.state.fromAccessibility('expanded');
|
|
66
|
+
const invalid = def.state.fromAccessibility('invalid');
|
|
67
|
+
// Base skeleton shared by every shadcn-style button.
|
|
68
|
+
def.feedback.style.use(tw(BUTTON_BASE_TOKENS));
|
|
69
|
+
// Variant surface rules map the public `variant` prop to visual tokens.
|
|
70
|
+
Object.keys(VARIANT_TOKENS).forEach((variant) => {
|
|
71
|
+
def.rule({
|
|
72
|
+
when: (w) => w.prop('variant').eq(variant),
|
|
73
|
+
intent: (i) => i.feedback.style.use(tw(VARIANT_TOKENS[variant])),
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
// Size rules are isolated so later icon-density refinements can layer on
|
|
77
|
+
// top without re-encoding every variant.
|
|
78
|
+
Object.keys(SIZE_TOKENS).forEach((size) => {
|
|
79
|
+
def.rule({
|
|
80
|
+
when: (w) => w.prop('size').eq(size),
|
|
81
|
+
intent: (i) => i.feedback.style.use(tw(SIZE_TOKENS[size])),
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
// Focus/press are shared interaction states exposed by `asButton()`, so
|
|
85
|
+
// shadcn styling can stay inside rule semantics instead of hard-coding
|
|
86
|
+
// host-specific pseudo selectors.
|
|
87
|
+
def.rule({
|
|
88
|
+
when: (w) => w.state(focusVisible).eq(true),
|
|
89
|
+
intent: (i) => i.feedback.style.use(tw('border-ring ring-3 ring-ring/50')),
|
|
90
|
+
});
|
|
91
|
+
def.rule({
|
|
92
|
+
when: (w) => w.all(w.state(focusVisible).eq(true), w.prop('variant').eq('destructive')),
|
|
93
|
+
intent: (i) => i.feedback.style.use(tw('border-destructive/40 ring-destructive/20')),
|
|
94
|
+
});
|
|
95
|
+
def.rule({
|
|
96
|
+
when: (w) => w.state(pressed).eq(true),
|
|
97
|
+
intent: (i) => i.feedback.style.use(tw('translate-y-px')),
|
|
98
|
+
});
|
|
99
|
+
// Hovered surface rules are split by variant so later dark/meta branches
|
|
100
|
+
// can replace them cleanly without duplicating the base variant tokens.
|
|
101
|
+
def.rule({
|
|
102
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.prop('variant').eq('default')),
|
|
103
|
+
intent: (i) => i.feedback.style.use(tw('bg-primary/80')),
|
|
104
|
+
});
|
|
105
|
+
def.rule({
|
|
106
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.prop('variant').eq('secondary')),
|
|
107
|
+
intent: (i) => i.feedback.style.use(tw('bg-secondary/80')),
|
|
108
|
+
});
|
|
109
|
+
def.rule({
|
|
110
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.prop('variant').eq('outline')),
|
|
111
|
+
intent: (i) => i.feedback.style.use(tw('bg-muted text-foreground')),
|
|
112
|
+
});
|
|
113
|
+
def.rule({
|
|
114
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.prop('variant').eq('ghost')),
|
|
115
|
+
intent: (i) => i.feedback.style.use(tw('bg-muted text-foreground')),
|
|
116
|
+
});
|
|
117
|
+
def.rule({
|
|
118
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.prop('variant').eq('link')),
|
|
119
|
+
intent: (i) => i.feedback.style.use(tw('underline')),
|
|
120
|
+
});
|
|
121
|
+
def.rule({
|
|
122
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.prop('variant').eq('destructive')),
|
|
123
|
+
intent: (i) => i.feedback.style.use(tw('bg-destructive/20')),
|
|
124
|
+
});
|
|
125
|
+
// Accessibility semantics stay in the official shared state lane. This
|
|
126
|
+
// keeps button-compatible semantics like `expanded` / `invalid` reusable
|
|
127
|
+
// by higher-level triggers instead of reintroducing ad-hoc aria props here.
|
|
128
|
+
def.rule({
|
|
129
|
+
when: (w) => w.all(w.state(expanded).eq(true), w.prop('variant').eq('outline')),
|
|
130
|
+
intent: (i) => i.feedback.style.use(tw('bg-muted text-foreground')),
|
|
131
|
+
});
|
|
132
|
+
def.rule({
|
|
133
|
+
when: (w) => w.all(w.state(expanded).eq(true), w.prop('variant').eq('secondary')),
|
|
134
|
+
intent: (i) => i.feedback.style.use(tw('bg-secondary text-secondary-foreground')),
|
|
135
|
+
});
|
|
136
|
+
def.rule({
|
|
137
|
+
when: (w) => w.state(invalid).eq(true),
|
|
138
|
+
intent: (i) => i.feedback.style.use(tw('border-destructive ring-3 ring-destructive/20')),
|
|
139
|
+
});
|
|
140
|
+
// Dark mode stays in meta so the prototype remains host-agnostic while web
|
|
141
|
+
// adapters still have a clean place to optimize to `dark:*`.
|
|
142
|
+
def.rule({
|
|
143
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.prop('variant').eq('outline')),
|
|
144
|
+
intent: (i) => i.feedback.style.use(tw('border-input bg-input/30')),
|
|
145
|
+
});
|
|
146
|
+
def.rule({
|
|
147
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.state(hovered).eq(true), w.prop('variant').eq('outline')),
|
|
148
|
+
intent: (i) => i.feedback.style.use(tw('bg-input/50')),
|
|
149
|
+
});
|
|
150
|
+
def.rule({
|
|
151
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.prop('variant').eq('destructive')),
|
|
152
|
+
intent: (i) => i.feedback.style.use(tw('bg-destructive/20')),
|
|
153
|
+
});
|
|
154
|
+
def.rule({
|
|
155
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.state(hovered).eq(true), w.prop('variant').eq('destructive')),
|
|
156
|
+
intent: (i) => i.feedback.style.use(tw('bg-destructive/30')),
|
|
157
|
+
});
|
|
158
|
+
def.rule({
|
|
159
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.state(focusVisible).eq(true), w.prop('variant').eq('destructive')),
|
|
160
|
+
intent: (i) => i.feedback.style.use(tw('ring-destructive/40')),
|
|
161
|
+
});
|
|
162
|
+
def.rule({
|
|
163
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.state(invalid).eq(true)),
|
|
164
|
+
intent: (i) => i.feedback.style.use(tw('border-destructive/50 ring-destructive/40')),
|
|
165
|
+
});
|
|
166
|
+
// Disabled remains a standalone rule because it semantically cuts across
|
|
167
|
+
// every variant and size, and we now source it from the shared button
|
|
168
|
+
// behavior instead of duplicating prop semantics locally.
|
|
169
|
+
def.rule({
|
|
170
|
+
when: (w) => w.state(disabled).eq(true),
|
|
171
|
+
intent: (i) => i.feedback.style.use(tw('pointer-events-none opacity-50')),
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
export default button;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ButtonExposes, ButtonProps } from '@proto.ui/prototypes-base';
|
|
2
|
+
export type ShadcnButtonVariant = 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
3
|
+
export type ShadcnButtonSize = 'default' | 'sm' | 'lg' | 'icon';
|
|
4
|
+
export interface ShadcnButtonProps extends ButtonProps {
|
|
5
|
+
variant?: ShadcnButtonVariant;
|
|
6
|
+
size?: ShadcnButtonSize;
|
|
7
|
+
}
|
|
8
|
+
export type ShadcnButtonExposes = ButtonExposes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asHoverCardContent } from '@proto.ui/prototypes-base';
|
|
3
|
+
const hoverCardContent = definePrototype({
|
|
4
|
+
name: 'shadcn-hover-card-content',
|
|
5
|
+
setup(def) {
|
|
6
|
+
asHoverCardContent();
|
|
7
|
+
def.feedback.style.use(tw('absolute left-0 top-full z-50 mt-2 block w-80 rounded-xl border border-border/60 bg-background p-4 text-sm leading-6 shadow-lg'));
|
|
8
|
+
return (r) => r.el('div', r.r.slot());
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export default hoverCardContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import hoverCardContent from './content';
|
|
2
|
+
import hoverCardRoot from './root';
|
|
3
|
+
import hoverCardTrigger from './trigger';
|
|
4
|
+
export type { ShadcnHoverCardRootProps, ShadcnHoverCardRootExposes, ShadcnHoverCardRootAsHookContract, ShadcnHoverCardTriggerProps, ShadcnHoverCardTriggerExposes, ShadcnHoverCardTriggerAsHookContract, ShadcnHoverCardContentProps, ShadcnHoverCardContentExposes, ShadcnHoverCardContentAsHookContract, } from './types';
|
|
5
|
+
export { hoverCardRoot, hoverCardTrigger, hoverCardContent };
|
|
6
|
+
export { default as shadcnHoverCardRoot } from './root';
|
|
7
|
+
export { default as shadcnHoverCardTrigger } from './trigger';
|
|
8
|
+
export { default as shadcnHoverCardContent } from './content';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import hoverCardContent from './content';
|
|
2
|
+
import hoverCardRoot from './root';
|
|
3
|
+
import hoverCardTrigger from './trigger';
|
|
4
|
+
export { hoverCardRoot, hoverCardTrigger, hoverCardContent };
|
|
5
|
+
export { default as shadcnHoverCardRoot } from './root';
|
|
6
|
+
export { default as shadcnHoverCardTrigger } from './trigger';
|
|
7
|
+
export { default as shadcnHoverCardContent } from './content';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asHoverCardRoot } from '@proto.ui/prototypes-base';
|
|
3
|
+
const hoverCardRoot = definePrototype({
|
|
4
|
+
name: 'shadcn-hover-card-root',
|
|
5
|
+
setup(def) {
|
|
6
|
+
asHoverCardRoot();
|
|
7
|
+
def.feedback.style.use(tw('relative inline-flex items-start'));
|
|
8
|
+
return (r) => r.el('div', r.r.slot());
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export default hoverCardRoot;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asHoverCardTrigger } from '@proto.ui/prototypes-base';
|
|
3
|
+
const TRIGGER_BASE_TOKENS = [
|
|
4
|
+
'inline-flex',
|
|
5
|
+
'items-center',
|
|
6
|
+
'rounded-md',
|
|
7
|
+
'border',
|
|
8
|
+
'border-border/60',
|
|
9
|
+
'bg-background',
|
|
10
|
+
'px-3',
|
|
11
|
+
'py-1.5',
|
|
12
|
+
'text-sm',
|
|
13
|
+
'font-medium',
|
|
14
|
+
'shadow-xs',
|
|
15
|
+
'transition-colors',
|
|
16
|
+
'outline-none',
|
|
17
|
+
'select-none',
|
|
18
|
+
].join(' ');
|
|
19
|
+
const hoverCardTrigger = definePrototype({
|
|
20
|
+
name: 'shadcn-hover-card-trigger',
|
|
21
|
+
setup(def) {
|
|
22
|
+
asHoverCardTrigger();
|
|
23
|
+
const disabled = def.state.fromInteraction('disabled');
|
|
24
|
+
const hovered = def.state.fromInteraction('hovered');
|
|
25
|
+
const focusVisible = def.state.fromInteraction('focusVisible');
|
|
26
|
+
const pressed = def.state.fromInteraction('pressed');
|
|
27
|
+
def.feedback.style.use(tw(TRIGGER_BASE_TOKENS));
|
|
28
|
+
def.rule({
|
|
29
|
+
when: (w) => w.state(hovered).eq(true),
|
|
30
|
+
intent: (i) => i.feedback.style.use(tw('bg-muted text-foreground')),
|
|
31
|
+
});
|
|
32
|
+
def.rule({
|
|
33
|
+
when: (w) => w.state(focusVisible).eq(true),
|
|
34
|
+
intent: (i) => i.feedback.style.use(tw('ring-3 ring-ring/50 ring-offset-2')),
|
|
35
|
+
});
|
|
36
|
+
def.rule({
|
|
37
|
+
when: (w) => w.state(pressed).eq(true),
|
|
38
|
+
intent: (i) => i.feedback.style.use(tw('translate-y-px')),
|
|
39
|
+
});
|
|
40
|
+
def.rule({
|
|
41
|
+
when: (w) => w.state(disabled).eq(true),
|
|
42
|
+
intent: (i) => i.feedback.style.use(tw('pointer-events-none opacity-50')),
|
|
43
|
+
});
|
|
44
|
+
return (r) => r.el('button', r.r.slot());
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
export default hoverCardTrigger;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HoverCardContentAsHookContract, HoverCardContentExposes, HoverCardContentProps, HoverCardRootAsHookContract, HoverCardRootExposes, HoverCardRootProps, HoverCardTriggerAsHookContract, HoverCardTriggerExposes, HoverCardTriggerProps } from '@proto.ui/prototypes-base';
|
|
2
|
+
export type ShadcnHoverCardRootProps = HoverCardRootProps;
|
|
3
|
+
export type ShadcnHoverCardRootExposes = HoverCardRootExposes;
|
|
4
|
+
export type ShadcnHoverCardRootAsHookContract = HoverCardRootAsHookContract;
|
|
5
|
+
export type ShadcnHoverCardTriggerProps = HoverCardTriggerProps;
|
|
6
|
+
export type ShadcnHoverCardTriggerExposes = HoverCardTriggerExposes;
|
|
7
|
+
export type ShadcnHoverCardTriggerAsHookContract = HoverCardTriggerAsHookContract;
|
|
8
|
+
export type ShadcnHoverCardContentProps = HoverCardContentProps;
|
|
9
|
+
export type ShadcnHoverCardContentExposes = HoverCardContentExposes;
|
|
10
|
+
export type ShadcnHoverCardContentAsHookContract = HoverCardContentAsHookContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as button } from './button';
|
|
2
|
+
export { default as shadcnButton } from './button';
|
|
3
|
+
export { default as toggle } from './toggle';
|
|
4
|
+
export { default as shadcnToggle } from './toggle';
|
|
5
|
+
export { switchRoot, switchThumb } from './switch';
|
|
6
|
+
export { default as shadcnSwitchRoot } from './switch/root';
|
|
7
|
+
export { default as shadcnSwitchThumb } from './switch/thumb';
|
|
8
|
+
export { tabsRoot, tabsList, tabsTrigger, tabsContent } from './tabs';
|
|
9
|
+
export { hoverCardRoot, hoverCardTrigger, hoverCardContent } from './hover-card';
|
|
10
|
+
export { default as shadcnTabsRoot } from './tabs/root';
|
|
11
|
+
export { default as shadcnTabsList } from './tabs/list';
|
|
12
|
+
export { default as shadcnTabsTrigger } from './tabs/trigger';
|
|
13
|
+
export { default as shadcnTabsContent } from './tabs/content';
|
|
14
|
+
export { default as shadcnHoverCardRoot } from './hover-card/root';
|
|
15
|
+
export { default as shadcnHoverCardTrigger } from './hover-card/trigger';
|
|
16
|
+
export { default as shadcnHoverCardContent } from './hover-card/content';
|
|
17
|
+
export type { ShadcnButtonProps, ShadcnButtonExposes, ShadcnButtonSize, ShadcnButtonVariant, } from './button/types';
|
|
18
|
+
export type { ShadcnToggleProps, ShadcnToggleExposes, ShadcnToggleStateHandles, ShadcnToggleAsHookContract, } from './toggle/types';
|
|
19
|
+
export type { ShadcnSwitchRootProps, ShadcnSwitchRootExposes, ShadcnSwitchRootStateHandles, ShadcnSwitchRootAsHookContract, ShadcnSwitchThumbProps, ShadcnSwitchThumbExposes, ShadcnSwitchThumbAsHookContract, } from './switch/types';
|
|
20
|
+
export type { ShadcnTabsRootProps, ShadcnTabsRootExposes, ShadcnTabsRootAsHookContract, ShadcnTabsListProps, ShadcnTabsListExposes, ShadcnTabsListAsHookContract, ShadcnTabsTriggerProps, ShadcnTabsTriggerExposes, ShadcnTabsTriggerStateHandles, ShadcnTabsTriggerAsHookContract, ShadcnTabsContentProps, ShadcnTabsContentExposes, ShadcnTabsContentAsHookContract, } from './tabs/types';
|
|
21
|
+
export type { ShadcnHoverCardRootProps, ShadcnHoverCardRootExposes, ShadcnHoverCardRootAsHookContract, ShadcnHoverCardTriggerProps, ShadcnHoverCardTriggerExposes, ShadcnHoverCardTriggerAsHookContract, ShadcnHoverCardContentProps, ShadcnHoverCardContentExposes, ShadcnHoverCardContentAsHookContract, } from './hover-card/types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default as button } from './button';
|
|
2
|
+
export { default as shadcnButton } from './button';
|
|
3
|
+
export { default as toggle } from './toggle';
|
|
4
|
+
export { default as shadcnToggle } from './toggle';
|
|
5
|
+
export { switchRoot, switchThumb } from './switch';
|
|
6
|
+
export { default as shadcnSwitchRoot } from './switch/root';
|
|
7
|
+
export { default as shadcnSwitchThumb } from './switch/thumb';
|
|
8
|
+
export { tabsRoot, tabsList, tabsTrigger, tabsContent } from './tabs';
|
|
9
|
+
export { hoverCardRoot, hoverCardTrigger, hoverCardContent } from './hover-card';
|
|
10
|
+
export { default as shadcnTabsRoot } from './tabs/root';
|
|
11
|
+
export { default as shadcnTabsList } from './tabs/list';
|
|
12
|
+
export { default as shadcnTabsTrigger } from './tabs/trigger';
|
|
13
|
+
export { default as shadcnTabsContent } from './tabs/content';
|
|
14
|
+
export { default as shadcnHoverCardRoot } from './hover-card/root';
|
|
15
|
+
export { default as shadcnHoverCardTrigger } from './hover-card/trigger';
|
|
16
|
+
export { default as shadcnHoverCardContent } from './hover-card/content';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import switchRoot from './root';
|
|
2
|
+
import switchThumb from './thumb';
|
|
3
|
+
export type { ShadcnSwitchRootProps, ShadcnSwitchRootExposes, ShadcnSwitchRootStateHandles, ShadcnSwitchRootAsHookContract, ShadcnSwitchThumbProps, ShadcnSwitchThumbExposes, ShadcnSwitchThumbAsHookContract, } from './types';
|
|
4
|
+
export { switchRoot, switchThumb };
|
|
5
|
+
export { default as shadcnSwitchRoot } from './root';
|
|
6
|
+
export { default as shadcnSwitchThumb } from './thumb';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asSwitchRoot } from '@proto.ui/prototypes-base';
|
|
3
|
+
const ROOT_BASE_TOKENS = [
|
|
4
|
+
'peer',
|
|
5
|
+
'inline-flex',
|
|
6
|
+
'h-6',
|
|
7
|
+
'w-11',
|
|
8
|
+
'shrink-0',
|
|
9
|
+
'items-center',
|
|
10
|
+
'rounded-full',
|
|
11
|
+
'border',
|
|
12
|
+
'border-transparent',
|
|
13
|
+
'pl-0.5',
|
|
14
|
+
'pr-[22px]',
|
|
15
|
+
'shadow-xs',
|
|
16
|
+
'transition-all',
|
|
17
|
+
'duration-200',
|
|
18
|
+
'ease-in-out',
|
|
19
|
+
'outline-none',
|
|
20
|
+
'bg-input/80',
|
|
21
|
+
'select-none',
|
|
22
|
+
].join(' ');
|
|
23
|
+
const switchRoot = definePrototype({
|
|
24
|
+
name: 'shadcn-switch-root',
|
|
25
|
+
setup(def) {
|
|
26
|
+
asSwitchRoot();
|
|
27
|
+
const checked = def.state.fromAccessibility('checked');
|
|
28
|
+
const disabled = def.state.fromInteraction('disabled');
|
|
29
|
+
const hovered = def.state.fromInteraction('hovered');
|
|
30
|
+
const focusVisible = def.state.fromInteraction('focusVisible');
|
|
31
|
+
const pressed = def.state.fromInteraction('pressed');
|
|
32
|
+
def.feedback.style.use(tw(ROOT_BASE_TOKENS));
|
|
33
|
+
def.rule({
|
|
34
|
+
when: (w) => w.state(checked).eq(true),
|
|
35
|
+
intent: (i) => i.feedback.style.use(tw('pl-[22px] pr-0.5 bg-primary text-primary-foreground')),
|
|
36
|
+
});
|
|
37
|
+
def.rule({
|
|
38
|
+
when: (w) => w.all(w.state(checked).eq(false), w.state(hovered).eq(true)),
|
|
39
|
+
intent: (i) => i.feedback.style.use(tw('bg-input')),
|
|
40
|
+
});
|
|
41
|
+
def.rule({
|
|
42
|
+
when: (w) => w.all(w.state(checked).eq(true), w.state(hovered).eq(true)),
|
|
43
|
+
intent: (i) => i.feedback.style.use(tw('bg-primary/90')),
|
|
44
|
+
});
|
|
45
|
+
def.rule({
|
|
46
|
+
when: (w) => w.state(pressed).eq(true),
|
|
47
|
+
intent: (i) => i.feedback.style.use(tw('scale-[0.98]')),
|
|
48
|
+
});
|
|
49
|
+
def.rule({
|
|
50
|
+
when: (w) => w.state(focusVisible).eq(true),
|
|
51
|
+
intent: (i) => i.feedback.style.use(tw('ring-3 ring-ring/50 ring-offset-2 ring-offset-background')),
|
|
52
|
+
});
|
|
53
|
+
def.rule({
|
|
54
|
+
when: (w) => w.state(disabled).eq(true),
|
|
55
|
+
intent: (i) => i.feedback.style.use(tw('pointer-events-none opacity-50')),
|
|
56
|
+
});
|
|
57
|
+
def.rule({
|
|
58
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.state(checked).eq(false)),
|
|
59
|
+
intent: (i) => i.feedback.style.use(tw('bg-input/50')),
|
|
60
|
+
});
|
|
61
|
+
def.rule({
|
|
62
|
+
when: (w) => w.all(w.meta('colorScheme').eq('dark'), w.state(checked).eq(true)),
|
|
63
|
+
intent: (i) => i.feedback.style.use(tw('bg-primary')),
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export default switchRoot;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asSwitchThumb } from '@proto.ui/prototypes-base';
|
|
3
|
+
const THUMB_TOKENS = [
|
|
4
|
+
'pointer-events-none',
|
|
5
|
+
'block',
|
|
6
|
+
'size-5',
|
|
7
|
+
'rounded-full',
|
|
8
|
+
'bg-background',
|
|
9
|
+
'border',
|
|
10
|
+
'border-border/50',
|
|
11
|
+
'shadow-lg',
|
|
12
|
+
'ring-0',
|
|
13
|
+
'transition-all',
|
|
14
|
+
'duration-200',
|
|
15
|
+
'ease-in-out',
|
|
16
|
+
'will-change-transform',
|
|
17
|
+
'translate-x-0',
|
|
18
|
+
].join(' ');
|
|
19
|
+
const switchThumb = definePrototype({
|
|
20
|
+
name: 'shadcn-switch-thumb',
|
|
21
|
+
setup(def) {
|
|
22
|
+
asSwitchThumb();
|
|
23
|
+
def.feedback.style.use(tw(THUMB_TOKENS));
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
export default switchThumb;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SwitchRootAsHookContract, SwitchRootExposes, SwitchRootProps, SwitchRootStateHandles, SwitchThumbAsHookContract, SwitchThumbExposes, SwitchThumbProps, SwitchThumbStateHandles } from '@proto.ui/prototypes-base';
|
|
2
|
+
export interface ShadcnSwitchRootProps extends SwitchRootProps {
|
|
3
|
+
}
|
|
4
|
+
export type ShadcnSwitchRootExposes = SwitchRootExposes;
|
|
5
|
+
export type ShadcnSwitchRootStateHandles = SwitchRootStateHandles;
|
|
6
|
+
export type ShadcnSwitchRootAsHookContract = SwitchRootAsHookContract;
|
|
7
|
+
export interface ShadcnSwitchThumbProps extends SwitchThumbProps {
|
|
8
|
+
}
|
|
9
|
+
export type ShadcnSwitchThumbExposes = SwitchThumbExposes;
|
|
10
|
+
export type ShadcnSwitchThumbStateHandles = SwitchThumbStateHandles;
|
|
11
|
+
export type ShadcnSwitchThumbAsHookContract = SwitchThumbAsHookContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asTabsContent } from '@proto.ui/prototypes-base';
|
|
3
|
+
const tabsContent = definePrototype({
|
|
4
|
+
name: 'shadcn-tabs-content',
|
|
5
|
+
setup(def) {
|
|
6
|
+
asTabsContent();
|
|
7
|
+
const current = def.state.fromAccessibility('current');
|
|
8
|
+
def.feedback.style.use(tw('block w-full min-h-28 rounded-xl border border-border/60 bg-background p-4 text-sm leading-6 shadow-xs outline-none'));
|
|
9
|
+
def.rule({
|
|
10
|
+
when: (w) => w.state(current).eq(false),
|
|
11
|
+
intent: (i) => i.feedback.style.use(tw('hidden')),
|
|
12
|
+
});
|
|
13
|
+
return (r) => r.el('div', r.r.slot());
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export default tabsContent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import tabsContent from './content';
|
|
2
|
+
import tabsList from './list';
|
|
3
|
+
import tabsRoot from './root';
|
|
4
|
+
import tabsTrigger from './trigger';
|
|
5
|
+
export type { ShadcnTabsRootProps, ShadcnTabsRootExposes, ShadcnTabsRootAsHookContract, ShadcnTabsListProps, ShadcnTabsListExposes, ShadcnTabsListAsHookContract, ShadcnTabsTriggerProps, ShadcnTabsTriggerExposes, ShadcnTabsTriggerStateHandles, ShadcnTabsTriggerAsHookContract, ShadcnTabsContentProps, ShadcnTabsContentExposes, ShadcnTabsContentAsHookContract, } from './types';
|
|
6
|
+
export { tabsRoot, tabsList, tabsTrigger, tabsContent };
|
|
7
|
+
export { default as shadcnTabsRoot } from './root';
|
|
8
|
+
export { default as shadcnTabsList } from './list';
|
|
9
|
+
export { default as shadcnTabsTrigger } from './trigger';
|
|
10
|
+
export { default as shadcnTabsContent } from './content';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import tabsContent from './content';
|
|
2
|
+
import tabsList from './list';
|
|
3
|
+
import tabsRoot from './root';
|
|
4
|
+
import tabsTrigger from './trigger';
|
|
5
|
+
export { tabsRoot, tabsList, tabsTrigger, tabsContent };
|
|
6
|
+
export { default as shadcnTabsRoot } from './root';
|
|
7
|
+
export { default as shadcnTabsList } from './list';
|
|
8
|
+
export { default as shadcnTabsTrigger } from './trigger';
|
|
9
|
+
export { default as shadcnTabsContent } from './content';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asTabsList } from '@proto.ui/prototypes-base';
|
|
3
|
+
const tabsList = definePrototype({
|
|
4
|
+
name: 'shadcn-tabs-list',
|
|
5
|
+
setup(def) {
|
|
6
|
+
asTabsList();
|
|
7
|
+
def.feedback.style.use(tw('inline-flex h-10 items-center rounded-xl border border-border/60 bg-muted/80 p-1 text-muted-foreground shadow-xs backdrop-blur-xs'));
|
|
8
|
+
return (r) => r.el('div', r.r.slot());
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export default tabsList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asTabsRoot } from '@proto.ui/prototypes-base';
|
|
3
|
+
const tabsRoot = definePrototype({
|
|
4
|
+
name: 'shadcn-tabs-root',
|
|
5
|
+
setup(def) {
|
|
6
|
+
asTabsRoot();
|
|
7
|
+
def.feedback.style.use(tw('flex flex-col gap-3 text-foreground'));
|
|
8
|
+
return (r) => r.el('div', r.r.slot());
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export default tabsRoot;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asTabsTrigger } from '@proto.ui/prototypes-base';
|
|
3
|
+
const BASE_TOKENS = [
|
|
4
|
+
'inline-flex',
|
|
5
|
+
'items-center',
|
|
6
|
+
'justify-center',
|
|
7
|
+
'whitespace-nowrap',
|
|
8
|
+
'rounded-lg',
|
|
9
|
+
'border',
|
|
10
|
+
'border-transparent',
|
|
11
|
+
'px-3',
|
|
12
|
+
'py-1.5',
|
|
13
|
+
'text-sm',
|
|
14
|
+
'font-medium',
|
|
15
|
+
'transition-all',
|
|
16
|
+
'outline-none',
|
|
17
|
+
'text-muted-foreground',
|
|
18
|
+
'select-none',
|
|
19
|
+
].join(' ');
|
|
20
|
+
const tabsTrigger = definePrototype({
|
|
21
|
+
name: 'shadcn-tabs-trigger',
|
|
22
|
+
setup(def) {
|
|
23
|
+
asTabsTrigger();
|
|
24
|
+
const disabled = def.state.fromInteraction('disabled');
|
|
25
|
+
const hovered = def.state.fromInteraction('hovered');
|
|
26
|
+
const focusVisible = def.state.fromInteraction('focusVisible');
|
|
27
|
+
const pressed = def.state.fromInteraction('pressed');
|
|
28
|
+
const selected = def.state.fromAccessibility('selected');
|
|
29
|
+
def.feedback.style.use(tw(BASE_TOKENS));
|
|
30
|
+
def.rule({
|
|
31
|
+
when: (w) => w.state(focusVisible).eq(true),
|
|
32
|
+
intent: (i) => i.feedback.style.use(tw('bg-background text-foreground shadow-xs ring-3 ring-ring/50 ring-offset-2 ring-offset-background')),
|
|
33
|
+
});
|
|
34
|
+
def.rule({
|
|
35
|
+
when: (w) => w.state(selected).eq(true),
|
|
36
|
+
intent: (i) => i.feedback.style.use(tw('bg-background text-foreground shadow-xs')),
|
|
37
|
+
});
|
|
38
|
+
def.rule({
|
|
39
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.state(selected).eq(false)),
|
|
40
|
+
intent: (i) => i.feedback.style.use(tw('bg-background/70 text-foreground shadow-xs')),
|
|
41
|
+
});
|
|
42
|
+
def.rule({
|
|
43
|
+
when: (w) => w.state(pressed).eq(true),
|
|
44
|
+
intent: (i) => i.feedback.style.use(tw('scale-[0.99] bg-background text-foreground shadow-xs')),
|
|
45
|
+
});
|
|
46
|
+
def.rule({
|
|
47
|
+
when: (w) => w.state(disabled).eq(true),
|
|
48
|
+
intent: (i) => i.feedback.style.use(tw('pointer-events-none opacity-50')),
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
export default tabsTrigger;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TabsContentAsHookContract, TabsContentExposes, TabsContentProps, TabsListAsHookContract, TabsListExposes, TabsListProps, TabsRootAsHookContract, TabsRootExposes, TabsRootProps, TabsTriggerAsHookContract, TabsTriggerExposes, TabsTriggerProps, TabsTriggerStateHandles } from '@proto.ui/prototypes-base';
|
|
2
|
+
export interface ShadcnTabsRootProps extends TabsRootProps {
|
|
3
|
+
}
|
|
4
|
+
export type ShadcnTabsRootExposes = TabsRootExposes;
|
|
5
|
+
export type ShadcnTabsRootAsHookContract = TabsRootAsHookContract;
|
|
6
|
+
export interface ShadcnTabsListProps extends TabsListProps {
|
|
7
|
+
}
|
|
8
|
+
export type ShadcnTabsListExposes = TabsListExposes;
|
|
9
|
+
export type ShadcnTabsListAsHookContract = TabsListAsHookContract;
|
|
10
|
+
export interface ShadcnTabsTriggerProps extends TabsTriggerProps {
|
|
11
|
+
}
|
|
12
|
+
export type ShadcnTabsTriggerExposes = TabsTriggerExposes;
|
|
13
|
+
export type ShadcnTabsTriggerStateHandles = TabsTriggerStateHandles;
|
|
14
|
+
export type ShadcnTabsTriggerAsHookContract = TabsTriggerAsHookContract;
|
|
15
|
+
export interface ShadcnTabsContentProps extends TabsContentProps {
|
|
16
|
+
}
|
|
17
|
+
export type ShadcnTabsContentExposes = TabsContentExposes;
|
|
18
|
+
export type ShadcnTabsContentAsHookContract = TabsContentAsHookContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ShadcnToggleProps } from './types';
|
|
2
|
+
declare const toggle: import("@proto.ui/core").Prototype<ShadcnToggleProps, import("@proto.ui/prototypes-base").ToggleExposes>;
|
|
3
|
+
export type { ShadcnToggleProps, ShadcnToggleExposes, ShadcnToggleStateHandles, ShadcnToggleAsHookContract, } from './types';
|
|
4
|
+
export default toggle;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { definePrototype, tw } from '@proto.ui/core';
|
|
2
|
+
import { asToggle } from '@proto.ui/prototypes-base';
|
|
3
|
+
const TOGGLE_BASE_TOKENS = [
|
|
4
|
+
'inline-flex',
|
|
5
|
+
'items-center',
|
|
6
|
+
'justify-center',
|
|
7
|
+
'gap-2',
|
|
8
|
+
'rounded-md',
|
|
9
|
+
'text-sm',
|
|
10
|
+
'font-medium',
|
|
11
|
+
'transition-colors',
|
|
12
|
+
'outline-none',
|
|
13
|
+
'border',
|
|
14
|
+
'border-transparent',
|
|
15
|
+
'whitespace-nowrap',
|
|
16
|
+
].join(' ');
|
|
17
|
+
const VARIANT_TOKENS = {
|
|
18
|
+
default: 'bg-transparent text-foreground',
|
|
19
|
+
outline: 'border-border bg-transparent shadow-xs',
|
|
20
|
+
};
|
|
21
|
+
const SIZE_TOKENS = {
|
|
22
|
+
default: 'h-9 px-3 min-w-9',
|
|
23
|
+
sm: 'h-8 px-2.5 min-w-8',
|
|
24
|
+
lg: 'h-10 px-5 min-w-10',
|
|
25
|
+
};
|
|
26
|
+
const toggle = definePrototype({
|
|
27
|
+
name: 'shadcn-toggle',
|
|
28
|
+
setup(def) {
|
|
29
|
+
def.props.define({
|
|
30
|
+
variant: { type: 'string', empty: 'fallback', enum: ['default', 'outline'] },
|
|
31
|
+
size: { type: 'string', empty: 'fallback', enum: ['default', 'sm', 'lg'] },
|
|
32
|
+
checked: { type: 'boolean', empty: 'fallback' },
|
|
33
|
+
defaultChecked: { type: 'boolean', empty: 'fallback' },
|
|
34
|
+
disabled: { type: 'boolean', empty: 'fallback' },
|
|
35
|
+
});
|
|
36
|
+
def.props.setDefaults({
|
|
37
|
+
variant: 'default',
|
|
38
|
+
size: 'default',
|
|
39
|
+
defaultChecked: false,
|
|
40
|
+
disabled: false,
|
|
41
|
+
});
|
|
42
|
+
asToggle();
|
|
43
|
+
const checked = def.state.fromAccessibility('checked');
|
|
44
|
+
const disabled = def.state.fromInteraction('disabled');
|
|
45
|
+
const hovered = def.state.fromInteraction('hovered');
|
|
46
|
+
const focusVisible = def.state.fromInteraction('focusVisible');
|
|
47
|
+
def.feedback.style.use(tw(TOGGLE_BASE_TOKENS));
|
|
48
|
+
Object.keys(VARIANT_TOKENS).forEach((variant) => {
|
|
49
|
+
def.rule({
|
|
50
|
+
when: (w) => w.prop('variant').eq(variant),
|
|
51
|
+
intent: (i) => i.feedback.style.use(tw(VARIANT_TOKENS[variant])),
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
Object.keys(SIZE_TOKENS).forEach((size) => {
|
|
55
|
+
def.rule({
|
|
56
|
+
when: (w) => w.prop('size').eq(size),
|
|
57
|
+
intent: (i) => i.feedback.style.use(tw(SIZE_TOKENS[size])),
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
def.rule({
|
|
61
|
+
when: (w) => w.state(checked).eq(true),
|
|
62
|
+
intent: (i) => i.feedback.style.use(tw('bg-muted text-muted-foreground')),
|
|
63
|
+
});
|
|
64
|
+
def.rule({
|
|
65
|
+
when: (w) => w.all(w.state(checked).eq(true), w.prop('variant').eq('outline')),
|
|
66
|
+
intent: (i) => i.feedback.style.use(tw('bg-accent text-accent-foreground')),
|
|
67
|
+
});
|
|
68
|
+
def.rule({
|
|
69
|
+
when: (w) => w.all(w.state(hovered).eq(true), w.state(checked).eq(false)),
|
|
70
|
+
intent: (i) => i.feedback.style.use(tw('bg-muted/60 text-foreground')),
|
|
71
|
+
});
|
|
72
|
+
def.rule({
|
|
73
|
+
when: (w) => w.state(focusVisible).eq(true),
|
|
74
|
+
intent: (i) => i.feedback.style.use(tw('ring-3 ring-ring/50')),
|
|
75
|
+
});
|
|
76
|
+
def.rule({
|
|
77
|
+
when: (w) => w.state(disabled).eq(true),
|
|
78
|
+
intent: (i) => i.feedback.style.use(tw('pointer-events-none opacity-50')),
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
export default toggle;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToggleAsHookContract, ToggleExposes, ToggleProps, ToggleStateHandles } from '@proto.ui/prototypes-base';
|
|
2
|
+
export interface ShadcnToggleProps extends ToggleProps {
|
|
3
|
+
variant?: 'default' | 'outline';
|
|
4
|
+
size?: 'default' | 'sm' | 'lg';
|
|
5
|
+
}
|
|
6
|
+
export type ShadcnToggleExposes = ToggleExposes;
|
|
7
|
+
export type ShadcnToggleStateHandles = ToggleStateHandles;
|
|
8
|
+
export type ShadcnToggleAsHookContract = ToggleAsHookContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proto.ui/prototypes-shadcn",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@proto.ui/core": "0.0.1",
|
|
7
|
+
"@proto.ui/module-as-trigger": "0.0.1",
|
|
8
|
+
"@proto.ui/module-event": "0.0.1",
|
|
9
|
+
"@proto.ui/module-rule-meta": "0.0.1",
|
|
10
|
+
"@proto.ui/prototypes-base": "0.0.1"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"description": "shadcn-style Proto UI prototype library for adapter-driven components.",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"homepage": "https://github.com/guangliang2019/Prototype-UI/tree/main/packages/prototypes/shadcn",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/guangliang2019/Prototype-UI.git",
|
|
24
|
+
"directory": "packages/prototypes/shadcn"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/guangliang2019/Prototype-UI/issues"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"proto-ui",
|
|
34
|
+
"proto",
|
|
35
|
+
"ui",
|
|
36
|
+
"prototypes",
|
|
37
|
+
"shadcn",
|
|
38
|
+
"prototype-library",
|
|
39
|
+
"shadcn-style"
|
|
40
|
+
],
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
]
|
|
46
|
+
}
|