@walkeros/storybook-addon 0.0.1
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/.eslintrc.js +15 -0
- package/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/manager.js +2 -0
- package/dist/manager.js.map +1 -0
- package/dist/preset.cjs +2 -0
- package/dist/preset.cjs.map +1 -0
- package/dist/preview.cjs +2 -0
- package/dist/preview.cjs.map +1 -0
- package/dist/preview.d.cts +20 -0
- package/dist/preview.d.ts +20 -0
- package/dist/preview.js +2 -0
- package/dist/preview.js.map +1 -0
- package/manager.js +1 -0
- package/package.json +111 -0
- package/preset.js +4 -0
- package/preview.js +1 -0
package/.eslintrc.js
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Storybook contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# @walkeros/storybook-addon
|
|
2
|
+
|
|
3
|
+
A Storybook addon that integrates walkerOS tagging support for data collection
|
|
4
|
+
and tracking validation. This addon helps you visualize and debug walkerOS
|
|
5
|
+
events in your Storybook stories, making it easier to validate your tracking
|
|
6
|
+
implementation during development.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- π **Event Visualization**: View all walkerOS events detected in your stories
|
|
11
|
+
in real-time
|
|
12
|
+
- π **Auto-refresh**: Automatically updates when navigating between stories or
|
|
13
|
+
changing story controls
|
|
14
|
+
- π **Detailed Event Information**: Inspect complete event data with JSON
|
|
15
|
+
syntax highlighting
|
|
16
|
+
- βοΈ **Configurable Settings**: Customize prefix and auto-refresh behavior
|
|
17
|
+
- π― **Story Arguments**: Pre-built arg types for walkerOS tagging attributes
|
|
18
|
+
- π **Zero Configuration**: Works out of the box with walkerOS data attributes
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Install the addon in your Storybook project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install --save-dev @walkeros/storybook-addon
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then register it in your Storybook configuration:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// .storybook/main.ts
|
|
32
|
+
import type { StorybookConfig } from '@storybook/react'; // or your framework
|
|
33
|
+
|
|
34
|
+
const config: StorybookConfig = {
|
|
35
|
+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
36
|
+
addons: [
|
|
37
|
+
'@storybook/addon-docs',
|
|
38
|
+
'@walkeros/storybook-addon', // π Add the walkerOS addon
|
|
39
|
+
],
|
|
40
|
+
framework: {
|
|
41
|
+
name: '@storybook/react', // or your framework
|
|
42
|
+
options: {},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default config;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Quick Start
|
|
52
|
+
|
|
53
|
+
1. **Install and register** the addon (see Installation above)
|
|
54
|
+
|
|
55
|
+
2. **Add walkerOS tracking** to your components using the `dataElb` prop
|
|
56
|
+
pattern:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { createTrackingProps, type DataElb } from '../utils/tagger';
|
|
60
|
+
|
|
61
|
+
interface ButtonProps {
|
|
62
|
+
label: string;
|
|
63
|
+
dataElb?: DataElb;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const Button = ({ label, dataElb }: ButtonProps) => {
|
|
67
|
+
const trackingProps = createTrackingProps(dataElb);
|
|
68
|
+
return <button {...trackingProps}>{label}</button>;
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
3. **View your story** - the walkerOS addon panel will automatically appear and
|
|
73
|
+
show detected events
|
|
74
|
+
|
|
75
|
+
4. **Configure as needed** using the addon's Config tab or story parameters
|
|
76
|
+
|
|
77
|
+
### Configure Storybook Controls
|
|
78
|
+
|
|
79
|
+
Add `dataElb` controls to your stories for easy tracking configuration:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// Button.stories.ts
|
|
83
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
84
|
+
import { Button } from './Button';
|
|
85
|
+
|
|
86
|
+
const meta: Meta<typeof Button> = {
|
|
87
|
+
title: 'Example/Button',
|
|
88
|
+
component: Button,
|
|
89
|
+
argTypes: {
|
|
90
|
+
dataElb: {
|
|
91
|
+
control: { type: 'object' },
|
|
92
|
+
description: 'walkerOS tracking configuration',
|
|
93
|
+
},
|
|
94
|
+
// ... your other arg types
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default meta;
|
|
99
|
+
type Story = StoryObj<typeof meta>;
|
|
100
|
+
|
|
101
|
+
export const Primary: Story = {
|
|
102
|
+
args: {
|
|
103
|
+
label: 'Button',
|
|
104
|
+
dataElb: {
|
|
105
|
+
entity: 'button',
|
|
106
|
+
action: 'click',
|
|
107
|
+
data: { category: 'primary' },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Configuration
|
|
114
|
+
|
|
115
|
+
The addon works with default settings out of the box, but you can customize its
|
|
116
|
+
behavior:
|
|
117
|
+
|
|
118
|
+
#### Global Configuration
|
|
119
|
+
|
|
120
|
+
Configure the addon globally in your Storybook preview:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
// .storybook/preview.ts
|
|
124
|
+
import type { Preview } from '@storybook/react';
|
|
125
|
+
|
|
126
|
+
const preview: Preview = {
|
|
127
|
+
parameters: {
|
|
128
|
+
// The addon automatically registers its own global configuration
|
|
129
|
+
// You can override defaults here if needed
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default preview;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Runtime Configuration
|
|
137
|
+
|
|
138
|
+
Use the addon's **Config tab** in the Storybook panel to adjust settings:
|
|
139
|
+
|
|
140
|
+
- **Auto-refresh**: Toggle automatic event updates
|
|
141
|
+
- **Prefix**: Change the data attribute prefix (default: `data-elb`)
|
|
142
|
+
|
|
143
|
+
These settings are saved and will persist across browser sessions.
|
|
144
|
+
|
|
145
|
+
## API Reference
|
|
146
|
+
|
|
147
|
+
### Exports
|
|
148
|
+
|
|
149
|
+
The addon exports the following types:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import {
|
|
153
|
+
DataElb, // TypeScript interface for dataElb prop
|
|
154
|
+
} from '@walkeros/storybook-addon';
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### `DataElb` Interface
|
|
158
|
+
|
|
159
|
+
TypeScript interface for the tracking prop pattern:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
interface DataElb {
|
|
163
|
+
entity?: string;
|
|
164
|
+
trigger?: string;
|
|
165
|
+
action?: string;
|
|
166
|
+
data?: WalkerOS.Properties; // Rich data objects
|
|
167
|
+
context?: WalkerOS.Properties; // Context information
|
|
168
|
+
globals?: WalkerOS.Properties; // Global properties
|
|
169
|
+
link?: Record<string, string>; // Link relationships
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Addon Configuration
|
|
174
|
+
|
|
175
|
+
The addon provides these configuration options (accessible via the Config tab):
|
|
176
|
+
|
|
177
|
+
#### `autoRefresh`
|
|
178
|
+
|
|
179
|
+
- **Type**: `boolean`
|
|
180
|
+
- **Default**: `true`
|
|
181
|
+
- **Description**: Automatically refresh events when navigating between stories
|
|
182
|
+
or changing controls
|
|
183
|
+
|
|
184
|
+
#### `prefix`
|
|
185
|
+
|
|
186
|
+
- **Type**: `string`
|
|
187
|
+
- **Default**: `'data-elb'`
|
|
188
|
+
- **Description**: Data attribute prefix used by walkerOS (must match your
|
|
189
|
+
walkerOS setup)
|
|
190
|
+
|
|
191
|
+
## How It Works
|
|
192
|
+
|
|
193
|
+
The addon works by:
|
|
194
|
+
|
|
195
|
+
1. **Event Detection**: Uses `getAllEvents` from `@walkeros/web-source-browser`
|
|
196
|
+
to scan your story's DOM for walkerOS data attributes
|
|
197
|
+
2. **Real-time Updates**: Automatically refreshes when stories change or
|
|
198
|
+
controls are updated
|
|
199
|
+
3. **Event Display**: Shows detailed information about each detected event with
|
|
200
|
+
JSON syntax highlighting
|
|
201
|
+
4. **Interactive UI**: Provides an expandable list interface for easy event
|
|
202
|
+
inspection
|
|
203
|
+
5. **Zero Configuration**: Works without initializing walkerOS - just add the
|
|
204
|
+
`dataElb` prop to your components
|
|
205
|
+
|
|
206
|
+
## Supported Frameworks
|
|
207
|
+
|
|
208
|
+
This addon works with any Storybook framework:
|
|
209
|
+
|
|
210
|
+
- React
|
|
211
|
+
- Vue
|
|
212
|
+
- Angular
|
|
213
|
+
- Web Components
|
|
214
|
+
- HTML
|
|
215
|
+
- Svelte
|
|
216
|
+
|
|
217
|
+
## Troubleshooting
|
|
218
|
+
|
|
219
|
+
### Events Not Showing
|
|
220
|
+
|
|
221
|
+
If events are not appearing in the addon panel:
|
|
222
|
+
|
|
223
|
+
1. **Check tracking implementation**: Ensure your components use the `dataElb`
|
|
224
|
+
prop:
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
<Button label="Click me" dataElb={{ entity: 'button', action: 'click' }} />
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
2. **Verify prefix**: Check that the prefix in the Config tab matches your
|
|
231
|
+
attributes (default: `data-elb`)
|
|
232
|
+
|
|
233
|
+
3. **Check rendering**: Ensure your components are actually rendered in the
|
|
234
|
+
story DOM
|
|
235
|
+
|
|
236
|
+
4. **Manual refresh**: Try clicking "Update events" button in the addon panel
|
|
237
|
+
|
|
238
|
+
5. **Console errors**: Check browser console for any JavaScript errors
|
|
239
|
+
|
|
240
|
+
### Common Issues
|
|
241
|
+
|
|
242
|
+
- **Empty event list**: Components may not have walkerOS attributes or the
|
|
243
|
+
prefix doesn't match
|
|
244
|
+
- **Outdated events**: Try disabling and re-enabling auto-refresh, or manually
|
|
245
|
+
refresh
|
|
246
|
+
- **Missing addon panel**: Ensure the addon is properly registered in
|
|
247
|
+
`.storybook/main.ts`
|
|
248
|
+
|
|
249
|
+
## Development
|
|
250
|
+
|
|
251
|
+
This addon is part of the
|
|
252
|
+
[walkerOS monorepo](https://github.com/elbwalker/walkerOS).
|
|
253
|
+
|
|
254
|
+
To contribute:
|
|
255
|
+
|
|
256
|
+
1. Clone the walkerOS repository
|
|
257
|
+
2. Run `npm install` in the root
|
|
258
|
+
3. Make changes in `apps/storybook-addon/`
|
|
259
|
+
4. Test with the demo in `apps/demos/storybook/`
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
MIT Β© [elbwalker GmbH](https://www.elbwalker.com)
|
|
264
|
+
|
|
265
|
+
## Links
|
|
266
|
+
|
|
267
|
+
- [walkerOS Documentation](https://docs.walkeros.com)
|
|
268
|
+
- [GitHub Repository](https://github.com/elbwalker/walkerOS)
|
|
269
|
+
- [walkerOS Website](https://www.walkeros.com)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WalkerOS } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
interface WalkerOSAddon {
|
|
4
|
+
autoRefresh: boolean;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
}
|
|
7
|
+
interface DataElb {
|
|
8
|
+
entity?: string;
|
|
9
|
+
trigger?: string;
|
|
10
|
+
action?: string;
|
|
11
|
+
data?: WalkerOS.Properties;
|
|
12
|
+
context?: WalkerOS.Properties;
|
|
13
|
+
globals?: WalkerOS.Properties;
|
|
14
|
+
link?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { DataElb, WalkerOSAddon };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WalkerOS } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
interface WalkerOSAddon {
|
|
4
|
+
autoRefresh: boolean;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
}
|
|
7
|
+
interface DataElb {
|
|
8
|
+
entity?: string;
|
|
9
|
+
trigger?: string;
|
|
10
|
+
action?: string;
|
|
11
|
+
data?: WalkerOS.Properties;
|
|
12
|
+
context?: WalkerOS.Properties;
|
|
13
|
+
globals?: WalkerOS.Properties;
|
|
14
|
+
link?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { DataElb, WalkerOSAddon };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/manager.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {useStorybookApi,useGlobals,useChannel,addons,types}from'storybook/manager-api';import {memo,useState,useCallback,useEffect,Fragment}from'react';import {AddonPanel,TabsState,Placeholder,Button,SyntaxHighlighter,Form}from'storybook/internal/components';import {styled,useTheme}from'storybook/theming';import {CURRENT_STORY_WAS_SET,SELECT_STORY,STORY_RENDERED,STORY_ARGS_UPDATED}from'storybook/internal/core-events';import {ArrowDownIcon}from'@storybook/icons';import {jsx,jsxs}from'react/jsx-runtime';var i="walkerOS",S=`${i}/panel`;var m={RESULT:`${i}/result`,REQUEST:`${i}/request`};var w=styled.ul({listStyle:"none",fontSize:14,padding:0,margin:0}),N=styled.div(({theme:e})=>({display:"flex",width:"100%",borderBottom:`1px solid ${e.appBorderColor}`,"&:hover":{background:e.background.hoverable}})),_=styled(ArrowDownIcon)(({theme:e})=>({height:10,width:10,minWidth:10,color:e.color.mediumdark,marginRight:10,transition:"transform 0.1s ease-in-out",alignSelf:"center",display:"inline-flex"})),W=styled.div(({theme:e})=>({padding:e.layoutMargin,paddingLeft:e.layoutMargin-3,background:"none",color:"inherit",textAlign:"left",cursor:"pointer",borderLeft:"3px solid transparent",width:"100%","&:focus":{outline:"0 none",borderLeft:`3px solid ${e.color.secondary}`}})),$=styled.div(({theme:e})=>({padding:e.layoutMargin,background:e.background.content,fontFamily:e.typography.fonts.mono,whiteSpace:"pre-wrap",textAlign:"left"})),U=({item:e})=>{let[r,s]=useState(true);return jsxs(Fragment,{children:[jsx(N,{children:jsxs(W,{onClick:()=>s(!r),role:"button",children:[jsx(_,{style:{transform:`rotate(${r?0:-90}deg)`}}),e.title]})}),r?jsx($,{children:e.content}):null]})},b=({items:e})=>jsx(w,{children:e.map((r,s)=>jsx(U,{item:r},s))});var A=memo(function(r){let s=useTheme(),c=useStorybookApi(),[x,L]=useGlobals(),n={...{autoRefresh:true,prefix:"data-elb"},...x[i]},[f,T]=useState([]),h=(t,a)=>{let D={...n,[t]:a};L({[i]:D});},E=useChannel({[m.RESULT]:t=>{T(t);}}),l=useCallback(()=>{E(m.REQUEST,n);},[n,E]);useEffect(()=>{n.autoRefresh&&l();},[]),useEffect(()=>{if(!n.autoRefresh)return;let t=[CURRENT_STORY_WAS_SET,SELECT_STORY,STORY_RENDERED,STORY_ARGS_UPDATED];return t.forEach(a=>c.on(a,l)),()=>t.forEach(a=>c.off(a,l))},[c,l,n.autoRefresh]);let C=t=>{let a=t.length==1?"Event":"Events";return `${t.length} ${a}`};return jsx(AddonPanel,{...r,children:jsxs(TabsState,{initial:"events",backgroundColor:s.background.hoverable,children:[jsx("div",{id:"events",title:C(f),children:jsxs(Placeholder,{children:[jsx(Fragment,{children:jsx(Button,{onClick:l,children:"Update events"})}),f.length>0?jsx(b,{items:f.map((t,a)=>({title:`#${a+1} ${t.entity} ${t.action}`,content:jsx(SyntaxHighlighter,{language:"json",copyable:true,bordered:true,padded:true,children:JSON.stringify(t,null,2)})}))}):jsx("p",{children:"No events yet"})]})}),jsx("div",{id:"config",title:"Config",children:jsx(Placeholder,{children:jsxs(Fragment,{children:[jsx(Form.Field,{label:"Auto-refresh",children:jsx("input",{type:"checkbox",id:"autoRefresh",checked:n.autoRefresh,onChange:t=>h("autoRefresh",t.target.checked)})}),jsx(Form.Field,{label:"Prefix",children:jsx(Form.Input,{name:"Prefix",value:n.prefix,placeholder:n.prefix,onChange:t=>h("prefix",t.target.value),size:"flex"})})]})})})]})})});addons.register(i,e=>{addons.add(S,{type:types.PANEL,title:i,match:({viewMode:r})=>r==="story",render:({active:r})=>jsx(A,{active:!!r})});});//# sourceMappingURL=manager.js.map
|
|
2
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/components/List.tsx","../src/components/Panel.tsx","../src/manager.tsx"],"names":["ADDON_ID","PANEL_ID","EVENTS","ListWrapper","styled","Wrapper","theme","Icon","ArrowDownIcon","HeaderBar","Description","ListItem","item","isOpen","onToggle","useState","jsxs","Fragment","jsx","List","items","idx","Panel","memo","props","useTheme","api","useStorybookApi","globals","updateGlobals","useGlobals","config","events","setState","updateConfig","key","value","newConfig","emit","useChannel","newEvents","updateEvents","useCallback","useEffect","storyEvents","CURRENT_STORY_WAS_SET","SELECT_STORY","STORY_RENDERED","STORY_ARGS_UPDATED","event","getEventTitle","form","AddonPanel","TabsState","Placeholder","Button","index","SyntaxHighlighter","Form","e","addons","types","viewMode","active"],"mappings":"2fAAO,IAAMA,CAAAA,CAAW,WACXC,CAAAA,CAAW,CAAA,EAAGD,CAAQ,CAAA,MAAA,CAAA,CAG5B,IAAME,EAAS,CACpB,MAAA,CAAQ,CAAA,EAAGF,CAAQ,UACnB,OAAA,CAAS,CAAA,EAAGA,CAAQ,CAAA,QAAA,CACtB,CAAA,CCUA,IAAMG,CAAAA,CAAcC,MAAAA,CAAO,GAAG,CAC5B,SAAA,CAAW,MAAA,CACX,QAAA,CAAU,GACV,OAAA,CAAS,CAAA,CACT,OAAQ,CACV,CAAC,EAEKC,CAAAA,CAAUD,MAAAA,CAAO,GAAA,CAAI,CAAC,CAAE,KAAA,CAAAE,CAAM,KAAO,CACzC,OAAA,CAAS,OACT,KAAA,CAAO,MAAA,CACP,YAAA,CAAc,CAAA,UAAA,EAAaA,EAAM,cAAc,CAAA,CAAA,CAC/C,UAAW,CACT,UAAA,CAAYA,EAAM,UAAA,CAAW,SAC/B,CACF,CAAA,CAAE,EAEIC,CAAAA,CAAOH,MAAAA,CAAOI,aAAa,CAAA,CAAE,CAAC,CAAE,KAAA,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,CAAW4B,CAAAA,EACTzB,EAAa,QAAA,CAAWyB,CAAAA,CAAE,OAA4B,KAAK,CAAA,CAE7D,KAAK,MAAA,CACP,CAAA,CACF,GACF,CAAA,CACF,CAAA,CACF,GACF,CAAA,CACF,CAEJ,CAAC,CAAA,CC9IDC,OAAO,QAAA,CAAS5D,CAAAA,CAAW0B,GAAQ,CACjCkC,MAAAA,CAAO,GAAA,CAAI3D,CAAAA,CAAU,CACnB,IAAA,CAAM4D,KAAAA,CAAM,MACZ,KAAA,CAAO7D,CAAAA,CACP,MAAO,CAAC,CAAE,QAAA,CAAA8D,CAAS,IAAMA,CAAAA,GAAa,OAAA,CACtC,OAAQ,CAAC,CAAE,OAAAC,CAAO,CAAA,GAAM7C,IAACI,CAAAA,CAAA,CAAM,OAAQ,CAAC,CAACyC,EAAQ,CACnD,CAAC,EACH,CAAC,CAAA","file":"manager.js","sourcesContent":["export const ADDON_ID = 'walkerOS';\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const KEY = `walkerOS`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n};\n","import { ArrowDownIcon } from '@storybook/icons';\nimport React, { Fragment, useState } from 'react';\nimport { styled } from 'storybook/theming';\n\ntype Item = {\n title: string;\n content: string | React.ReactNode;\n};\n\ninterface ListItemProps {\n item: Item;\n}\n\ninterface ListProps {\n items: Item[];\n}\n\nconst ListWrapper = styled.ul({\n listStyle: 'none',\n fontSize: 14,\n padding: 0,\n margin: 0,\n});\n\nconst Wrapper = styled.div(({ theme }) => ({\n display: 'flex',\n width: '100%',\n borderBottom: `1px solid ${theme.appBorderColor}`,\n '&:hover': {\n background: theme.background.hoverable,\n },\n}));\n\nconst Icon = styled(ArrowDownIcon)(({ theme }) => ({\n height: 10,\n width: 10,\n minWidth: 10,\n color: theme.color.mediumdark,\n marginRight: 10,\n transition: 'transform 0.1s ease-in-out',\n alignSelf: 'center',\n display: 'inline-flex',\n}));\n\nconst HeaderBar = styled.div(({ theme }) => ({\n padding: theme.layoutMargin,\n paddingLeft: theme.layoutMargin - 3,\n background: 'none',\n color: 'inherit',\n textAlign: 'left',\n cursor: 'pointer',\n borderLeft: '3px solid transparent',\n width: '100%',\n\n '&:focus': {\n outline: '0 none',\n borderLeft: `3px solid ${theme.color.secondary}`,\n },\n}));\n\nconst Description = styled.div(({ theme }) => ({\n padding: theme.layoutMargin,\n background: theme.background.content,\n fontFamily: theme.typography.fonts.mono,\n whiteSpace: 'pre-wrap',\n textAlign: 'left',\n}));\n\nexport const ListItem: React.FC<ListItemProps> = ({ item }) => {\n const [isOpen, onToggle] = useState(true);\n\n return (\n <Fragment>\n <Wrapper>\n <HeaderBar onClick={() => onToggle(!isOpen)} role=\"button\">\n <Icon\n style={{\n transform: `rotate(${isOpen ? 0 : -90}deg)`,\n }}\n />\n {item.title}\n </HeaderBar>\n </Wrapper>\n {isOpen ? <Description>{item.content}</Description> : null}\n </Fragment>\n );\n};\n\nexport const List: React.FC<ListProps> = ({ items }) => (\n <ListWrapper>\n {items.map((item, idx) => (\n <ListItem key={idx} item={item}></ListItem>\n ))}\n </ListWrapper>\n);\n","import type { WalkerOSAddon } from 'src/types';\nimport type { Events } from '@walkeros/web-source-browser';\nimport React, { Fragment, memo, useCallback, useEffect, useState } from 'react';\nimport {\n AddonPanel,\n Placeholder,\n TabsState,\n SyntaxHighlighter,\n Button,\n Form,\n} from 'storybook/internal/components';\nimport { useChannel, useGlobals, useStorybookApi } from 'storybook/manager-api';\nimport { useTheme } from 'storybook/theming';\nimport {\n STORY_ARGS_UPDATED,\n CURRENT_STORY_WAS_SET,\n SELECT_STORY,\n STORY_RENDERED,\n} from 'storybook/internal/core-events';\n\nimport { ADDON_ID, EVENTS } from '../constants';\nimport { List } from './List';\n\ninterface PanelProps {\n active: boolean;\n walkerOSAddon: WalkerOSAddon;\n}\n\nexport const Panel: React.FC<PanelProps> = memo(function MyPanel(props) {\n const theme = useTheme();\n const api = useStorybookApi();\n\n const [globals, updateGlobals] = useGlobals();\n\n const defaultConfig: WalkerOSAddon = {\n autoRefresh: true,\n prefix: 'data-elb',\n };\n const config = {\n ...defaultConfig,\n ...globals[ADDON_ID],\n } as WalkerOSAddon;\n\n const [events, setState] = useState<Events>([]);\n\n const updateConfig = (key: keyof WalkerOSAddon, value: unknown) => {\n const newConfig = { ...config, [key]: value };\n updateGlobals({ [ADDON_ID]: newConfig });\n };\n\n // https://storybook.js.org/docs/react/addons/addons-api#usechannel\n const emit = useChannel({\n [EVENTS.RESULT]: (newEvents: Events) => {\n setState(newEvents);\n },\n });\n\n const updateEvents = useCallback(() => {\n emit(EVENTS.REQUEST, config);\n }, [config, emit]);\n\n // Initial auto-refresh on page load\n useEffect(() => {\n if (config.autoRefresh) {\n updateEvents();\n }\n }, []); // Only run once on mount\n\n // Auto-refresh on story navigation and args updates\n useEffect(() => {\n if (!config.autoRefresh) return;\n\n // Events to listen for\n const storyEvents = [\n CURRENT_STORY_WAS_SET,\n SELECT_STORY,\n STORY_RENDERED,\n STORY_ARGS_UPDATED,\n ];\n\n // Listen for story navigation and control changes\n storyEvents.forEach((event) => api.on(event, updateEvents));\n // Cleanup listeners on unmount\n return () => storyEvents.forEach((event) => api.off(event, updateEvents));\n }, [api, updateEvents, config.autoRefresh]);\n\n const getEventTitle = (events: Events) => {\n const form = events.length == 1 ? 'Event' : 'Events';\n return `${events.length} ${form}`;\n };\n\n return (\n <AddonPanel {...props}>\n <TabsState\n initial=\"events\"\n backgroundColor={theme.background.hoverable as string}\n >\n <div id=\"events\" title={getEventTitle(events)}>\n <Placeholder>\n <Fragment>\n <Button onClick={updateEvents}>Update events</Button>\n </Fragment>\n {events.length > 0 ? (\n <List\n items={events.map((item, index) => ({\n title: `#${index + 1} ${item.entity} ${item.action}`,\n content: (\n <SyntaxHighlighter\n language=\"json\"\n copyable={true}\n bordered={true}\n padded={true}\n >\n {JSON.stringify(item, null, 2)}\n </SyntaxHighlighter>\n ),\n }))}\n />\n ) : (\n <p>No events yet</p>\n )}\n </Placeholder>\n </div>\n <div id=\"config\" title=\"Config\">\n <Placeholder>\n <Fragment>\n <Form.Field label=\"Auto-refresh\">\n <input\n type=\"checkbox\"\n id=\"autoRefresh\"\n checked={config.autoRefresh}\n onChange={(e) =>\n updateConfig('autoRefresh', e.target.checked)\n }\n />\n </Form.Field>\n <Form.Field label=\"Prefix\">\n <Form.Input\n name=\"Prefix\"\n value={config.prefix}\n placeholder={config.prefix}\n onChange={(e) =>\n updateConfig('prefix', (e.target as HTMLInputElement).value)\n }\n size=\"flex\"\n />\n </Form.Field>\n </Fragment>\n </Placeholder>\n </div>\n </TabsState>\n </AddonPanel>\n );\n});\n","import React from 'react';\nimport { addons, types } from 'storybook/manager-api';\n\nimport { Panel } from './components/Panel';\nimport { ADDON_ID, PANEL_ID } from './constants';\n\n/**\n * Note: if you want to use JSX in this file, rename it to `manager.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/manager.tsx\",\n */\n\naddons.register(ADDON_ID, (api) => {\n addons.add(PANEL_ID, {\n type: types.PANEL,\n title: ADDON_ID,\n match: ({ viewMode }) => viewMode === 'story',\n render: ({ active }) => <Panel active={!!active} />,\n });\n});\n"]}
|
package/dist/preset.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/preset.ts"],"names":["viteFinal","config","webpack"],"mappings":"aAAO,IAAMA,EAAY,MAAOC,CAAAA,EACvBA,CAAAA,CAGIC,CAAAA,CAAU,MAAOD,CAAAA,EACrBA","file":"preset.cjs","sourcesContent":["export const viteFinal = async (config: unknown) => {\n return config;\n};\n\nexport const webpack = async (config: unknown) => {\n return config;\n};\n"]}
|
package/dist/preview.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var previewApi=require('storybook/preview-api'),webSourceBrowser=require('@walkeros/web-source-browser');var e="walkerOS";var r={RESULT:`${e}/result`,REQUEST:`${e}/request`};var n=previewApi.addons.getChannel(),a=null;n.addListener(r.REQUEST,t=>{let o=a||document.querySelector("#storybook-root")||document.body,s=webSourceBrowser.getAllEvents(o,t.prefix);n.emit(r.RESULT,s);});var l=(t,o)=>(a=o.canvasElement,t());var c={decorators:[l],globalTypes:{[e]:{description:"walkerOS addon configuration",defaultValue:{autoRefresh:true,prefix:"data-elb"}}},initialGlobals:{[e]:{autoRefresh:true,prefix:"data-elb"}}},x=c;module.exports=x;//# sourceMappingURL=preview.cjs.map
|
|
2
|
+
//# sourceMappingURL=preview.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/withRoundTrip.ts","../src/preview.ts"],"names":["ADDON_ID","EVENTS","channel","addons","currentCanvasElement","config","canvasElement","events","getAllEvents","withRoundTrip","storyFn","context","preview","preview_default"],"mappings":"sHAAO,IAAMA,CAAAA,CAAW,UAAA,CAIjB,IAAMC,CAAAA,CAAS,CACpB,MAAA,CAAQ,CAAA,EAAGD,CAAQ,UACnB,OAAA,CAAS,CAAA,EAAGA,CAAQ,CAAA,QAAA,CACtB,CAAA,CCCA,IAAME,CAAAA,CAAUC,iBAAAA,CAAO,UAAA,EAAW,CAC9BC,CAAAA,CAAuC,IAAA,CAG3CF,EAAQ,WAAA,CAAYD,CAAAA,CAAO,OAAA,CAAUI,CAAAA,EAA0B,CAE7D,IAAMC,EACJF,CAAAA,EACA,QAAA,CAAS,aAAA,CAAc,iBAAiB,CAAA,EACxC,QAAA,CAAS,KAELG,CAAAA,CAASC,6BAAAA,CAAaF,CAAAA,CAA0BD,CAAAA,CAAO,MAAM,CAAA,CAGnEH,EAAQ,IAAA,CAAKD,CAAAA,CAAO,MAAA,CAAQM,CAAM,EACpC,CAAC,EAEM,IAAME,CAAAA,CAAmC,CAACC,CAAAA,CAASC,CAAAA,IAExDP,CAAAA,CAAuBO,EAAQ,aAAA,CAExBD,CAAAA,EAAQ,CAAA,CCTjB,IAAME,CAAAA,CAAwC,CAC5C,WAAY,CAACH,CAAa,CAAA,CAC1B,WAAA,CAAa,CACX,CAACT,CAAQ,EAAG,CACV,WAAA,CAAa,8BAAA,CACb,YAAA,CAAc,CACZ,YAAa,IAAA,CACb,MAAA,CAAQ,UACV,CACF,CACF,CAAA,CACA,eAAgB,CACd,CAACA,CAAQ,EAAG,CACV,WAAA,CAAa,IAAA,CACb,MAAA,CAAQ,UACV,CACF,CACF,CAAA,CAEOa,CAAAA,CAAQD","file":"preview.cjs","sourcesContent":["export const ADDON_ID = 'walkerOS';\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const KEY = `walkerOS`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n};\n","import type { WalkerOSAddon } from 'src/types';\nimport type { DecoratorFunction } from 'storybook/internal/types';\nimport { addons } from 'storybook/preview-api';\nimport { getAllEvents } from '@walkeros/web-source-browser';\n\nimport { EVENTS } from './constants';\n\n// Set up the channel listener globally, not per story\nconst channel = addons.getChannel();\nlet currentCanvasElement: Element | null = null;\n\n// Global listener for the request events\nchannel.addListener(EVENTS.REQUEST, (config: WalkerOSAddon) => {\n // Try to find the canvas element if we don't have it yet\n const canvasElement =\n currentCanvasElement ||\n document.querySelector('#storybook-root') ||\n document.body;\n\n const events = getAllEvents(canvasElement as Element, config.prefix);\n\n // Send the result back to the manager\n channel.emit(EVENTS.RESULT, events);\n});\n\nexport const withRoundTrip: DecoratorFunction = (storyFn, context) => {\n // Update the current canvas element when a story renders\n currentCanvasElement = context.canvasElement as Element;\n\n return storyFn();\n};\n","/**\n * A decorator is a way to wrap a story in extra βrenderingβ functionality. Many addons define decorators\n * in order to augment stories:\n * - with extra rendering\n * - gather details about how a story is rendered\n *\n * When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.\n *\n * https://storybook.js.org/docs/react/writing-stories/decorators\n */\nimport type { ProjectAnnotations, Renderer } from 'storybook/internal/types';\n\nimport { ADDON_ID } from './constants';\nimport { withRoundTrip } from './withRoundTrip';\n\n/**\n * Note: if you want to use JSX in this file, rename it to `preview.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/preview.tsx\",\n */\n\nconst preview: ProjectAnnotations<Renderer> = {\n decorators: [withRoundTrip],\n globalTypes: {\n [ADDON_ID]: {\n description: 'walkerOS addon configuration',\n defaultValue: {\n autoRefresh: true,\n prefix: 'data-elb',\n },\n },\n },\n initialGlobals: {\n [ADDON_ID]: {\n autoRefresh: true,\n prefix: 'data-elb',\n },\n },\n};\n\nexport default preview;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProjectAnnotations, Renderer } from 'storybook/internal/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A decorator is a way to wrap a story in extra βrenderingβ functionality. Many addons define decorators
|
|
5
|
+
* in order to augment stories:
|
|
6
|
+
* - with extra rendering
|
|
7
|
+
* - gather details about how a story is rendered
|
|
8
|
+
*
|
|
9
|
+
* When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.
|
|
10
|
+
*
|
|
11
|
+
* https://storybook.js.org/docs/react/writing-stories/decorators
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Note: if you want to use JSX in this file, rename it to `preview.tsx`
|
|
16
|
+
* and update the entry prop in tsup.config.ts to use "src/preview.tsx",
|
|
17
|
+
*/
|
|
18
|
+
declare const preview: ProjectAnnotations<Renderer>;
|
|
19
|
+
|
|
20
|
+
export { preview as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProjectAnnotations, Renderer } from 'storybook/internal/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A decorator is a way to wrap a story in extra βrenderingβ functionality. Many addons define decorators
|
|
5
|
+
* in order to augment stories:
|
|
6
|
+
* - with extra rendering
|
|
7
|
+
* - gather details about how a story is rendered
|
|
8
|
+
*
|
|
9
|
+
* When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.
|
|
10
|
+
*
|
|
11
|
+
* https://storybook.js.org/docs/react/writing-stories/decorators
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Note: if you want to use JSX in this file, rename it to `preview.tsx`
|
|
16
|
+
* and update the entry prop in tsup.config.ts to use "src/preview.tsx",
|
|
17
|
+
*/
|
|
18
|
+
declare const preview: ProjectAnnotations<Renderer>;
|
|
19
|
+
|
|
20
|
+
export { preview as default };
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {addons}from'storybook/preview-api';import {getAllEvents}from'@walkeros/web-source-browser';var e="walkerOS";var r={RESULT:`${e}/result`,REQUEST:`${e}/request`};var n=addons.getChannel(),a=null;n.addListener(r.REQUEST,t=>{let o=a||document.querySelector("#storybook-root")||document.body,s=getAllEvents(o,t.prefix);n.emit(r.RESULT,s);});var l=(t,o)=>(a=o.canvasElement,t());var c={decorators:[l],globalTypes:{[e]:{description:"walkerOS addon configuration",defaultValue:{autoRefresh:true,prefix:"data-elb"}}},initialGlobals:{[e]:{autoRefresh:true,prefix:"data-elb"}}},x=c;export{x as default};//# sourceMappingURL=preview.js.map
|
|
2
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/withRoundTrip.ts","../src/preview.ts"],"names":["ADDON_ID","EVENTS","channel","addons","currentCanvasElement","config","canvasElement","events","getAllEvents","withRoundTrip","storyFn","context","preview","preview_default"],"mappings":"mGAAO,IAAMA,CAAAA,CAAW,UAAA,CAIjB,IAAMC,CAAAA,CAAS,CACpB,MAAA,CAAQ,CAAA,EAAGD,CAAQ,UACnB,OAAA,CAAS,CAAA,EAAGA,CAAQ,CAAA,QAAA,CACtB,CAAA,CCCA,IAAME,CAAAA,CAAUC,MAAAA,CAAO,UAAA,EAAW,CAC9BC,CAAAA,CAAuC,IAAA,CAG3CF,EAAQ,WAAA,CAAYD,CAAAA,CAAO,OAAA,CAAUI,CAAAA,EAA0B,CAE7D,IAAMC,EACJF,CAAAA,EACA,QAAA,CAAS,aAAA,CAAc,iBAAiB,CAAA,EACxC,QAAA,CAAS,KAELG,CAAAA,CAASC,YAAAA,CAAaF,CAAAA,CAA0BD,CAAAA,CAAO,MAAM,CAAA,CAGnEH,EAAQ,IAAA,CAAKD,CAAAA,CAAO,MAAA,CAAQM,CAAM,EACpC,CAAC,EAEM,IAAME,CAAAA,CAAmC,CAACC,CAAAA,CAASC,CAAAA,IAExDP,CAAAA,CAAuBO,EAAQ,aAAA,CAExBD,CAAAA,EAAQ,CAAA,CCTjB,IAAME,CAAAA,CAAwC,CAC5C,WAAY,CAACH,CAAa,CAAA,CAC1B,WAAA,CAAa,CACX,CAACT,CAAQ,EAAG,CACV,WAAA,CAAa,8BAAA,CACb,YAAA,CAAc,CACZ,YAAa,IAAA,CACb,MAAA,CAAQ,UACV,CACF,CACF,CAAA,CACA,eAAgB,CACd,CAACA,CAAQ,EAAG,CACV,WAAA,CAAa,IAAA,CACb,MAAA,CAAQ,UACV,CACF,CACF,CAAA,CAEOa,CAAAA,CAAQD","file":"preview.js","sourcesContent":["export const ADDON_ID = 'walkerOS';\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const KEY = `walkerOS`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n};\n","import type { WalkerOSAddon } from 'src/types';\nimport type { DecoratorFunction } from 'storybook/internal/types';\nimport { addons } from 'storybook/preview-api';\nimport { getAllEvents } from '@walkeros/web-source-browser';\n\nimport { EVENTS } from './constants';\n\n// Set up the channel listener globally, not per story\nconst channel = addons.getChannel();\nlet currentCanvasElement: Element | null = null;\n\n// Global listener for the request events\nchannel.addListener(EVENTS.REQUEST, (config: WalkerOSAddon) => {\n // Try to find the canvas element if we don't have it yet\n const canvasElement =\n currentCanvasElement ||\n document.querySelector('#storybook-root') ||\n document.body;\n\n const events = getAllEvents(canvasElement as Element, config.prefix);\n\n // Send the result back to the manager\n channel.emit(EVENTS.RESULT, events);\n});\n\nexport const withRoundTrip: DecoratorFunction = (storyFn, context) => {\n // Update the current canvas element when a story renders\n currentCanvasElement = context.canvasElement as Element;\n\n return storyFn();\n};\n","/**\n * A decorator is a way to wrap a story in extra βrenderingβ functionality. Many addons define decorators\n * in order to augment stories:\n * - with extra rendering\n * - gather details about how a story is rendered\n *\n * When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.\n *\n * https://storybook.js.org/docs/react/writing-stories/decorators\n */\nimport type { ProjectAnnotations, Renderer } from 'storybook/internal/types';\n\nimport { ADDON_ID } from './constants';\nimport { withRoundTrip } from './withRoundTrip';\n\n/**\n * Note: if you want to use JSX in this file, rename it to `preview.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/preview.tsx\",\n */\n\nconst preview: ProjectAnnotations<Renderer> = {\n decorators: [withRoundTrip],\n globalTypes: {\n [ADDON_ID]: {\n description: 'walkerOS addon configuration',\n defaultValue: {\n autoRefresh: true,\n prefix: 'data-elb',\n },\n },\n },\n initialGlobals: {\n [ADDON_ID]: {\n autoRefresh: true,\n prefix: 'data-elb',\n },\n },\n};\n\nexport default preview;\n"]}
|
package/manager.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './dist/manager';
|
package/package.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/storybook-addon",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Integrate walkerOS tagging support for data collection",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tracking",
|
|
7
|
+
"data collection",
|
|
8
|
+
"tagging",
|
|
9
|
+
"storybook-addons"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/elbwalker/walkerOS",
|
|
14
|
+
"directory": "apps/storybook-addon"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "elbwalker GmbH <hello@elbwalker.com>",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"require": "./dist/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./preview": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/preview.js",
|
|
28
|
+
"require": "./dist/preview.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./preset": "./dist/preset.cjs",
|
|
31
|
+
"./manager": "./dist/manager.js",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/**/*",
|
|
36
|
+
"README.md",
|
|
37
|
+
"*.js",
|
|
38
|
+
"*.d.ts"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"build:watch": "npm run build -- --watch",
|
|
43
|
+
"test": "jest",
|
|
44
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"start": "run-p build:watch \"storybook --quiet\"",
|
|
47
|
+
"prerelease": "zx scripts/prepublish-checks.js",
|
|
48
|
+
"release": "npm run build && auto shipit",
|
|
49
|
+
"storybook": "storybook dev -p 6006",
|
|
50
|
+
"build-storybook": "storybook build"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@walkeros/core": "*",
|
|
54
|
+
"@walkeros/web-core": "*",
|
|
55
|
+
"@walkeros/web-source-browser": "*",
|
|
56
|
+
"@storybook/icons": "^1.4.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@walkeros/eslint": "*",
|
|
60
|
+
"@walkeros/jest": "*",
|
|
61
|
+
"@walkeros/tsconfig": "*",
|
|
62
|
+
"@walkeros/tsup": "*",
|
|
63
|
+
"@storybook/addon-docs": "^9.0.15",
|
|
64
|
+
"@storybook/react-vite": "^9.0.15",
|
|
65
|
+
"@types/node": "^22",
|
|
66
|
+
"@types/react": "^18.2.65",
|
|
67
|
+
"@types/react-dom": "^18.2.21",
|
|
68
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
69
|
+
"auto": "^11.1.1",
|
|
70
|
+
"boxen": "^7.1.1",
|
|
71
|
+
"npm-run-all2": "^6.2.3",
|
|
72
|
+
"prettier": "^3.3.3",
|
|
73
|
+
"prompts": "^2.4.2",
|
|
74
|
+
"react": "^18.2.0",
|
|
75
|
+
"react-dom": "^18.2.0",
|
|
76
|
+
"storybook": "^9.0.15",
|
|
77
|
+
"ts-dedent": "^2.2.0",
|
|
78
|
+
"tsup": "^8.2.4",
|
|
79
|
+
"typescript": "^5.8.2",
|
|
80
|
+
"vite": "^5.3.5",
|
|
81
|
+
"zx": "^8.4.1"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"storybook": "^9.0.15"
|
|
85
|
+
},
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public"
|
|
88
|
+
},
|
|
89
|
+
"bundler": {
|
|
90
|
+
"exportEntries": [
|
|
91
|
+
"src/index.ts"
|
|
92
|
+
],
|
|
93
|
+
"managerEntries": [
|
|
94
|
+
"src/manager.tsx"
|
|
95
|
+
],
|
|
96
|
+
"previewEntries": [
|
|
97
|
+
"src/preview.ts"
|
|
98
|
+
],
|
|
99
|
+
"nodeEntries": [
|
|
100
|
+
"src/preset.ts"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"storybook": {
|
|
104
|
+
"displayName": "walkerOS",
|
|
105
|
+
"supportedFrameworks": [
|
|
106
|
+
"react",
|
|
107
|
+
"html"
|
|
108
|
+
],
|
|
109
|
+
"icon": "https://user-images.githubusercontent.com/321738/63501763-88dbf600-c4cc-11e9-96cd-94adadc2fd72.png"
|
|
110
|
+
}
|
|
111
|
+
}
|
package/preset.js
ADDED
package/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/preview';
|