@tcn/ui 0.12.0 → 0.12.2
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/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +39 -34
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -1
- package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/sip_input.js +57 -52
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +8 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +121 -111
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/surfaces/pop_confirm/pop_confirm.d.ts.map +1 -1
- package/dist/surfaces/pop_confirm/pop_confirm.js +18 -12
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
- package/dist/surfaces/tooltip/tooltip.d.ts.map +1 -1
- package/dist/surfaces/tooltip/tooltip.js +22 -20
- package/dist/surfaces/tooltip/tooltip.js.map +1 -1
- package/package.json +1 -1
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +7 -0
- package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +5 -0
- package/src/inputs/phone_number_input/sip_input.tsx +5 -0
- package/src/inputs/select/select.stories.tsx +34 -11
- package/src/inputs/suggestions/suggestion_list.tsx +23 -6
- package/src/surfaces/pop_confirm/pop_confirm.tsx +8 -2
- package/src/surfaces/tooltip/tooltip.tsx +2 -1
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { clsx as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as e, jsxs as u, Fragment as d } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as x } from "clsx";
|
|
3
|
+
import R, { useRef as _, isValidElement as h, cloneElement as w } from "react";
|
|
4
4
|
import { PreviewPopper as E } from "../../overlay/popper/preview_popper.js";
|
|
5
5
|
import { HStack as b } from "../../stacks/h_stack.js";
|
|
6
|
-
import '../../tooltip.css';const
|
|
6
|
+
import '../../tooltip.css';const j = "_tooltip_b8c58d5", P = { tooltip: j }, H = R.forwardRef(function({
|
|
7
7
|
children: o,
|
|
8
8
|
className: r,
|
|
9
9
|
verticalAnchor: n = "top",
|
|
10
10
|
verticalOrigin: c = "bottom",
|
|
11
|
-
horizontalAnchor:
|
|
12
|
-
horizontalOrigin:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
horizontalAnchor: l = "center",
|
|
12
|
+
horizontalOrigin: s = "center",
|
|
13
|
+
precision: m = "low",
|
|
14
|
+
// TODO: Fix caret styles and set to high
|
|
15
|
+
label: p,
|
|
16
|
+
...i
|
|
17
|
+
}, a) {
|
|
18
|
+
const t = _(null), f = h(o) ? w(o, { ref: t }) : /* @__PURE__ */ e(b, { as: "span", ref: t, children: o });
|
|
19
|
+
return /* @__PURE__ */ u(d, { children: [
|
|
20
|
+
f,
|
|
19
21
|
/* @__PURE__ */ e(
|
|
20
22
|
E,
|
|
21
23
|
{
|
|
22
|
-
ref:
|
|
24
|
+
ref: a,
|
|
23
25
|
anchorElement: t,
|
|
24
26
|
verticalAnchor: n,
|
|
25
27
|
verticalOrigin: c,
|
|
26
|
-
horizontalAnchor:
|
|
27
|
-
horizontalOrigin:
|
|
28
|
-
precision:
|
|
29
|
-
className:
|
|
30
|
-
...
|
|
31
|
-
children:
|
|
28
|
+
horizontalAnchor: l,
|
|
29
|
+
horizontalOrigin: s,
|
|
30
|
+
precision: m,
|
|
31
|
+
className: x(r, P.tooltip, "tcn-surface", "tcn-tooltip"),
|
|
32
|
+
...i,
|
|
33
|
+
children: p
|
|
32
34
|
}
|
|
33
35
|
)
|
|
34
36
|
] });
|
|
35
37
|
});
|
|
36
38
|
export {
|
|
37
|
-
|
|
39
|
+
H as Tooltip
|
|
38
40
|
};
|
|
39
41
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../../src/surfaces/tooltip/tooltip.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { isValidElement, cloneElement, useRef } from 'react';\nimport styles from './tooltip.module.css';\nimport {\n PreviewPopper,\n type PreviewPopperProps,\n} from '../../overlay/popper/preview_popper.js';\nimport { HStack } from '../../stacks/h_stack.js';\n\nexport interface TooltipProps extends Omit<PreviewPopperProps, 'anchorElement'> {\n /** The element that triggers the tooltip on hover */\n children: React.ReactNode;\n /** Content to display in the tooltip */\n label: React.ReactNode;\n}\n\nexport const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(function Tooltip(\n {\n children,\n className,\n verticalAnchor = 'top',\n verticalOrigin = 'bottom',\n horizontalAnchor = 'center',\n horizontalOrigin = 'center',\n label,\n ...props\n },\n ref\n) {\n const anchorRef = useRef<HTMLElement>(null);\n\n // If children is a valid element, clone it and attach the ref\n // Otherwise, wrap it in a span\n const anchor = isValidElement(children) ? (\n cloneElement(children, { ref: anchorRef } as React.Attributes)\n ) : (\n <HStack as=\"span\" ref={anchorRef}>\n {children}\n </HStack>\n );\n\n return (\n <>\n {anchor}\n <PreviewPopper\n ref={ref}\n anchorElement={anchorRef}\n verticalAnchor={verticalAnchor}\n verticalOrigin={verticalOrigin}\n horizontalAnchor={horizontalAnchor}\n horizontalOrigin={horizontalOrigin}\n precision
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../../src/surfaces/tooltip/tooltip.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { isValidElement, cloneElement, useRef } from 'react';\nimport styles from './tooltip.module.css';\nimport {\n PreviewPopper,\n type PreviewPopperProps,\n} from '../../overlay/popper/preview_popper.js';\nimport { HStack } from '../../stacks/h_stack.js';\n\nexport interface TooltipProps extends Omit<PreviewPopperProps, 'anchorElement'> {\n /** The element that triggers the tooltip on hover */\n children: React.ReactNode;\n /** Content to display in the tooltip */\n label: React.ReactNode;\n}\n\nexport const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(function Tooltip(\n {\n children,\n className,\n verticalAnchor = 'top',\n verticalOrigin = 'bottom',\n horizontalAnchor = 'center',\n horizontalOrigin = 'center',\n precision = 'low', // TODO: Fix caret styles and set to high\n label,\n ...props\n },\n ref\n) {\n const anchorRef = useRef<HTMLElement>(null);\n\n // If children is a valid element, clone it and attach the ref\n // Otherwise, wrap it in a span\n const anchor = isValidElement(children) ? (\n cloneElement(children, { ref: anchorRef } as React.Attributes)\n ) : (\n <HStack as=\"span\" ref={anchorRef}>\n {children}\n </HStack>\n );\n\n return (\n <>\n {anchor}\n <PreviewPopper\n ref={ref}\n anchorElement={anchorRef}\n verticalAnchor={verticalAnchor}\n verticalOrigin={verticalOrigin}\n horizontalAnchor={horizontalAnchor}\n horizontalOrigin={horizontalOrigin}\n precision={precision}\n className={clsx(className, styles.tooltip, 'tcn-surface', 'tcn-tooltip')}\n {...props}\n >\n {label}\n </PreviewPopper>\n </>\n );\n});\n"],"names":["Tooltip","React","children","className","verticalAnchor","verticalOrigin","horizontalAnchor","horizontalOrigin","precision","label","props","ref","anchorRef","useRef","anchor","isValidElement","cloneElement","jsx","HStack","jsxs","Fragment","PreviewPopper","clsx","styles"],"mappings":";;;;;kDAgBaA,IAAUC,EAAM,WAAyC,SACpE;AAAA,EACE,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AAAA,EACnB,kBAAAC,IAAmB;AAAA,EACnB,WAAAC,IAAY;AAAA;AAAA,EACZ,OAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAYC,EAAoB,IAAI,GAIpCC,IAASC,EAAeb,CAAQ,IACpCc,EAAad,GAAU,EAAE,KAAKU,EAAA,CAA+B,IAE7D,gBAAAK,EAACC,GAAA,EAAO,IAAG,QAAO,KAAKN,GACpB,UAAAV,GACH;AAGF,SACE,gBAAAiB,EAAAC,GAAA,EACG,UAAA;AAAA,IAAAN;AAAA,IACD,gBAAAG;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,KAAAV;AAAA,QACA,eAAeC;AAAA,QACf,gBAAAR;AAAA,QACA,gBAAAC;AAAA,QACA,kBAAAC;AAAA,QACA,kBAAAC;AAAA,QACA,WAAAC;AAAA,QACA,WAAWc,EAAKnB,GAAWoB,EAAO,SAAS,eAAe,aAAa;AAAA,QACtE,GAAGb;AAAA,QAEH,UAAAD;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ,CAAC;"}
|
package/package.json
CHANGED
|
@@ -139,6 +139,13 @@ export const WithPhoneBook = () => {
|
|
|
139
139
|
<Option value="+14355865955" label="Bob Johnson" keywords={['bob', 'johnson']}>
|
|
140
140
|
Bob Johnson - +1 (435) 586-5955
|
|
141
141
|
</Option>
|
|
142
|
+
<Option
|
|
143
|
+
value="+14355865950"
|
|
144
|
+
label="A Really Really Really Really Really Long Label For Jack"
|
|
145
|
+
keywords={['jack', 'johnson']}
|
|
146
|
+
>
|
|
147
|
+
A Really Really Really Really Reall Long Label - +1 (435) 586-5955
|
|
148
|
+
</Option>
|
|
142
149
|
<Option
|
|
143
150
|
value="sip:foo@bar.com"
|
|
144
151
|
label="Foo Sip"
|
|
@@ -112,6 +112,11 @@ export const PhoneNumberInputAdapter = forwardRef<
|
|
|
112
112
|
<SuggestionList
|
|
113
113
|
open={isPhoneBookOpen}
|
|
114
114
|
anchorElement={phoneBookElement}
|
|
115
|
+
horizontalAnchor="end"
|
|
116
|
+
horizontalOrigin="end"
|
|
117
|
+
verticalAnchor="top"
|
|
118
|
+
verticalOrigin="top"
|
|
119
|
+
width="300px"
|
|
115
120
|
onOptionSelect={handlePhoneBookOptionSelect}
|
|
116
121
|
onClose={closePhoneBook}
|
|
117
122
|
noSuggestionMessage="No phone numbers found"
|
|
@@ -138,7 +138,12 @@ export function SipInput({
|
|
|
138
138
|
anchorElement={phoneBookElement}
|
|
139
139
|
onOptionSelect={handlePhoneBookOptionSelect}
|
|
140
140
|
onClose={closePhoneBook}
|
|
141
|
+
width="300px"
|
|
141
142
|
noSuggestionMessage="No phone numbers found"
|
|
143
|
+
horizontalAnchor="end"
|
|
144
|
+
horizontalOrigin="end"
|
|
145
|
+
verticalAnchor="top"
|
|
146
|
+
verticalOrigin="top"
|
|
142
147
|
>
|
|
143
148
|
{phoneBookOptions}
|
|
144
149
|
</SuggestionList>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Option, type OptionProps } from '../options/option.js';
|
|
3
3
|
import { Select as SelectComponent, SelectProps } from './select.js';
|
|
4
4
|
import { HStack } from '../../stacks/h_stack.js';
|
|
5
5
|
import { VStack } from '../../stacks/v_stack.js';
|
|
6
6
|
import { Headline } from '../../typography/headline/headline.js';
|
|
7
7
|
import { BodyText } from '../../typography/body_text/body_text.js';
|
|
8
|
+
import { Button } from '../../actions/button/button/button.js';
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
title: 'Inputs/Select',
|
|
@@ -124,23 +125,45 @@ export function CustomWidth(_: Omit<SelectProps, 'children'>) {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
export function DelayedOptions() {
|
|
128
|
+
const timeoutRef = useRef<number | null>(null);
|
|
127
129
|
const [value, setValue] = useState<string>('');
|
|
128
130
|
const [options, setOptions] = useState<React.ReactElement<OptionProps>[]>([]);
|
|
129
131
|
|
|
130
132
|
useEffect(() => {
|
|
131
|
-
window.setTimeout(() => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
134
|
+
const length = options.length;
|
|
135
|
+
const newOptions = [
|
|
136
|
+
...options,
|
|
137
|
+
<Option
|
|
138
|
+
key={length}
|
|
139
|
+
value={String(length)}
|
|
140
|
+
label={String(length)}
|
|
141
|
+
keywords={[String(length)]}
|
|
142
|
+
>
|
|
143
|
+
{String(length)}
|
|
135
144
|
</Option>,
|
|
136
|
-
]
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
];
|
|
146
|
+
setOptions(newOptions);
|
|
147
|
+
}, 2000);
|
|
148
|
+
|
|
149
|
+
return () => {
|
|
150
|
+
window.clearTimeout(timeoutRef?.current || 0);
|
|
151
|
+
};
|
|
152
|
+
}, [options]);
|
|
139
153
|
|
|
140
154
|
return (
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
|
|
155
|
+
<>
|
|
156
|
+
<SelectComponent value={value} onChange={setValue} width="100px">
|
|
157
|
+
{options}
|
|
158
|
+
</SelectComponent>
|
|
159
|
+
<Button
|
|
160
|
+
onClick={() => {
|
|
161
|
+
window.clearInterval(timeoutRef.current ?? 0);
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
Stop
|
|
165
|
+
</Button>
|
|
166
|
+
</>
|
|
144
167
|
);
|
|
145
168
|
}
|
|
146
169
|
|
|
@@ -24,6 +24,7 @@ export interface SuggestionListProps
|
|
|
24
24
|
open?: boolean;
|
|
25
25
|
children?: React.ReactNode;
|
|
26
26
|
onChange?: (value: string) => void;
|
|
27
|
+
width?: string;
|
|
27
28
|
onOptionSelect?: (
|
|
28
29
|
value: string,
|
|
29
30
|
label: string | undefined,
|
|
@@ -39,6 +40,12 @@ export interface SuggestionListProps
|
|
|
39
40
|
cursorStartPosition: number | null,
|
|
40
41
|
cursorEndPosition: number | null
|
|
41
42
|
) => void;
|
|
43
|
+
verticalAnchor?: 'top' | 'center' | 'bottom';
|
|
44
|
+
verticalOrigin?: 'top' | 'center' | 'bottom';
|
|
45
|
+
verticalOffset?: number;
|
|
46
|
+
horizontalAnchor?: 'start' | 'center' | 'end';
|
|
47
|
+
horizontalOrigin?: 'start' | 'center' | 'end';
|
|
48
|
+
horizontalOffset?: number;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export function SuggestionList({
|
|
@@ -47,6 +54,7 @@ export function SuggestionList({
|
|
|
47
54
|
scrollToValue,
|
|
48
55
|
anchorElement,
|
|
49
56
|
open = false,
|
|
57
|
+
width = 'auto',
|
|
50
58
|
children,
|
|
51
59
|
onOptionSelect,
|
|
52
60
|
noSuggestionMessage = '-- No Matches --',
|
|
@@ -57,6 +65,12 @@ export function SuggestionList({
|
|
|
57
65
|
trimCustomInput = false,
|
|
58
66
|
haveValueAsOption = false,
|
|
59
67
|
restoreFocus = true,
|
|
68
|
+
verticalAnchor = 'top',
|
|
69
|
+
verticalOrigin = 'top',
|
|
70
|
+
verticalOffset = -4,
|
|
71
|
+
horizontalAnchor = 'start',
|
|
72
|
+
horizontalOrigin = 'start',
|
|
73
|
+
horizontalOffset = 0,
|
|
60
74
|
...props
|
|
61
75
|
}: SuggestionListProps) {
|
|
62
76
|
// Extract valid Option components from children
|
|
@@ -403,25 +417,28 @@ export function SuggestionList({
|
|
|
403
417
|
}, [searchValue]);
|
|
404
418
|
|
|
405
419
|
useLayoutEffect(() => {
|
|
406
|
-
const newMatches = getMatchedOptions(
|
|
420
|
+
const newMatches = getMatchedOptions(internalValue, MAX_RESULTS);
|
|
407
421
|
setMatchedOptions(newMatches);
|
|
408
|
-
}, [
|
|
422
|
+
}, [getMatchedOptions, internalValue]);
|
|
409
423
|
|
|
410
424
|
return (
|
|
411
425
|
<Popper
|
|
412
426
|
open={open}
|
|
413
427
|
anchorElement={anchorElement}
|
|
414
428
|
onClose={handleUseClose}
|
|
415
|
-
verticalAnchor=
|
|
416
|
-
verticalOrigin=
|
|
417
|
-
verticalOffset={
|
|
429
|
+
verticalAnchor={verticalAnchor}
|
|
430
|
+
verticalOrigin={verticalOrigin}
|
|
431
|
+
verticalOffset={verticalOffset}
|
|
432
|
+
horizontalAnchor={horizontalAnchor}
|
|
433
|
+
horizontalOrigin={horizontalOrigin}
|
|
434
|
+
horizontalOffset={horizontalOffset}
|
|
418
435
|
restoreFocus={restoreFocus}
|
|
419
436
|
>
|
|
420
437
|
<VStack
|
|
421
438
|
minHeight={`calc(${suggestionsHeight}, 8px)`}
|
|
422
439
|
maxHeight="300px"
|
|
423
440
|
minWidth={suggestionsWidth}
|
|
424
|
-
width=
|
|
441
|
+
width={width}
|
|
425
442
|
hAlign="start"
|
|
426
443
|
className={clsx(styles['suggestion-list'], 'tcn-suggestion-list')}
|
|
427
444
|
>
|
|
@@ -11,13 +11,19 @@ export type PopConfirmProps = ElementPopperProps;
|
|
|
11
11
|
|
|
12
12
|
export const PopConfirm = React.forwardRef<HTMLDivElement, PopConfirmProps>(
|
|
13
13
|
function PopConfirm(
|
|
14
|
-
{
|
|
14
|
+
{
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
precision = 'low',
|
|
18
|
+
dismissals = [PopperDismissal.CLICK_AWAY],
|
|
19
|
+
...props
|
|
20
|
+
},
|
|
15
21
|
ref
|
|
16
22
|
) {
|
|
17
23
|
return (
|
|
18
24
|
<ElementPopper
|
|
19
25
|
ref={ref}
|
|
20
|
-
precision=
|
|
26
|
+
precision={precision}
|
|
21
27
|
className={clsx(className, 'tcn-pop-confirm')}
|
|
22
28
|
dismissals={dismissals}
|
|
23
29
|
{...props}
|
|
@@ -22,6 +22,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(function T
|
|
|
22
22
|
verticalOrigin = 'bottom',
|
|
23
23
|
horizontalAnchor = 'center',
|
|
24
24
|
horizontalOrigin = 'center',
|
|
25
|
+
precision = 'low', // TODO: Fix caret styles and set to high
|
|
25
26
|
label,
|
|
26
27
|
...props
|
|
27
28
|
},
|
|
@@ -49,7 +50,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(function T
|
|
|
49
50
|
verticalOrigin={verticalOrigin}
|
|
50
51
|
horizontalAnchor={horizontalAnchor}
|
|
51
52
|
horizontalOrigin={horizontalOrigin}
|
|
52
|
-
precision=
|
|
53
|
+
precision={precision}
|
|
53
54
|
className={clsx(className, styles.tooltip, 'tcn-surface', 'tcn-tooltip')}
|
|
54
55
|
{...props}
|
|
55
56
|
>
|