@homecode/ui 5.3.1 → 5.3.4

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/dist/esm/index.js CHANGED
@@ -16,7 +16,7 @@ export { DropZone } from './src/components/DropZone/DropZone.js';
16
16
  export { Expand } from './src/components/Expand/Expand.js';
17
17
  export { Flex } from './src/components/Flex/Flex.js';
18
18
  export { Form } from './src/components/Form/Form.js';
19
- export { Gallery } from './src/components/Gallery/Gallery.js';
19
+ export { Gallery, normalizeGalleryItem } from './src/components/Gallery/Gallery.js';
20
20
  export { Heading } from './src/components/Heading/Heading.js';
21
21
  export { Icon } from './src/components/Icon/Icon.js';
22
22
  export { Input } from './src/components/Input/Input.js';
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { Component, createRef, useState, useRef, useLayoutEffect } from 'react';
2
+ import { Component, createRef, useState, useRef, useLayoutEffect, useEffect } from 'react';
3
3
  import { createStore } from 'justorm/react';
4
4
  import Time from 'timen';
5
5
  import compare from 'compareq';
@@ -13,6 +13,11 @@ import { circularSlice } from '../../tools/array.js';
13
13
  import S from './Gallery.styl.js';
14
14
  import { Lazy } from '../Lazy/Lazy.js';
15
15
 
16
+ function normalizeGalleryItem(item) {
17
+ if (typeof item === 'string')
18
+ return { src: item, kind: 'image' };
19
+ return { src: item.src, kind: item.kind ?? 'image' };
20
+ }
16
21
  const THRESHOLD = 50;
17
22
  const DURATION = 200;
18
23
  const DIR_NAME = {
@@ -32,12 +37,25 @@ function getInitialState(items, startIndex) {
32
37
  function Arr({ className, size, icon, ...rest }) {
33
38
  return (jsx(Button, { className: cn(S.arr, className), size: size, variant: "clear", ...rest, children: jsx(Icon, { type: icon, size: size }) }));
34
39
  }
35
- function Item({ src, size }) {
40
+ function VideoItem({ src, size, isActive, }) {
41
+ const [loaded, setLoaded] = useState(false);
42
+ const videoRef = useRef(null);
43
+ useEffect(() => {
44
+ const video = videoRef.current;
45
+ if (!video || isActive)
46
+ return;
47
+ video.pause();
48
+ }, [isActive, src]);
49
+ return (jsxs("div", { className: cn(S.item, S.videoItem), children: [jsx("video", { ref: videoRef, src: src, controls: true, playsInline: true, className: S.video, onLoadedData: () => setLoaded(true) }), !loaded && jsx(Spinner, { size: size })] }));
50
+ }
51
+ function Item({ src, kind, size, isActive, }) {
36
52
  const [loaded, setLoaded] = useState(false);
37
53
  const [isError, setIsError] = useState(false);
38
54
  const style = {};
39
55
  const imgRef = useRef(null);
40
56
  useLayoutEffect(() => {
57
+ if (kind === 'video')
58
+ return;
41
59
  const img = imgRef.current;
42
60
  if (!img || isError)
43
61
  return;
@@ -54,7 +72,10 @@ function Item({ src, size }) {
54
72
  };
55
73
  }
56
74
  if (typeof img.decode === 'function') {
57
- img.decode().then(notify).catch(() => { });
75
+ img
76
+ .decode()
77
+ .then(notify)
78
+ .catch(() => { });
58
79
  return () => {
59
80
  cancelled = true;
60
81
  };
@@ -68,7 +89,10 @@ function Item({ src, size }) {
68
89
  return () => {
69
90
  cancelled = true;
70
91
  };
71
- }, [src, isError]);
92
+ }, [src, isError, kind]);
93
+ if (kind === 'video') {
94
+ return jsx(VideoItem, { src: src, size: size, isActive: isActive });
95
+ }
72
96
  if (loaded)
73
97
  style.backgroundImage = `url(${src})`;
74
98
  return (jsx("div", { className: S.item, style: style, children: !loaded &&
@@ -114,13 +138,16 @@ class Gallery extends Component {
114
138
  this.setState({});
115
139
  }
116
140
  }
141
+ get normalizedItems() {
142
+ return this.props.items.map(normalizeGalleryItem);
143
+ }
117
144
  getStateItems() {
118
145
  return this.isSingle()
119
- ? [this.props.items[0]]
146
+ ? [this.normalizedItems[0]]
120
147
  : getInitialState(this.items, this.index);
121
148
  }
122
149
  recenter() {
123
- const [...items] = this.props.items;
150
+ const [...items] = this.normalizedItems;
124
151
  this.items = [items.pop(), ...items];
125
152
  }
126
153
  init() {
@@ -195,7 +222,8 @@ class Gallery extends Component {
195
222
  this.removeTransformDelta();
196
223
  this.setState({});
197
224
  const { onChange } = this.props;
198
- onChange?.(this.index, this.items[this.index]);
225
+ const active = this.items[this.index];
226
+ onChange?.(this.index, active.src);
199
227
  }
200
228
  render() {
201
229
  const { className, size, showArrows, showDots, initialBounce, cover, ...rest } = this.props;
@@ -213,10 +241,10 @@ class Gallery extends Component {
213
241
  props.onPointerLeave = this.onPointerUp;
214
242
  }
215
243
  }
216
- return (jsxs("div", { className: classes, ...props, children: [jsx("div", { className: innerClasses, ref: this.innerRef, children: items.map((src, i) => (jsx(Item, { src: src, size: size }, `${i}_${src}`))) }), !isSingle && showArrows && !isDragging && (jsxs(Fragment, { children: [jsx(Arr, { className: S.left, size: size, icon: "chevronLeft", onClick: () => this.move(1) }), jsx(Arr, { className: S.right, size: size, icon: "chevronRight", onClick: () => this.move(-1) })] })), showDots && (jsx(Lazy, { hideSpinner: true, loader: () => import('./Dots/Dots.js'),
244
+ return (jsxs("div", { className: classes, ...props, children: [jsx("div", { className: innerClasses, ref: this.innerRef, children: items.map((item, i) => (jsx(Item, { src: item.src, kind: item.kind, size: size, isActive: isSingle ? i === 0 : i === 1 }, `${i}_${item.src}_${item.kind}`))) }), !isSingle && showArrows && !isDragging && (jsxs(Fragment, { children: [jsx(Arr, { className: S.left, size: size, icon: "chevronLeft", onClick: () => this.move(1) }), jsx(Arr, { className: S.right, size: size, icon: "chevronRight", onClick: () => this.move(-1) })] })), showDots && (jsx(Lazy, { hideSpinner: true, loader: () => import('./Dots/Dots.js'),
217
245
  // @ts-ignore
218
246
  index: this.index % items.length, count: items.length }))] }));
219
247
  }
220
248
  }
221
249
 
222
- export { Gallery };
250
+ export { Gallery, normalizeGalleryItem };
@@ -1,7 +1,7 @@
1
1
  import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = ".Gallery_item__P4qTJ,.Gallery_root__-Crit{height:100%;width:100%}.Gallery_root__-Crit{overflow:hidden;position:relative}.Gallery_inner__4FAPt{-webkit-backface-visibility:hidden;backface-visibility:hidden;display:flex;height:100%;position:absolute;touch-action:none;transform:translate3d(-33.33333%,0,0);width:calc(300% + 1px)}.Gallery_single__Wfd9h .Gallery_inner__4FAPt{transform:none;width:100%}.Gallery_single__Wfd9h .Gallery_item__P4qTJ{width:100%}.Gallery_inner__4FAPt.Gallery_left__zrrmv,.Gallery_inner__4FAPt.Gallery_right__dpZ-m{transition:transform 0s ease-out;transition-duration:.2s}.Gallery_inner__4FAPt.Gallery_left__zrrmv{transform:translateZ(0)!important}.Gallery_inner__4FAPt.Gallery_right__dpZ-m{transform:translate3d(-66.66667%,0,0)!important}.Gallery_inner__4FAPt.Gallery_initialBounce__nZnKd{animation:Gallery_bounce__buqva 1s ease-out}.Gallery_item__P4qTJ{align-items:center;background-position:50%;background-repeat:no-repeat;background-size:contain;display:flex;justify-content:center;width:33.33333%}.Gallery_cover__ZGx5X .Gallery_item__P4qTJ{background-size:cover}.Gallery_item__P4qTJ>img{opacity:0;pointer-events:none;position:absolute}.Gallery_brokenImage__Bj3O-{height:50%;opacity:.2;width:50%}.Gallery_arr__knicI{background:transparent!important;height:100%;min-height:100%;opacity:0;padding:10%;position:absolute;top:0;transition:opacity .1s ease-out;z-index:1}.Gallery_arr__knicI.Gallery_left__zrrmv{justify-content:flex-start;left:0}.Gallery_arr__knicI.Gallery_right__dpZ-m{justify-content:flex-end;right:0;width:77%}.Gallery_arr__knicI:hover{opacity:1}@keyframes Gallery_bounce__buqva{0%{left:0}50%{left:-20%}80%{left:10%}to{left:0}}";
4
- var S = {"root":"Gallery_root__-Crit","item":"Gallery_item__P4qTJ","inner":"Gallery_inner__4FAPt","single":"Gallery_single__Wfd9h","left":"Gallery_left__zrrmv","right":"Gallery_right__dpZ-m","initialBounce":"Gallery_initialBounce__nZnKd","bounce":"Gallery_bounce__buqva","cover":"Gallery_cover__ZGx5X","brokenImage":"Gallery_brokenImage__Bj3O-","arr":"Gallery_arr__knicI"};
3
+ var css_248z = ".Gallery_item__P4qTJ,.Gallery_root__-Crit{height:100%;width:100%}.Gallery_root__-Crit{overflow:hidden;position:relative}.Gallery_inner__4FAPt{-webkit-backface-visibility:hidden;backface-visibility:hidden;display:flex;height:100%;position:absolute;touch-action:none;transform:translate3d(-33.33333%,0,0);width:calc(300% + 1px)}.Gallery_single__Wfd9h .Gallery_inner__4FAPt{transform:none;width:100%}.Gallery_single__Wfd9h .Gallery_item__P4qTJ{width:100%}.Gallery_inner__4FAPt.Gallery_left__zrrmv,.Gallery_inner__4FAPt.Gallery_right__dpZ-m{transition:transform 0s ease-out;transition-duration:.2s}.Gallery_inner__4FAPt.Gallery_left__zrrmv{transform:translateZ(0)!important}.Gallery_inner__4FAPt.Gallery_right__dpZ-m{transform:translate3d(-66.66667%,0,0)!important}.Gallery_inner__4FAPt.Gallery_initialBounce__nZnKd{animation:Gallery_bounce__buqva 1s ease-out}.Gallery_item__P4qTJ{align-items:center;background-position:50%;background-repeat:no-repeat;background-size:contain;display:flex;justify-content:center;width:33.33333%}.Gallery_cover__ZGx5X .Gallery_item__P4qTJ{background-size:cover}.Gallery_item__P4qTJ>img{opacity:0;pointer-events:none;position:absolute}.Gallery_brokenImage__Bj3O-{height:50%;opacity:.2;width:50%}.Gallery_videoItem__06r39 .Gallery_video__vKK23{max-height:100%;max-width:100%;-o-object-fit:contain;object-fit:contain}.Gallery_arr__knicI{background:transparent!important;height:100%;min-height:100%;opacity:0;padding:10%;position:absolute;top:0;transition:opacity .1s ease-out;z-index:1}.Gallery_arr__knicI.Gallery_left__zrrmv{justify-content:flex-start;left:0}.Gallery_arr__knicI.Gallery_right__dpZ-m{justify-content:flex-end;right:0;width:77%}.Gallery_arr__knicI:hover{opacity:1}@keyframes Gallery_bounce__buqva{0%{left:0}50%{left:-20%}80%{left:10%}to{left:0}}";
4
+ var S = {"root":"Gallery_root__-Crit","item":"Gallery_item__P4qTJ","inner":"Gallery_inner__4FAPt","single":"Gallery_single__Wfd9h","left":"Gallery_left__zrrmv","right":"Gallery_right__dpZ-m","initialBounce":"Gallery_initialBounce__nZnKd","bounce":"Gallery_bounce__buqva","cover":"Gallery_cover__ZGx5X","brokenImage":"Gallery_brokenImage__Bj3O-","videoItem":"Gallery_videoItem__06r39","video":"Gallery_video__vKK23","arr":"Gallery_arr__knicI"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { S as default };
@@ -1,6 +1,15 @@
1
1
  /** Keep in sync with `PromptComposer.styl` max/min heights. */
2
- const PROMPT_COMPOSER_MAX_HEIGHT_PX = 200;
3
2
  const PROMPT_COMPOSER_MIN_HEIGHT_PX = 40;
3
+ function safePromptComposerEditorText(editor) {
4
+ if (!editor || editor.isDestroyed)
5
+ return null;
6
+ try {
7
+ return editor.getText?.() ?? null;
8
+ }
9
+ catch {
10
+ return null;
11
+ }
12
+ }
4
13
  function promptComposerSafeEditorDom(editor) {
5
14
  if (!editor || editor.isDestroyed)
6
15
  return null;
@@ -22,7 +31,7 @@ function promptComposerFloorPx(cs) {
22
31
  : Number.parseFloat(cs.lineHeight) || fs * 1.25;
23
32
  return Math.max(PROMPT_COMPOSER_MIN_HEIGHT_PX, Math.ceil(linePx + padY));
24
33
  }
25
- /** Autosize `.ProseMirror` root: empty -> floor, text -> measured height with clamp. */
34
+ /** Autosize `.ProseMirror` root: empty -> floor, text -> measured content height. */
26
35
  function syncPromptComposerHeight(el, text) {
27
36
  const floor = promptComposerFloorPx(getComputedStyle(el));
28
37
  el.style.overflowY = 'hidden';
@@ -35,10 +44,9 @@ function syncPromptComposerHeight(el, text) {
35
44
  el.style.height = '0';
36
45
  contentHeight = el.scrollHeight;
37
46
  }
38
- const h = Math.min(Math.max(contentHeight, floor), PROMPT_COMPOSER_MAX_HEIGHT_PX);
47
+ const h = Math.max(contentHeight, floor);
39
48
  el.style.height = `${h}px`;
40
- el.style.overflowY =
41
- contentHeight > PROMPT_COMPOSER_MAX_HEIGHT_PX ? 'auto' : 'hidden';
49
+ el.style.overflowY = 'hidden';
42
50
  }
43
51
 
44
- export { PROMPT_COMPOSER_MAX_HEIGHT_PX, PROMPT_COMPOSER_MIN_HEIGHT_PX, promptComposerSafeEditorDom, syncPromptComposerHeight };
52
+ export { PROMPT_COMPOSER_MIN_HEIGHT_PX, promptComposerSafeEditorDom, safePromptComposerEditorText, syncPromptComposerHeight };
@@ -2,11 +2,12 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import cn from 'classnames';
3
3
  import { forwardRef, useMemo, useImperativeHandle } from 'react';
4
4
  import { EditorContent } from '@tiptap/react';
5
+ import { Scroll } from '../Scroll/Scroll.js';
5
6
  import S from './PromptComposer.styl.js';
6
7
  import { createPromptComposerHandle } from './promptComposerInsert.js';
7
8
  import { usePromptComposerEditor } from './usePromptComposerEditor.js';
8
9
 
9
- const PromptComposer = forwardRef(function PromptComposer({ disabled = false, placeholder, className, slashCommandItems, onSlashItemCommand, prefillMessage, attachmentsCount = 0, allowEnterSubmit = true, onSubmit, onChange, }, ref) {
10
+ const PromptComposer = forwardRef(function PromptComposer({ disabled = false, placeholder, className, slashCommandItems, onSlashItemCommand, prefillMessage, attachmentsCount = 0, allowEnterSubmit = true, onSubmit, onChange, scrollProps = {}, }, ref) {
10
11
  const { editor } = usePromptComposerEditor({
11
12
  disabled,
12
13
  placeholder,
@@ -29,7 +30,7 @@ const PromptComposer = forwardRef(function PromptComposer({ disabled = false, pl
29
30
  },
30
31
  }), []);
31
32
  useImperativeHandle(ref, () => (editor ? createPromptComposerHandle(editor) : unavailableHandle), [editor, unavailableHandle]);
32
- return (jsx("div", { className: cn(S.root, className), "data-disabled": disabled ? 'true' : 'false', children: jsx(EditorContent, { editor: editor, className: S.editorMount }) }));
33
+ return (jsx("div", { className: cn(S.root, className), "data-disabled": disabled ? 'true' : 'false', children: jsx(Scroll, { y: true, fadeSize: "s", ...scrollProps, className: S.scroller, children: jsx(EditorContent, { editor: editor, className: S.editorMount }) }) }));
33
34
  });
34
35
 
35
36
  export { PromptComposer };
@@ -1,7 +1,7 @@
1
1
  import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = ".PromptComposer_root__gfdXN{width:100%}.PromptComposer_editorMount__B9G-o{background:transparent;border:none;border-radius:0!important;box-shadow:none!important;display:flex;flex:1;flex-direction:column;max-height:200px;min-height:40px;min-width:0;padding:0!important}.PromptComposer_editorMount__B9G-o:focus-within{box-shadow:none!important}.PromptComposer_editorMount__B9G-o .promptComposerEditor{border:none!important;box-shadow:none!important;flex:1;margin:0;max-height:200px!important;min-height:40px!important;outline:none!important;overflow-x:hidden!important;overflow-y:auto!important;padding:var(--p-2) 0 0!important;resize:none!important;white-space:pre-wrap;word-break:break-word}.PromptComposer_editorMount__B9G-o .promptComposerEmptyEditor .promptComposerEmptyNode:before{color:var(--muted-foreground);content:attr(data-placeholder);float:left;height:0;pointer-events:none}";
4
- var S = {"root":"PromptComposer_root__gfdXN","editorMount":"PromptComposer_editorMount__B9G-o"};
3
+ var css_248z = ".PromptComposer_root__gfdXN{width:100%}.PromptComposer_scroller__Sueif{flex:1;max-height:200px;min-height:40px;width:100%}.PromptComposer_editorMount__B9G-o{background:transparent;border:none;border-radius:0!important;box-shadow:none!important;display:flex;flex:1;flex-direction:column;min-height:40px;min-width:0;padding:0!important}.PromptComposer_editorMount__B9G-o:focus-within{box-shadow:none!important}.PromptComposer_editorMount__B9G-o .promptComposerEditor{border:none!important;box-shadow:none!important;flex:1;margin:0;min-height:40px!important;outline:none!important;overflow:hidden!important;padding:var(--p-2) 0 0!important;resize:none!important;white-space:pre-wrap;word-break:break-word}.PromptComposer_editorMount__B9G-o .promptComposerEmptyEditor .promptComposerEmptyNode:before{color:var(--muted-foreground);content:attr(data-placeholder);float:left;height:0;pointer-events:none}";
4
+ var S = {"root":"PromptComposer_root__gfdXN","scroller":"PromptComposer_scroller__Sueif","editorMount":"PromptComposer_editorMount__B9G-o"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { S as default };
@@ -85,9 +85,13 @@ function createPromptComposerHandle(editor) {
85
85
  return {
86
86
  insertAtCaret: (content, options) => insertPromptComposerContentAtCaret(editor, content, options),
87
87
  focus: () => {
88
+ if (editor.isDestroyed)
89
+ return;
88
90
  editor.commands.focus();
89
91
  },
90
92
  reset: () => {
93
+ if (editor.isDestroyed)
94
+ return;
91
95
  editor.chain().clearContent().focus().run();
92
96
  },
93
97
  getText: () => editor.getText(),
@@ -4,7 +4,7 @@ import { useEditor } from '@tiptap/react';
4
4
  import StarterKit from '@tiptap/starter-kit';
5
5
  import { DEFAULT_CHAT_SLASH_ITEMS } from '../../tiptap/slash-mention/defaultChatSlashItems.js';
6
6
  import { createSlashMentionExtension } from '../../tiptap/slash-mention/createSlashMentionExtension.js';
7
- import { promptComposerSafeEditorDom, syncPromptComposerHeight } from './PromptComposer.helpers.js';
7
+ import { safePromptComposerEditorText, promptComposerSafeEditorDom, syncPromptComposerHeight } from './PromptComposer.helpers.js';
8
8
  import { PROMPT_COMPOSER_EMPTY_DOC, promptComposerParagraphDoc } from './promptComposerDoc.js';
9
9
 
10
10
  const PROMPT_COMPOSER_EDITOR_CLASS = 'promptComposerEditor';
@@ -67,7 +67,9 @@ function usePromptComposerEditor({ disabled, placeholder, slashCommandItems, onS
67
67
  const [text, setText] = useState('');
68
68
  const editorDomRef = useRef(null);
69
69
  const bindEditorDom = useCallback(({ editor }) => {
70
- const nextText = editor.getText();
70
+ const nextText = safePromptComposerEditorText(editor);
71
+ if (nextText == null)
72
+ return;
71
73
  setText(nextText);
72
74
  queueMicrotask(() => {
73
75
  const dom = promptComposerSafeEditorDom(editor);
@@ -119,8 +121,10 @@ function usePromptComposerEditor({ disabled, placeholder, slashCommandItems, onS
119
121
  handleKeyDown: handleEditorKeyDown,
120
122
  },
121
123
  onTransaction: ({ editor: activeEditor }) => {
124
+ const nextText = safePromptComposerEditorText(activeEditor);
125
+ if (nextText == null)
126
+ return;
122
127
  const dom = promptComposerSafeEditorDom(activeEditor);
123
- const nextText = activeEditor.getText();
124
128
  if (dom) {
125
129
  syncPromptComposerHeight(dom, nextText);
126
130
  }
@@ -152,23 +156,36 @@ function usePromptComposerEditor({ disabled, placeholder, slashCommandItems, onS
152
156
  };
153
157
  }, [editor]);
154
158
  useEffect(() => {
155
- if (!editor || prefillMessage == null)
159
+ if (!editor || prefillMessage == null || editor.isDestroyed)
160
+ return;
161
+ const current = safePromptComposerEditorText(editor);
162
+ if (current == null)
156
163
  return;
157
- const current = editor.getText();
158
164
  const next = prefillMessage;
159
165
  if (current === next)
160
166
  return;
161
- if (next === '') {
162
- editor.commands.setContent(PROMPT_COMPOSER_EMPTY_DOC);
167
+ try {
168
+ if (next === '') {
169
+ editor.commands.setContent(PROMPT_COMPOSER_EMPTY_DOC);
170
+ }
171
+ else {
172
+ editor.commands.setContent(promptComposerParagraphDoc(next));
173
+ }
163
174
  }
164
- else {
165
- editor.commands.setContent(promptComposerParagraphDoc(next));
175
+ catch {
176
+ return;
166
177
  }
167
- setText(editor.getText());
178
+ const synced = safePromptComposerEditorText(editor);
179
+ if (synced != null)
180
+ setText(synced);
168
181
  queueMicrotask(() => {
182
+ if (editor.isDestroyed)
183
+ return;
169
184
  const dom = promptComposerSafeEditorDom(editor);
170
- if (dom)
171
- syncPromptComposerHeight(dom, editor.getText());
185
+ const heightText = safePromptComposerEditorText(editor);
186
+ if (dom && heightText != null) {
187
+ syncPromptComposerHeight(dom, heightText);
188
+ }
172
189
  if (!disabled && !editor.isDestroyed) {
173
190
  editor.chain().focus('end').run();
174
191
  }
@@ -1,9 +1,15 @@
1
1
  import { Component } from 'react';
2
2
  import * as T from './Gallery.types';
3
+ export type { GalleryItem } from './Gallery.types';
4
+ export declare function normalizeGalleryItem(item: T.GalleryItem): {
5
+ src: string;
6
+ kind: 'image' | 'video';
7
+ };
8
+ type NormalizedItem = ReturnType<typeof normalizeGalleryItem>;
3
9
  type Direction = -1 | 1;
4
10
  export declare class Gallery extends Component<T.Props> {
5
11
  store: any;
6
- items: any;
12
+ items: NormalizedItem[];
7
13
  index: number;
8
14
  timers: any;
9
15
  startX: any;
@@ -17,6 +23,7 @@ export declare class Gallery extends Component<T.Props> {
17
23
  componentDidMount(): void;
18
24
  componentWillUnmount(): void;
19
25
  componentDidUpdate(prevProps: any): void;
26
+ get normalizedItems(): NormalizedItem[];
20
27
  getStateItems(): any[];
21
28
  recenter(): void;
22
29
  init(): void;
@@ -33,4 +40,3 @@ export declare class Gallery extends Component<T.Props> {
33
40
  switch(direction: Direction): void;
34
41
  render(): JSX.Element;
35
42
  }
36
- export {};
@@ -1,12 +1,16 @@
1
1
  import type { ComponentType, Size } from 'uilib/types';
2
+ export type GalleryItem = string | {
3
+ src: string;
4
+ kind?: 'image' | 'video';
5
+ };
2
6
  export type Props = ComponentType & {
3
- items: string[];
7
+ items: GalleryItem[];
4
8
  size?: Size;
5
9
  animation?: boolean;
6
10
  startIndex?: number;
7
11
  showArrows?: boolean;
8
12
  showDots?: boolean;
9
13
  initialBounce?: boolean;
10
- cover: true;
11
- onChange?: (index: number, item: string) => void;
14
+ cover?: boolean;
15
+ onChange?: (index: number, src: string) => void;
12
16
  };
@@ -10,4 +10,5 @@ export declare const PromptComposer: import("react").ForwardRefExoticComponent<i
10
10
  allowEnterSubmit?: boolean;
11
11
  onSubmit?: (text: string, editor: import("@tiptap/core").Editor) => void;
12
12
  onChange?: (text: string, editor: import("@tiptap/core").Editor) => void;
13
+ scrollProps?: Partial<import("../Scroll/Scroll.types").Props>;
13
14
  } & import("react").RefAttributes<PromptComposerHandle>>;
@@ -1,8 +1,12 @@
1
1
  /** Keep in sync with `PromptComposer.styl` max/min heights. */
2
2
  export declare const PROMPT_COMPOSER_MAX_HEIGHT_PX = 200;
3
3
  export declare const PROMPT_COMPOSER_MIN_HEIGHT_PX = 40;
4
+ export declare function safePromptComposerEditorText(editor: {
5
+ readonly isDestroyed?: boolean;
6
+ getText?: () => string;
7
+ } | null | undefined): string | null;
4
8
  export declare function promptComposerSafeEditorDom(editor: {
5
9
  readonly isDestroyed?: boolean;
6
10
  } | null | undefined): HTMLElement | null;
7
- /** Autosize `.ProseMirror` root: empty -> floor, text -> measured height with clamp. */
11
+ /** Autosize `.ProseMirror` root: empty -> floor, text -> measured content height. */
8
12
  export declare function syncPromptComposerHeight(el: HTMLElement, text: string): void;
@@ -1,6 +1,7 @@
1
1
  import type { Editor } from '@tiptap/core';
2
2
  import type { HTMLAttributes } from 'react';
3
3
  import type { SlashCommandItem, SlashOnItemCommand } from '../../tiptap/slash-mention';
4
+ import type { Props as ScrollProps } from '../Scroll/Scroll.types';
4
5
  export type Props = HTMLAttributes<HTMLDivElement> & {
5
6
  disabled?: boolean;
6
7
  placeholder?: string;
@@ -15,5 +16,6 @@ export type Props = HTMLAttributes<HTMLDivElement> & {
15
16
  onSubmit?: (text: string, editor: Editor) => void;
16
17
  /** Called on every transaction with plain text value. */
17
18
  onChange?: (text: string, editor: Editor) => void;
19
+ scrollProps?: Partial<ScrollProps>;
18
20
  };
19
21
  export type PromptComposerProps = Props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "5.3.1",
3
+ "version": "5.3.4",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "tests": "jest",
@@ -36,13 +36,15 @@
36
36
  "type": "git",
37
37
  "url": "git+https://github.com/foreverido/uilib.git"
38
38
  },
39
- "main": "dist/cjs",
39
+ "main": "./dist/esm/index.js",
40
40
  "module": "dist/esm",
41
41
  "types": "dist/esm/types/index.d.ts",
42
42
  "type": "module",
43
43
  "exports": {
44
44
  ".": {
45
45
  "import": "./dist/esm/index.js",
46
+ "require": "./dist/esm/index.js",
47
+ "default": "./dist/esm/index.js",
46
48
  "types": "./dist/esm/types/index.d.ts"
47
49
  },
48
50
  "./icons": {