wally-ui 1.13.1 → 1.14.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/package.json +1 -1
- package/playground/showcase/package-lock.json +48 -0
- package/playground/showcase/package.json +1 -0
- package/playground/showcase/src/app/app.routes.server.ts +4 -0
- package/playground/showcase/src/app/components/ai/ai-chat/ai-chat.html +7 -2
- package/playground/showcase/src/app/components/ai/ai-chat/ai-chat.ts +12 -1
- package/playground/showcase/src/app/components/ai/ai-chat.service.spec.ts +16 -0
- package/playground/showcase/src/app/components/ai/ai-chat.service.ts +6 -0
- package/playground/showcase/src/app/components/ai/ai-composer/ai-composer.html +14 -7
- package/playground/showcase/src/app/components/ai/ai-composer/ai-composer.ts +3 -1
- package/playground/showcase/src/app/components/ai/ai-message/ai-message.css +0 -0
- package/playground/showcase/src/app/components/ai/ai-message/ai-message.html +165 -0
- package/playground/showcase/src/app/components/ai/ai-message/ai-message.spec.ts +23 -0
- package/playground/showcase/src/app/components/ai/ai-message/ai-message.ts +51 -0
- package/playground/showcase/src/app/components/button/button.html +1 -1
- package/playground/showcase/src/app/components/button/button.ts +3 -3
- package/playground/showcase/src/app/components/selection-popover/selection-popover.css +0 -0
- package/playground/showcase/src/app/components/selection-popover/selection-popover.html +33 -0
- package/playground/showcase/src/app/components/selection-popover/selection-popover.spec.ts +23 -0
- package/playground/showcase/src/app/components/selection-popover/selection-popover.ts +269 -0
- package/playground/showcase/src/app/pages/documentation/chat-sdk/chat-sdk.html +1 -1
- package/playground/showcase/src/app/pages/documentation/components/button-docs/button-docs.examples.ts +10 -10
- package/playground/showcase/src/app/pages/documentation/components/button-docs/button-docs.html +2 -2
- package/playground/showcase/src/app/pages/documentation/components/components.html +27 -0
- package/playground/showcase/src/app/pages/documentation/components/components.routes.ts +4 -0
- package/playground/showcase/src/app/pages/documentation/components/selection-popover-docs/selection-popover-docs.css +1 -0
- package/playground/showcase/src/app/pages/documentation/components/selection-popover-docs/selection-popover-docs.examples.ts +328 -0
- package/playground/showcase/src/app/pages/documentation/components/selection-popover-docs/selection-popover-docs.html +555 -0
- package/playground/showcase/src/app/pages/documentation/components/selection-popover-docs/selection-popover-docs.ts +97 -0
- package/playground/showcase/src/app/pages/home/home.html +2 -2
- package/playground/showcase/src/styles.css +1 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// Selection Popover documentation code examples
|
|
2
|
+
export const SelectionPopoverCodeExamples = {
|
|
3
|
+
// Installation
|
|
4
|
+
installation: `npx wally-ui add selection-popover`,
|
|
5
|
+
|
|
6
|
+
// Import examples
|
|
7
|
+
import: `import { SelectionPopover } from './components/wally-ui/selection-popover/selection-popover';`,
|
|
8
|
+
componentImport: `@Component({
|
|
9
|
+
selector: 'app-example',
|
|
10
|
+
imports: [SelectionPopover],
|
|
11
|
+
templateUrl: './example.html'
|
|
12
|
+
})`,
|
|
13
|
+
|
|
14
|
+
// Basic usage
|
|
15
|
+
basicUsage: `<wally-selection-popover>
|
|
16
|
+
<article>
|
|
17
|
+
<h1>Article Title</h1>
|
|
18
|
+
<p>Select any text in this content to see the popover appear...</p>
|
|
19
|
+
</article>
|
|
20
|
+
</wally-selection-popover>`,
|
|
21
|
+
|
|
22
|
+
// === CUSTOM ACTIONS ===
|
|
23
|
+
|
|
24
|
+
customActions: `<wally-selection-popover (textSelected)="onTextSelected($event)">
|
|
25
|
+
<!-- Custom actions toolbar -->
|
|
26
|
+
<div popoverActions class="flex gap-1">
|
|
27
|
+
<button
|
|
28
|
+
class="px-3 py-2 text-sm text-[#0a0a0a] dark:text-white hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors">
|
|
29
|
+
Ask AI
|
|
30
|
+
</button>
|
|
31
|
+
<button
|
|
32
|
+
class="px-3 py-2 text-sm text-[#0a0a0a] dark:text-white hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors">
|
|
33
|
+
Copy
|
|
34
|
+
</button>
|
|
35
|
+
<button
|
|
36
|
+
class="px-3 py-2 text-sm text-[#0a0a0a] dark:text-white hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors">
|
|
37
|
+
Share
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<!-- Selectable content -->
|
|
42
|
+
<article class="prose dark:prose-invert">
|
|
43
|
+
<p>Select text to see custom actions...</p>
|
|
44
|
+
</article>
|
|
45
|
+
</wally-selection-popover>`,
|
|
46
|
+
|
|
47
|
+
customActionsTs: `export class MyComponent {
|
|
48
|
+
onTextSelected(text: string) {
|
|
49
|
+
console.log('Selected:', text);
|
|
50
|
+
// Handle the selected text
|
|
51
|
+
// This is called when any action is clicked
|
|
52
|
+
}
|
|
53
|
+
}`,
|
|
54
|
+
|
|
55
|
+
// === WITH WALLY BUTTON ===
|
|
56
|
+
|
|
57
|
+
withWallyButton: `<wally-selection-popover (textSelected)="askAboutSelection($event)">
|
|
58
|
+
<!-- Custom action with Wally Button -->
|
|
59
|
+
<div popoverActions>
|
|
60
|
+
<wally-button variant="ghost" size="sm">
|
|
61
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
|
62
|
+
stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
63
|
+
<path stroke-linecap="round" stroke-linejoin="round"
|
|
64
|
+
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z" />
|
|
65
|
+
</svg>
|
|
66
|
+
Ask AI
|
|
67
|
+
</wally-button>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<!-- Content -->
|
|
71
|
+
<article>
|
|
72
|
+
<p>Select text to ask AI about it...</p>
|
|
73
|
+
</article>
|
|
74
|
+
</wally-selection-popover>`,
|
|
75
|
+
|
|
76
|
+
withWallyButtonTs: `export class MyComponent {
|
|
77
|
+
askAboutSelection(text: string) {
|
|
78
|
+
// Send to AI chat
|
|
79
|
+
this.aiService.ask(\`Explain: \${text}\`);
|
|
80
|
+
}
|
|
81
|
+
}`,
|
|
82
|
+
|
|
83
|
+
// === PRODUCTION EXAMPLES ===
|
|
84
|
+
|
|
85
|
+
blogExample: `<!-- Blog Article with Selection Actions -->
|
|
86
|
+
<wally-selection-popover (textSelected)="handleAction($event)">
|
|
87
|
+
<div popoverActions class="flex gap-1">
|
|
88
|
+
<button
|
|
89
|
+
(click)="highlight()"
|
|
90
|
+
class="px-3 py-2 text-sm text-[#0a0a0a] dark:text-white hover:bg-yellow-100 dark:hover:bg-yellow-900 rounded transition-colors"
|
|
91
|
+
aria-label="Highlight text">
|
|
92
|
+
Highlight
|
|
93
|
+
</button>
|
|
94
|
+
<button
|
|
95
|
+
(click)="addComment()"
|
|
96
|
+
class="px-3 py-2 text-sm text-[#0a0a0a] dark:text-white hover:bg-blue-100 dark:hover:bg-blue-900 rounded transition-colors"
|
|
97
|
+
aria-label="Add comment">
|
|
98
|
+
Comment
|
|
99
|
+
</button>
|
|
100
|
+
<button
|
|
101
|
+
(click)="share()"
|
|
102
|
+
class="px-3 py-2 text-sm text-[#0a0a0a] dark:text-white hover:bg-green-100 dark:hover:bg-green-900 rounded transition-colors"
|
|
103
|
+
aria-label="Share selection">
|
|
104
|
+
Share
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<article class="max-w-2xl mx-auto prose dark:prose-invert">
|
|
109
|
+
<h1>Understanding Angular Signals</h1>
|
|
110
|
+
<p>
|
|
111
|
+
Angular Signals represent a major shift in how we handle reactivity...
|
|
112
|
+
</p>
|
|
113
|
+
</article>
|
|
114
|
+
</wally-selection-popover>`,
|
|
115
|
+
|
|
116
|
+
blogExampleTs: `export class BlogComponent {
|
|
117
|
+
selectedText = signal<string>('');
|
|
118
|
+
|
|
119
|
+
handleAction(text: string) {
|
|
120
|
+
this.selectedText.set(text);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
highlight() {
|
|
124
|
+
console.log('Highlighting:', this.selectedText());
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
addComment() {
|
|
128
|
+
console.log('Adding comment to:', this.selectedText());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
share() {
|
|
132
|
+
console.log('Sharing:', this.selectedText());
|
|
133
|
+
}
|
|
134
|
+
}`,
|
|
135
|
+
|
|
136
|
+
documentationExample: `<!-- Documentation with AI Assistant -->
|
|
137
|
+
<wally-selection-popover (textSelected)="askAI($event)">
|
|
138
|
+
<div popoverActions>
|
|
139
|
+
<wally-button variant="ghost" size="sm">
|
|
140
|
+
<svg class="size-4">...</svg>
|
|
141
|
+
Explain with AI
|
|
142
|
+
</wally-button>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div class="documentation-content">
|
|
146
|
+
<h2>API Reference</h2>
|
|
147
|
+
<pre><code>function useState<T>(initialValue: T): [T, (value: T) => void]</code></pre>
|
|
148
|
+
<p>Select any technical term to get AI explanation...</p>
|
|
149
|
+
</div>
|
|
150
|
+
</wally-selection-popover>`,
|
|
151
|
+
|
|
152
|
+
readingModeExample: `<!-- Reading Mode with Actions -->
|
|
153
|
+
<wally-selection-popover (textSelected)="onSelect($event)">
|
|
154
|
+
<div popoverActions class="flex items-center gap-2 px-2">
|
|
155
|
+
<button class="p-2 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded">
|
|
156
|
+
<svg class="size-4"><!-- Dictionary icon --></svg>
|
|
157
|
+
</button>
|
|
158
|
+
<button class="p-2 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded">
|
|
159
|
+
<svg class="size-4"><!-- Translate icon --></svg>
|
|
160
|
+
</button>
|
|
161
|
+
<button class="p-2 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded">
|
|
162
|
+
<svg class="size-4"><!-- Read aloud icon --></svg>
|
|
163
|
+
</button>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div class="reading-content text-lg leading-relaxed">
|
|
167
|
+
<p>Select text to see reading assistance tools...</p>
|
|
168
|
+
</div>
|
|
169
|
+
</wally-selection-popover>`,
|
|
170
|
+
|
|
171
|
+
// === MOBILE SUPPORT ===
|
|
172
|
+
|
|
173
|
+
mobileSupport: `<!-- Automatic mobile support -->\n<wally-selection-popover (textSelected)="onSelect($event)">\n <!-- Works seamlessly on mobile devices:\n - Touch event support (touchstart, touchend)\n - Native selection menu prevention\n - Viewport-aware positioning (avoids virtual keyboard)\n - Larger touch targets on mobile (44x44px minimum)\n - Touch scroll prevention on popover\n - Adaptive delays for better touch detection\n -->\n\n <article>\n <p>Try selecting text on mobile - the popover automatically adapts!</p>\n </article>\n</wally-selection-popover>`,
|
|
174
|
+
|
|
175
|
+
// === ADVANCED ===
|
|
176
|
+
|
|
177
|
+
minSelectionLength: `<!-- Custom minimum selection length -->
|
|
178
|
+
<wally-selection-popover>
|
|
179
|
+
<!-- By default, requires 3+ characters -->
|
|
180
|
+
<!-- Customize by handling selection in your code -->
|
|
181
|
+
|
|
182
|
+
<article>
|
|
183
|
+
<p>Select at least 3 characters...</p>
|
|
184
|
+
</article>
|
|
185
|
+
</wally-selection-popover>
|
|
186
|
+
|
|
187
|
+
<!-- Note: The component has a built-in 3-character minimum
|
|
188
|
+
to prevent accidental popover triggers on short selections -->`,
|
|
189
|
+
|
|
190
|
+
positioningBehavior: `<!-- Automatic viewport-aware positioning -->
|
|
191
|
+
<wally-selection-popover>
|
|
192
|
+
<!-- Popover automatically:
|
|
193
|
+
1. Centers above selection
|
|
194
|
+
2. Prevents overflow on screen edges
|
|
195
|
+
3. Adjusts position if too close to viewport boundaries
|
|
196
|
+
4. Uses position: fixed for scroll stability
|
|
197
|
+
-->
|
|
198
|
+
|
|
199
|
+
<article>
|
|
200
|
+
<p>Try selecting text near screen edges...</p>
|
|
201
|
+
</article>
|
|
202
|
+
</wally-selection-popover>`,
|
|
203
|
+
|
|
204
|
+
keyboardAccessibility: `<!-- Keyboard interaction -->
|
|
205
|
+
<wally-selection-popover (textSelected)="onSelect($event)">
|
|
206
|
+
<!-- Supports:
|
|
207
|
+
- ESC key to close popover
|
|
208
|
+
- Click outside to dismiss
|
|
209
|
+
- Full ARIA dialog attributes
|
|
210
|
+
- role="dialog" with aria-label
|
|
211
|
+
-->
|
|
212
|
+
|
|
213
|
+
<article>
|
|
214
|
+
<p>Select text and press ESC to close...</p>
|
|
215
|
+
</article>
|
|
216
|
+
</wally-selection-popover>`,
|
|
217
|
+
|
|
218
|
+
eventHandling: `<!-- Event handling example -->
|
|
219
|
+
<wally-selection-popover (textSelected)="handleSelection($event)">
|
|
220
|
+
<div popoverActions>
|
|
221
|
+
<wally-button variant="ghost" (buttonClick)="performAction()">
|
|
222
|
+
Custom Action
|
|
223
|
+
</wally-button>
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<article>
|
|
227
|
+
<p>Content here...</p>
|
|
228
|
+
</article>
|
|
229
|
+
</wally-selection-popover>`,
|
|
230
|
+
|
|
231
|
+
eventHandlingTs: `export class MyComponent {
|
|
232
|
+
// This event fires when:
|
|
233
|
+
// 1. Any custom action is clicked
|
|
234
|
+
// 2. The fallback button is clicked (if no custom actions)
|
|
235
|
+
handleSelection(text: string) {
|
|
236
|
+
console.log('User selected:', text);
|
|
237
|
+
|
|
238
|
+
// The popover automatically closes after this event
|
|
239
|
+
// No need to manually clear selection
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
performAction() {
|
|
243
|
+
// Custom action logic
|
|
244
|
+
// The textSelected event will still fire with the selected text
|
|
245
|
+
}
|
|
246
|
+
}`,
|
|
247
|
+
|
|
248
|
+
// === API USAGE ===
|
|
249
|
+
|
|
250
|
+
fullExample: `<!-- Complete example with all features -->
|
|
251
|
+
<wally-selection-popover (textSelected)="onTextSelected($event)">
|
|
252
|
+
<!-- Custom actions (optional) -->
|
|
253
|
+
<div popoverActions class="flex gap-1">
|
|
254
|
+
<wally-button
|
|
255
|
+
variant="ghost"
|
|
256
|
+
size="sm"
|
|
257
|
+
[ariaLabel]="'Ask AI about selection'">
|
|
258
|
+
<svg class="size-4">...</svg>
|
|
259
|
+
Ask AI
|
|
260
|
+
</wally-button>
|
|
261
|
+
|
|
262
|
+
<wally-button
|
|
263
|
+
variant="ghost"
|
|
264
|
+
size="sm"
|
|
265
|
+
[ariaLabel]="'Copy to clipboard'">
|
|
266
|
+
<svg class="size-4">...</svg>
|
|
267
|
+
Copy
|
|
268
|
+
</wally-button>
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
<!-- Selectable content -->
|
|
272
|
+
<article class="prose dark:prose-invert max-w-none">
|
|
273
|
+
<h1>Your Content</h1>
|
|
274
|
+
<p>Select any text to see the action toolbar...</p>
|
|
275
|
+
|
|
276
|
+
<h2>Features</h2>
|
|
277
|
+
<ul>
|
|
278
|
+
<li>Automatic positioning</li>
|
|
279
|
+
<li>Viewport awareness</li>
|
|
280
|
+
<li>Keyboard accessible</li>
|
|
281
|
+
<li>Zero flash rendering</li>
|
|
282
|
+
</ul>
|
|
283
|
+
</article>
|
|
284
|
+
</wally-selection-popover>`,
|
|
285
|
+
|
|
286
|
+
fullExampleTs: `export class MyComponent {
|
|
287
|
+
selectedText = signal<string>('');
|
|
288
|
+
|
|
289
|
+
onTextSelected(text: string) {
|
|
290
|
+
this.selectedText.set(text);
|
|
291
|
+
|
|
292
|
+
// Perform action based on user's custom button click
|
|
293
|
+
// For example: send to AI, copy to clipboard, etc.
|
|
294
|
+
|
|
295
|
+
console.log('Selected text:', text);
|
|
296
|
+
}
|
|
297
|
+
}`,
|
|
298
|
+
|
|
299
|
+
// === STYLING ===
|
|
300
|
+
|
|
301
|
+
customStyling: `<!-- Custom popover styling -->
|
|
302
|
+
<wally-selection-popover (textSelected)="onSelect($event)">
|
|
303
|
+
<!-- Use Tailwind classes for custom styling -->
|
|
304
|
+
<div popoverActions class="flex items-center gap-2 px-3 py-2">
|
|
305
|
+
<!-- Primary action with custom colors -->
|
|
306
|
+
<button class="
|
|
307
|
+
px-3 py-2 rounded-lg
|
|
308
|
+
bg-blue-500 text-white
|
|
309
|
+
hover:bg-blue-600
|
|
310
|
+
transition-colors">
|
|
311
|
+
Primary
|
|
312
|
+
</button>
|
|
313
|
+
|
|
314
|
+
<!-- Secondary action -->
|
|
315
|
+
<button class="
|
|
316
|
+
px-3 py-2 rounded-lg
|
|
317
|
+
text-neutral-700 dark:text-neutral-300
|
|
318
|
+
hover:bg-neutral-100 dark:hover:bg-neutral-800
|
|
319
|
+
transition-colors">
|
|
320
|
+
Secondary
|
|
321
|
+
</button>
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<article>
|
|
325
|
+
<p>Content...</p>
|
|
326
|
+
</article>
|
|
327
|
+
</wally-selection-popover>`,
|
|
328
|
+
};
|