@synergy-design-system/react 2.16.0 → 2.18.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.
- package/README.md +55 -2
- package/dist/chunks/{chunk.LS5YMLOL.js → chunk.WKTCEEC3.js} +1 -1
- package/dist/chunks/{chunk.LS5YMLOL.js.map → chunk.WKTCEEC3.js.map} +2 -2
- package/dist/components/range.d.ts +5 -0
- package/dist/components/range.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/syn-jsx-elements.d.ts +2765 -0
- package/dist/types/syn-jsx-elements.js +1 -0
- package/dist/types/syn-jsx-elements.js.map +7 -0
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -7,6 +7,10 @@ This package aims for an improved UX when used in React applications:
|
|
|
7
7
|
- Auto-completion
|
|
8
8
|
- Event handling
|
|
9
9
|
|
|
10
|
+
> Note that with react@19 and above, react has full support for web-components.
|
|
11
|
+
> For those react versions, this package can be used by loading custom types,
|
|
12
|
+
> you **do not need to use the exported components** anymore.
|
|
13
|
+
|
|
10
14
|
## Getting started
|
|
11
15
|
|
|
12
16
|
### 1. Package installation
|
|
@@ -54,14 +58,63 @@ createRoot(document.getElementById("root")!).render(
|
|
|
54
58
|
);
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
### 3.
|
|
61
|
+
### 3. Using native Synergy components in react (only for react >= 19.0.0) in Typescript projects
|
|
62
|
+
|
|
63
|
+
React@19 finally shipped with official support for web components.
|
|
64
|
+
With this version of react, you are free to **use our native web components** directly in your application.
|
|
65
|
+
|
|
66
|
+
However, you will likely receive errors because our elements are not known to React as available (in react speech `intrinsic`) elements. This will also occur when using typescript. For this reason, we provide **type only wrappers** for all versions of react from version 19.0.0 onward.
|
|
67
|
+
|
|
68
|
+
Using synergy in a typescript project with React@19 can be easily achieved via one line of code. There is no need to import `@synergy-design-system/react` in your code directly anymore!
|
|
69
|
+
|
|
70
|
+
Just add the following definition to your projects typescript configuration file (e.g. `tsconfig.json`):
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"compilerOptions": {
|
|
75
|
+
"types": ["@synergy-design-system/react/types/latest"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This makes sure your project knows about our list of intrinsic elements. This will also enable **automatic type checks and auto completion for properties** for all synergy elements.
|
|
81
|
+
|
|
82
|
+
You may now use the components by importing them from the `@synergy-design-system/component` package and rendering them in a React component.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
// You may also load the complete bundle somewhere in your application,
|
|
86
|
+
// but directly including only needed components leads to smaller bundles.
|
|
87
|
+
import "@synergy-design-system/components/components/button/button.js";
|
|
88
|
+
import "@synergy-design-system/components/components/input/input.js";
|
|
89
|
+
|
|
90
|
+
export const MyButton = () => <syn-button type="submit">Submit me</syn-button>;
|
|
91
|
+
export const MyInput = () => (
|
|
92
|
+
<syn-input name="my-input" onsyn-change={e => console.log(e)} required />
|
|
93
|
+
);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### 3.1. Migrating from synergies react wrappers to native components
|
|
97
|
+
|
|
98
|
+
1. First make sure you have react@19 or higher installed in your project.
|
|
99
|
+
2. Upgrade `@synergy-design-system/react` to the latest version.
|
|
100
|
+
3. Add the required types to your typescript configuration (`compilerOptions.types=['@synergy-design-system/react/types/latest']`).
|
|
101
|
+
4. Run typescript to verify everything is still fine.
|
|
102
|
+
5. Replace occurrences of the old synergy components with their native counterpart (e.g. `<SynButton>` should be exchanged for `<syn-button>`). When using native synergy components, make sure to double check on event names (e.g. `<SynInput onSynInput={e => null} />` will become `<syn-input onsyn-input={e => null} />`).
|
|
103
|
+
6. When you are done, remove all occurrences of `@synergy-design-system/react` from your code.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### 4. Using the lit wrappers (required for react < 19.0.0, optional for react >= 19.0.0)
|
|
58
108
|
|
|
59
109
|
You may now use the components by importing them from the `@synergy-design-system/react` package and rendering them in a React component.
|
|
60
110
|
|
|
61
111
|
```tsx
|
|
62
|
-
import { SynButton } from "@synergy-design-system/react";
|
|
112
|
+
import { SynButton, SynInput } from "@synergy-design-system/react";
|
|
63
113
|
|
|
64
114
|
export const MyButton = () => <SynButton type="submit">Submit me</SynButton>;
|
|
115
|
+
export const MyInput = () => (
|
|
116
|
+
<SynInput name="my-input" onSynChange={e => console.log(e)} required />
|
|
117
|
+
);
|
|
65
118
|
```
|
|
66
119
|
|
|
67
120
|
### 4. Usage of the components
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/range.ts"],
|
|
4
|
-
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED @synergy-design-system/react wrappers for @synergy-design-system/components\n// Please do not edit this file directly!\n// It will get recreated when running pnpm build.\n// ---------------------------------------------------------------------\nimport * as React from 'react';\nimport { createComponent } from '@lit/react';\nimport Component from '@synergy-design-system/components/components/range/range.component.js';\n\nimport { type EventName } from '@lit/react';\nimport type { SynBlurEvent } from '@synergy-design-system/components';\nimport type { SynChangeEvent } from '@synergy-design-system/components';\nimport type { SynFocusEvent } from '@synergy-design-system/components';\nimport type { SynInputEvent } from '@synergy-design-system/components';\nimport type { SynInvalidEvent } from '@synergy-design-system/components';\nimport type { SynMoveEvent } from '@synergy-design-system/components';\n\nconst tagName = 'syn-range';\nComponent.define('syn-range');\n\n/**\n * @summary Ranges allow the user to select values within a given range using one or two thumbs.\n * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-range--docs\n * @status stable\n *\n * @dependency syn-tooltip\n *\n * @slot label - The range's label. Alternatively, you can use the `label` attribute.\n * @slot prefix - Used to prepend a presentational icon or similar element to the range.\n * @slot suffix - Used to append a presentational icon or similar element to the range.\n * @slot help-text - Text that describes how to use the range.\n * Alternatively, you can use the `help-text` attribute.\n * @slot ticks - Used to display tick marks at specific intervals along the range.\n *\n * @event syn-blur - Emitted when the control loses focus.\n * @event syn-change - Emitted when an alteration to the control's value is committed by the user.\n * @event syn-focus - Emitted when the control gains focus.\n * @event syn-input - Emitted when the control receives input.\n * @event syn-invalid - Emitted when the form control has been checked for validity\n * and its constraints aren't satisfied.\n * @event syn-move - Emitted when the user moves a thumb, either via touch or keyboard.\n * Use `Event.preventDefault()` to prevent movement.\n *\n * @csspart form-control - The form control that wraps the label, input, and help text.\n * @csspart form-control-label - The label's wrapper.\n * @csspart form-control-help-text - The help text's wrapper.\n * @csspart base - The component's base wrapper.\n * @csspart input-wrapper - The container that wraps the input track and ticks.\n * @csspart track-wrapper - The wrapper for the track.\n * @csspart track - The inactive track.\n * @csspart active-track - The active track.\n * @csspart prefix - The container that wraps the prefix.\n * @csspart suffix - The container that wraps the suffix.\n * @csspart ticks - The container that wraps the tick marks.\n * @csspart thumb - The thumb(s) that the user can drag to change the range.\n *\n * @cssproperty --thumb-size - The size of a thumb.\n * @cssproperty --thumb-hit-area-size - The clickable area around the thumb.\n * Per default this is set to 140% of the thumb size. Must be a scale css value (defaults to 1.4).\n * @cssproperty --track-hit-area-size - The clickable area around the track (top and left).\n * @cssproperty --track-color-active - Color of the track representing the current value.\n * @cssproperty --track-color-inactive - Color of the track that represents the remaining value.\n * @cssproperty --track-height - The height of the track.\n * @cssproperty --track-active-offset - The point of origin of the active track,\n * starting at the left side of the range.\n */\nexport const SynRange = createComponent({\n displayName: 'SynRange',\n elementClass: Component,\n events: {\n onSynBlur: 'syn-blur' as EventName<SynBlurEvent>,\n onSynChange: 'syn-change' as EventName<SynChangeEvent>,\n onSynFocus: 'syn-focus' as EventName<SynFocusEvent>,\n onSynInput: 'syn-input' as EventName<SynInputEvent>,\n onSynInvalid: 'syn-invalid' as EventName<SynInvalidEvent>,\n onSynMove: 'syn-move' as EventName<SynMoveEvent>,\n },\n react: React,\n tagName,\n});\n\nexport type { SynBlurEvent } from '@synergy-design-system/components';\nexport type { SynChangeEvent } from '@synergy-design-system/components';\nexport type { SynFocusEvent } from '@synergy-design-system/components';\nexport type { SynInputEvent } from '@synergy-design-system/components';\nexport type { SynInvalidEvent } from '@synergy-design-system/components';\nexport type { SynMoveEvent } from '@synergy-design-system/components';\n"],
|
|
5
|
-
"mappings": ";AAKA,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,OAAO,eAAe;AAUtB,IAAM,UAAU;AAChB,UAAU,OAAO,WAAW;
|
|
4
|
+
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED @synergy-design-system/react wrappers for @synergy-design-system/components\n// Please do not edit this file directly!\n// It will get recreated when running pnpm build.\n// ---------------------------------------------------------------------\nimport * as React from 'react';\nimport { createComponent } from '@lit/react';\nimport Component from '@synergy-design-system/components/components/range/range.component.js';\n\nimport { type EventName } from '@lit/react';\nimport type { SynBlurEvent } from '@synergy-design-system/components';\nimport type { SynChangeEvent } from '@synergy-design-system/components';\nimport type { SynFocusEvent } from '@synergy-design-system/components';\nimport type { SynInputEvent } from '@synergy-design-system/components';\nimport type { SynInvalidEvent } from '@synergy-design-system/components';\nimport type { SynMoveEvent } from '@synergy-design-system/components';\n\nconst tagName = 'syn-range';\nComponent.define('syn-range');\n\n/**\n * @summary Ranges allow the user to select values within a given range using one or two thumbs.\n * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-range--docs\n * @status stable\n *\n * @dependency syn-tooltip\n *\n * @slot label - The range's label. Alternatively, you can use the `label` attribute.\n * @slot prefix - Used to prepend a presentational icon or similar element to the range.\n * @slot suffix - Used to append a presentational icon or similar element to the range.\n * @slot help-text - Text that describes how to use the range.\n * Alternatively, you can use the `help-text` attribute.\n * @slot ticks - Used to display tick marks at specific intervals along the range.\n *\n * @event syn-blur - Emitted when the control loses focus.\n * @event syn-change - Emitted when an alteration to the control's value is committed by the user.\n * @event syn-focus - Emitted when the control gains focus.\n * @event syn-input - Emitted when the control receives input.\n * @event syn-invalid - Emitted when the form control has been checked for validity\n * and its constraints aren't satisfied.\n * @event syn-move - Emitted when the user moves a thumb, either via touch or keyboard.\n * Use `Event.preventDefault()` to prevent movement.\n *\n * @csspart form-control - The form control that wraps the label, input, and help text.\n * @csspart form-control-label - The label's wrapper.\n * @csspart form-control-help-text - The help text's wrapper.\n * @csspart base - The component's base wrapper.\n * @csspart input-wrapper - The container that wraps the input track and ticks.\n * @csspart track-wrapper - The wrapper for the track.\n * @csspart track - The inactive track.\n * @csspart active-track - The active track.\n * @csspart prefix - The container that wraps the prefix.\n * @csspart suffix - The container that wraps the suffix.\n * @csspart ticks - The container that wraps the tick marks.\n * @csspart thumb - The thumb(s) that the user can drag to change the range.\n *\n * @csspart tooltip__base - The base of the tooltip\n * @csspart tooltip__arrow - The arrow of the tooltip\n * @csspart tooltip__popup - The popup of the tooltip\n * @csspart tooltip__body - The body of the tooltip\n *\n * @cssproperty --thumb-size - The size of a thumb.\n * @cssproperty --thumb-hit-area-size - The clickable area around the thumb.\n * Per default this is set to 140% of the thumb size. Must be a scale css value (defaults to 1.4).\n * @cssproperty --track-hit-area-size - The clickable area around the track (top and left).\n * @cssproperty --track-color-active - Color of the track representing the current value.\n * @cssproperty --track-color-inactive - Color of the track that represents the remaining value.\n * @cssproperty --track-height - The height of the track.\n * @cssproperty --track-active-offset - The point of origin of the active track,\n * starting at the left side of the range.\n */\nexport const SynRange = createComponent({\n displayName: 'SynRange',\n elementClass: Component,\n events: {\n onSynBlur: 'syn-blur' as EventName<SynBlurEvent>,\n onSynChange: 'syn-change' as EventName<SynChangeEvent>,\n onSynFocus: 'syn-focus' as EventName<SynFocusEvent>,\n onSynInput: 'syn-input' as EventName<SynInputEvent>,\n onSynInvalid: 'syn-invalid' as EventName<SynInvalidEvent>,\n onSynMove: 'syn-move' as EventName<SynMoveEvent>,\n },\n react: React,\n tagName,\n});\n\nexport type { SynBlurEvent } from '@synergy-design-system/components';\nexport type { SynChangeEvent } from '@synergy-design-system/components';\nexport type { SynFocusEvent } from '@synergy-design-system/components';\nexport type { SynInputEvent } from '@synergy-design-system/components';\nexport type { SynInvalidEvent } from '@synergy-design-system/components';\nexport type { SynMoveEvent } from '@synergy-design-system/components';\n"],
|
|
5
|
+
"mappings": ";AAKA,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,OAAO,eAAe;AAUtB,IAAM,UAAU;AAChB,UAAU,OAAO,WAAW;AAqDrB,IAAM,WAAW,gBAAgB;AAAA,EACtC,aAAa;AAAA,EACb,cAAc;AAAA,EACd,QAAQ;AAAA,IACN,WAAW;AAAA,IACX,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,WAAW;AAAA,EACb;AAAA,EACA,OAAO;AAAA,EACP;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -42,6 +42,11 @@ import type { SynMoveEvent } from '@synergy-design-system/components';
|
|
|
42
42
|
* @csspart ticks - The container that wraps the tick marks.
|
|
43
43
|
* @csspart thumb - The thumb(s) that the user can drag to change the range.
|
|
44
44
|
*
|
|
45
|
+
* @csspart tooltip__base - The base of the tooltip
|
|
46
|
+
* @csspart tooltip__arrow - The arrow of the tooltip
|
|
47
|
+
* @csspart tooltip__popup - The popup of the tooltip
|
|
48
|
+
* @csspart tooltip__body - The body of the tooltip
|
|
49
|
+
*
|
|
45
50
|
* @cssproperty --thumb-size - The size of a thumb.
|
|
46
51
|
* @cssproperty --thumb-hit-area-size - The clickable area around the thumb.
|
|
47
52
|
* Per default this is set to 140% of the thumb size. Must be a scale css value (defaults to 1.4).
|
package/dist/components/range.js
CHANGED