@nectary/components 4.6.5 → 4.6.7

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.
@@ -0,0 +1 @@
1
+ export type TSinchAvatarColor = 'blue' | 'dark-blue' | 'dark-gray' | 'dark-green' | 'dark-orange' | 'dark-pink' | 'dark-red' | 'dark-violet' | 'dark-yellow' | 'default' | 'gray' | 'green' | 'light-blue' | 'light-gray' | 'light-green' | 'light-orange' | 'light-pink' | 'light-red' | 'light-violet' | 'light-yellow' | 'orange' | 'pink' | 'red' | 'violet' | 'yellow' | 'away-default' | 'busy-default' | 'offline-default' | 'online-default';
@@ -0,0 +1 @@
1
+ export {};
package/avatar/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { TSinchAvatarColor } from './colors';
1
2
  import type { TSinchElementReact } from '../types';
2
3
  import type { TSinchSize } from '../utils/size';
3
4
  export type TSinchAvatarStatus = 'online' | 'busy' | 'away' | 'offline';
@@ -7,7 +8,7 @@ export type TSinchAvatarElement = HTMLElement & {
7
8
  /** Alt text */
8
9
  alt: string;
9
10
  /** Background color */
10
- color: string | null;
11
+ color: TSinchAvatarColor | null;
11
12
  /** Status */
12
13
  status: TSinchAvatarStatus | null;
13
14
  /** Size, `m` by default */
@@ -29,7 +30,7 @@ export type TSinchAvatarReact = TSinchElementReact<TSinchAvatarElement> & {
29
30
  /** Alt text */
30
31
  alt?: string;
31
32
  /** Background color */
32
- color?: string;
33
+ color?: TSinchAvatarColor;
33
34
  /** Size, `m` by default */
34
35
  size?: TSinchSize;
35
36
  /** Status */
@@ -0,0 +1 @@
1
+ export type TSinchChipColor = 'blue-default' | 'blue' | 'danger-default' | 'danger' | 'dark-blue-default' | 'dark-blue' | 'dark-gray-default' | 'dark-gray' | 'dark-green-default' | 'dark-green' | 'dark-orange-default' | 'dark-orange' | 'dark-pink-default' | 'dark-pink' | 'dark-red-default' | 'dark-red' | 'dark-violet-default' | 'dark-violet' | 'dark-yellow-default' | 'dark-yellow' | 'gray-default' | 'gray' | 'green-default' | 'green' | 'info-default' | 'info' | 'light-blue-default' | 'light-blue' | 'light-gray-default' | 'light-gray' | 'light-green-default' | 'light-green' | 'light-orange-default' | 'light-orange' | 'light-pink-default' | 'light-pink' | 'light-red-default' | 'light-red' | 'light-violet-default' | 'light-violet' | 'light-yellow-default' | 'light-yellow' | 'neutral-default' | 'neutral' | 'orange-default' | 'orange' | 'pink-default' | 'pink' | 'red-default' | 'red' | 'success-default' | 'success' | 'violet-default' | 'violet' | 'warning-default' | 'warning' | 'yellow-default' | 'yellow';
package/chip/colors.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/chip/types.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import type { TSinchChipColor } from './colors';
1
2
  import type { TSinchElementReact } from '../types';
2
3
  export type TSinchChipElement = HTMLElement & {
3
4
  /** Text */
4
5
  text: string;
5
6
  /** Color, gray by default */
6
- color: string | null;
7
+ color: TSinchChipColor | null;
7
8
  /** Small */
8
9
  small: boolean;
9
10
  /** Click event */
@@ -23,7 +24,7 @@ export type TSinchChipReact = TSinchElementReact<TSinchChipElement> & {
23
24
  /** Text */
24
25
  text: string;
25
26
  /** Color, gray by default */
26
- color?: string;
27
+ color?: TSinchChipColor;
27
28
  /** Small */
28
29
  small?: boolean;
29
30
  /** Click event handler */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "4.6.5",
3
+ "version": "4.6.7",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.22.15",
23
- "@nectary/assets": "2.2.0"
23
+ "@nectary/assets": "2.2.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/cli": "^7.22.15",
@@ -32,5 +32,8 @@
32
32
  "@types/react": "^18.2.21",
33
33
  "babel-plugin-html-inline-minifier": "workspace:*",
34
34
  "typescript": "^5.2.2"
35
+ },
36
+ "peerDependencies": {
37
+ "@nectary/theme-base": "1.4.0"
35
38
  }
36
39
  }
package/popover/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../pop';
2
2
  import { defineCustomElement, getBooleanAttribute, getLiteralAttribute, updateLiteralAttribute, updateBooleanAttribute, NectaryElement, updateAttribute, getReactEventHandler, isAttrTrue, setClass, rectOverlap, subscribeContext, isAttrEqual } from '../utils';
3
- const templateHTML = '<style>:host{display:contents}#content-wrapper{position:relative;padding-top:4px}:host([tip]) #content-wrapper{padding-top:12px;filter:drop-shadow(var(--sinch-comp-popover-shadow))}:host([orientation^=top]) #content-wrapper{padding-top:0;padding-bottom:4px}:host([orientation^=top][tip]) #content-wrapper{padding-top:0;padding-bottom:12px}#content{background-color:var(--sinch-comp-popover-color-default-background-initial);border:1px solid var(--sinch-comp-popover-color-default-border-initial);border-radius:var(--sinch-comp-popover-shape-radius);box-shadow:var(--sinch-comp-popover-shadow);overflow:hidden}:host([tip]) #content{box-shadow:none}#tip{position:absolute;left:50%;top:13px;transform:translateX(-50%) rotate(180deg);transform-origin:top center;fill:var(--sinch-comp-popover-color-default-background-initial);stroke:var(--sinch-comp-popover-color-default-border-initial);stroke-linecap:square;pointer-events:none;display:none}:host([orientation^=top]) #tip{transform:translateX(-50%) rotate(0);top:calc(100% - 13px)}:host([tip]) #tip:not(.hidden){display:block}</style><sinch-pop id="pop" inset="4"><slot name="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><slot name="content"></slot></div><svg id="tip" width="16" height="9" aria-hidden="true"><path d="m0 0 8 8 8 -8"/></svg></div></sinch-pop>';
3
+ const templateHTML = '<style>:host{display:contents}#content-wrapper{position:relative;padding-top:4px;width:fit-content;min-width:100%}:host([tip]) #content-wrapper{padding-top:12px;filter:drop-shadow(var(--sinch-comp-popover-shadow))}:host([orientation^=top]) #content-wrapper{padding-top:0;padding-bottom:4px}:host([orientation^=top][tip]) #content-wrapper{padding-top:0;padding-bottom:12px}#content{background-color:var(--sinch-comp-popover-color-default-background-initial);border:1px solid var(--sinch-comp-popover-color-default-border-initial);border-radius:var(--sinch-comp-popover-shape-radius);box-shadow:var(--sinch-comp-popover-shadow);overflow:hidden}:host([tip]) #content{box-shadow:none}#tip{position:absolute;left:50%;top:13px;transform:translateX(-50%) rotate(180deg);transform-origin:top center;fill:var(--sinch-comp-popover-color-default-background-initial);stroke:var(--sinch-comp-popover-color-default-border-initial);stroke-linecap:square;pointer-events:none;display:none}:host([orientation^=top]) #tip{transform:translateX(-50%) rotate(0);top:calc(100% - 13px)}:host([tip]) #tip:not(.hidden){display:block}</style><sinch-pop id="pop" inset="4"><slot name="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><slot name="content"></slot></div><svg id="tip" width="16" height="9" aria-hidden="true"><path d="m0 0 8 8 8 -8"/></svg></div></sinch-pop>';
4
4
  import { getPopOrientation, orientationValues } from './utils';
5
5
  const TIP_SIZE = 16;
6
6
  const template = document.createElement('template');
@@ -10,6 +10,7 @@ defineCustomElement('sinch-popover', class extends NectaryElement {
10
10
  #$content;
11
11
  #$tip;
12
12
  #controller = null;
13
+ #resizeObserver = null;
13
14
  constructor() {
14
15
  super();
15
16
  const shadowRoot = this.attachShadow();
@@ -31,10 +32,18 @@ defineCustomElement('sinch-popover', class extends NectaryElement {
31
32
  });
32
33
  subscribeContext(this.#$content, 'visibility', this.#onContextVisibility, signal);
33
34
  updateAttribute(this.#$pop, 'orientation', getPopOrientation(this.orientation));
35
+ this.#resizeObserver = new ResizeObserver(() => {
36
+ if (this.#$pop.open) {
37
+ this.#updateContentMaxWidth();
38
+ }
39
+ });
40
+ this.#resizeObserver.observe(document.body);
34
41
  }
35
42
  disconnectedCallback() {
36
43
  this.#controller.abort();
37
44
  this.#controller = null;
45
+ this.#resizeObserver?.disconnect();
46
+ this.#resizeObserver = null;
38
47
  }
39
48
  static get observedAttributes() {
40
49
  return ['orientation', 'open', 'modal', 'tip', 'aria-label', 'aria-description'];
@@ -119,6 +128,7 @@ defineCustomElement('sinch-popover', class extends NectaryElement {
119
128
  #onContextVisibility = e => {
120
129
  if (e.detail) {
121
130
  this.#updateTipOrientation();
131
+ this.#updateContentMaxWidth();
122
132
  } else {
123
133
  this.#resetTipOrientation();
124
134
  }
@@ -143,4 +153,9 @@ defineCustomElement('sinch-popover', class extends NectaryElement {
143
153
  this.#$tip.style.left = `${xPos}px`;
144
154
  setClass(this.#$tip, 'hidden', rectOverlap(targetRect, contentRect));
145
155
  };
156
+ #updateContentMaxWidth = () => {
157
+ const contentRect = this.#$content.getBoundingClientRect();
158
+ const availableSpace = window.innerWidth - contentRect.left - 16;
159
+ this.#$content.style.maxWidth = `${availableSpace}px`;
160
+ };
146
161
  });
@@ -0,0 +1 @@
1
+ export type TSinchTagColor = 'blue' | 'danger' | 'dark-blue' | 'dark-gray' | 'dark-green' | 'dark-orange' | 'dark-pink' | 'dark-red' | 'dark-violet' | 'dark-yellow' | 'default' | 'gray' | 'green' | 'info' | 'light-blue' | 'light-gray' | 'light-green' | 'light-orange' | 'light-pink' | 'light-red' | 'light-violet' | 'light-yellow' | 'orange' | 'pink' | 'red' | 'success' | 'violet' | 'warning' | 'yellow';
package/tag/colors.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/tag/types.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import type { TSinchTagColor } from './colors';
1
2
  import type { TSinchElementReact } from '../types';
2
3
  export type TSinchTagElement = HTMLElement & {
3
4
  /** Text */
4
5
  text: string;
5
6
  /** Color, gray by default */
6
- color: string | null;
7
+ color: TSinchTagColor | null;
7
8
  /** Small */
8
9
  small: boolean;
9
10
  /** Text */
@@ -17,7 +18,7 @@ export type TSinchTagReact = TSinchElementReact<TSinchTagElement> & {
17
18
  /** Text */
18
19
  text: string;
19
20
  /** Color, gray by default */
20
- color?: string;
21
+ color?: TSinchTagColor;
21
22
  /** Small */
22
23
  small?: boolean;
23
24
  } & {
@@ -3,4 +3,11 @@ export type TSinchCountry = {
3
3
  phoneCode: string;
4
4
  phoneMask: string | null;
5
5
  };
6
+ /**
7
+ * @deprecated -
8
+ * not up to date:
9
+ * - for a general list of country, https://www.npmjs.com/package/countries-list is a better choice
10
+ * - for validating phone numbers, we recommend https://www.npmjs.com/package/google-libphonenumber or https://www.npmjs.com/package/awesome-phonenumber
11
+ * - for the phone masks, we used the `countries-phone-masks` (https://www.npmjs.com/package/countries-phone-masks) in the example, but how well maintained it is is unknown.
12
+ **/
6
13
  export declare const countries: Record<string, TSinchCountry>;