@adea-ai/ui 0.63.3 → 0.64.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 (44) hide show
  1. package/README.md +46 -0
  2. package/dist/NOTICE +54 -0
  3. package/dist/components/conversation/busy-send-button.d.ts +28 -0
  4. package/dist/components/conversation/busy-send-button.d.ts.map +1 -0
  5. package/dist/components/conversation/busy-send-button.js +184 -0
  6. package/dist/components/conversation/busy-send-button.js.map +1 -0
  7. package/dist/components/conversation/conversation-surface.d.ts +5 -1
  8. package/dist/components/conversation/conversation-surface.d.ts.map +1 -1
  9. package/dist/components/conversation/conversation-surface.js +42 -62
  10. package/dist/components/conversation/conversation-surface.js.map +1 -1
  11. package/dist/components/conversation/index.d.ts +1 -0
  12. package/dist/components/conversation/index.d.ts.map +1 -1
  13. package/dist/components/conversation/index.js +2 -1
  14. package/dist/components/conversation/scroll-follow-core.d.ts +181 -0
  15. package/dist/components/conversation/scroll-follow-core.d.ts.map +1 -0
  16. package/dist/components/conversation/scroll-follow-core.js +139 -0
  17. package/dist/components/conversation/scroll-follow-core.js.map +1 -0
  18. package/dist/components/conversation/scroll-follow.d.ts +13 -0
  19. package/dist/components/conversation/scroll-follow.d.ts.map +1 -0
  20. package/dist/components/conversation/scroll-follow.js +102 -0
  21. package/dist/components/conversation/scroll-follow.js.map +1 -0
  22. package/dist/index.js +2 -1
  23. package/dist/lib/tokens.d.ts +3 -0
  24. package/dist/lib/tokens.d.ts.map +1 -1
  25. package/dist/lib/tokens.js +3 -0
  26. package/dist/lib/tokens.js.map +1 -1
  27. package/dist/r/conversation.json +17 -0
  28. package/dist/r/registry.json +17 -0
  29. package/dist/r/src/components/conversation/busy-send-button.tsx +161 -0
  30. package/dist/r/src/components/conversation/conversation-surface.tsx +45 -48
  31. package/dist/r/src/components/conversation/index.ts +1 -0
  32. package/dist/r/src/components/conversation/scroll-follow-core.ts +314 -0
  33. package/dist/r/src/components/conversation/scroll-follow.ts +133 -0
  34. package/dist/r/src/lib/tokens.ts +3 -0
  35. package/dist/r/src/styles/theme.css +9 -0
  36. package/package.json +1 -1
  37. package/registry.json +17 -0
  38. package/src/components/conversation/busy-send-button.tsx +161 -0
  39. package/src/components/conversation/conversation-surface.tsx +45 -48
  40. package/src/components/conversation/index.ts +1 -0
  41. package/src/components/conversation/scroll-follow-core.ts +314 -0
  42. package/src/components/conversation/scroll-follow.ts +133 -0
  43. package/src/lib/tokens.ts +3 -0
  44. package/src/styles/theme.css +9 -0
@@ -0,0 +1,133 @@
1
+ /*
2
+ * Substantially translated from KiroCrew website/src/app-sdk/useChatScrollFollow.ts,
3
+ * pinned at 283e136c0f902e965a535a7c9548c57c7504fed0.
4
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ * This product includes software developed at Amazon.com, Inc. (https://www.amazon.com/).
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy at http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software distributed
10
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the
12
+ * specific language governing permissions and limitations under the License.
13
+ * Solid owner effects replace React refs/effects; native geometry and the
14
+ * content/viewport observer contract are retained. No session store is copied.
15
+ */
16
+ import { createEffect, createSignal, onCleanup } from 'solid-js'
17
+ import {
18
+ bottomTarget,
19
+ computeAtBottom,
20
+ evaluateAutoPin,
21
+ isSelfScroll,
22
+ resolveUserScrollStick,
23
+ } from './scroll-follow-core'
24
+
25
+ const geometry = (element: HTMLDivElement) => ({
26
+ scrollTop: element.scrollTop,
27
+ scrollHeight: element.scrollHeight,
28
+ clientHeight: element.clientHeight,
29
+ })
30
+
31
+ /** Internal plain-scroller binding; host-owned restoration can disable follow. */
32
+ export function createScrollFollow(options: {
33
+ enabled: () => boolean
34
+ resetKey: () => string | undefined
35
+ threshold: () => number
36
+ }) {
37
+ const [atBottom, setAtBottom] = createSignal(true)
38
+ let scroller: HTMLDivElement | undefined
39
+ let content: HTMLDivElement | undefined
40
+ let stick = true
41
+ let lastWriteTop = -1
42
+ let lastWriteClientHeight = -1
43
+ let previousTop = -1
44
+ let lastScrollClientHeight = 0
45
+
46
+ const writePin = (element: HTMLDivElement, target: number) => {
47
+ // Instant writes keep the self-scroll reference synchronized. A smooth
48
+ // animation would produce intermediate positions that resemble user input.
49
+ element.scrollTop = target
50
+ lastWriteTop = target
51
+ lastWriteClientHeight = element.clientHeight
52
+ previousTop = target
53
+ }
54
+ const pinAuto = () => {
55
+ if (!scroller || !options.enabled()) return
56
+ const geom = geometry(scroller)
57
+ const result = evaluateAutoPin({
58
+ stick,
59
+ geom,
60
+ lastWriteTop,
61
+ viewportShrink: lastWriteClientHeight >= 0 ? lastWriteClientHeight - geom.clientHeight : 0,
62
+ })
63
+ stick = result.stick
64
+ if (result.pin) writePin(scroller, result.target)
65
+ else if (result.stick) {
66
+ lastWriteTop = result.target
67
+ lastWriteClientHeight = geom.clientHeight
68
+ }
69
+ setAtBottom(computeAtBottom(geometry(scroller), options.threshold()))
70
+ }
71
+ const onScroll = () => {
72
+ if (!scroller || !options.enabled()) return
73
+ const geom = geometry(scroller)
74
+ setAtBottom(computeAtBottom(geom, options.threshold()))
75
+ if (!isSelfScroll(geom.scrollTop, lastWriteTop)) {
76
+ stick = resolveUserScrollStick({
77
+ stick,
78
+ followOutput: true,
79
+ scrollTop: geom.scrollTop,
80
+ prevScrollTop: previousTop,
81
+ geom,
82
+ viewportGrowth: lastScrollClientHeight > 0 ? geom.clientHeight - lastScrollClientHeight : 0,
83
+ })
84
+ if (!stick) {
85
+ lastWriteTop = -1
86
+ lastWriteClientHeight = -1
87
+ }
88
+ }
89
+ previousTop = geom.scrollTop
90
+ // This baseline belongs only to scroll events, not observer callbacks.
91
+ // Advancing it during resize would erase the viewport-clamp evidence.
92
+ lastScrollClientHeight = geom.clientHeight
93
+ }
94
+ const jump = () => {
95
+ if (!scroller || !options.enabled()) return
96
+ stick = true
97
+ writePin(scroller, bottomTarget(geometry(scroller)))
98
+ setAtBottom(true)
99
+ // The jump control disappears at the bottom. Return its keyboard focus to
100
+ // the transcript instead of leaving the reader on a detached button.
101
+ scroller.focus({ preventScroll: true })
102
+ }
103
+
104
+ createEffect(() => {
105
+ options.resetKey()
106
+ const enabled = options.enabled()
107
+ stick = true
108
+ lastWriteTop = -1
109
+ lastWriteClientHeight = -1
110
+ previousTop = -1
111
+ lastScrollClientHeight = 0
112
+ setAtBottom(true)
113
+ if (!enabled || !scroller) return
114
+ writePin(scroller, bottomTarget(geometry(scroller)))
115
+ if (typeof ResizeObserver === 'undefined') return
116
+ const observer = new ResizeObserver(pinAuto)
117
+ observer.observe(scroller)
118
+ if (content) observer.observe(content)
119
+ onCleanup(() => observer.disconnect())
120
+ })
121
+
122
+ return {
123
+ atBottom,
124
+ onScroll,
125
+ jump,
126
+ bindScroller: (element: HTMLDivElement) => {
127
+ scroller = element
128
+ },
129
+ bindContent: (element: HTMLDivElement) => {
130
+ content = element
131
+ },
132
+ }
133
+ }
package/src/lib/tokens.ts CHANGED
@@ -434,6 +434,9 @@ export const typographyTokens: TokenDefinition[] = [
434
434
  },
435
435
  ]
436
436
 
437
+ /** Height tokens also size both axes of icon controls through Tailwind's --size
438
+ * namespace. Padding has its own --spacing mapping. Nominal pixel descriptions
439
+ * use a 16px rem; rendered dimensions follow the consumer's root font size. */
437
440
  export const densityTokens: TokenDefinition[] = [
438
441
  { name: 'control-height-2xs', kind: 'dimension', description: '20px — an inline chip control.' },
439
442
  { name: 'control-height-xs', kind: 'dimension', description: '24px — a dense table row action.' },
@@ -826,6 +826,15 @@
826
826
  --height-control-md: var(--control-height-md);
827
827
  --height-control-lg: var(--control-height-lg);
828
828
  --height-control-xl: var(--control-height-xl);
829
+ /* Tailwind `size-*` prefers --size-* and then --spacing-*. Without this
830
+ bridge, square icon controls use the padding ladder below for both axes.
831
+ Height, square size and inline padding remain distinct semantic contracts. */
832
+ --size-control-2xs: var(--control-height-2xs);
833
+ --size-control-xs: var(--control-height-xs);
834
+ --size-control-sm: var(--control-height-sm);
835
+ --size-control-md: var(--control-height-md);
836
+ --size-control-lg: var(--control-height-lg);
837
+ --size-control-xl: var(--control-height-xl);
829
838
  --height-row-sm: var(--row-height-sm);
830
839
  --height-row-md: var(--row-height-md);
831
840
  --height-row-lg: var(--row-height-lg);