lupine.components 1.1.51 → 1.1.52

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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/component-pool/aspect-ratio/aspect-ratio.tsx +2 -2
  3. package/src/component-pool/avatar/avatar.tsx +3 -3
  4. package/src/component-pool/badge/badge.tsx +2 -2
  5. package/src/component-pool/breadcrumbs/breadcrumbs.tsx +2 -2
  6. package/src/component-pool/card/card.tsx +2 -2
  7. package/src/component-pool/carousel/carousel.tsx +2 -2
  8. package/src/component-pool/cascader/cascader.tsx +2 -2
  9. package/src/component-pool/charts/gauge-chart.tsx +3 -2
  10. package/src/component-pool/charts/pie-chart.tsx +3 -3
  11. package/src/component-pool/charts/radar-chart.tsx +11 -11
  12. package/src/component-pool/charts/scatter-chart.tsx +4 -4
  13. package/src/component-pool/copy-button/copy-button.tsx +2 -2
  14. package/src/component-pool/date-picker/date-picker.tsx +4 -4
  15. package/src/component-pool/floating-icon-menu/floating-icon-menu.tsx +3 -2
  16. package/src/component-pool/map-wrapper/map-wrapper.tsx +3 -4
  17. package/src/component-pool/radial-progress/radial-progress.tsx +2 -2
  18. package/src/component-pool/range/gauge.tsx +2 -2
  19. package/src/component-pool/range/range.tsx +2 -2
  20. package/src/component-pool/search-input/search-input.tsx +2 -2
  21. package/src/component-pool/skeleton/skeleton-card.tsx +2 -2
  22. package/src/component-pool/skeleton/skeleton.tsx +2 -2
  23. package/src/component-pool/tag-input/tag-input.tsx +3 -8
  24. package/src/component-pool/time-picker/time-picker.tsx +3 -3
  25. package/src/component-pool/timeline/timeline.tsx +2 -2
  26. package/src/component-pool/tooltip/tooltip.tsx +2 -2
  27. package/src/components/meta-data.tsx +1 -2
  28. package/src/components/meta-description.tsx +1 -2
  29. package/src/components/popup-menu.tsx +3 -3
  30. package/src/components/tabs.tsx +2 -2
  31. package/src/demo/demo-render-page.tsx +2 -0
  32. package/src/demo/mock/side-menu-mock.tsx +55 -58
  33. package/src/lib/index.ts +0 -1
  34. package/src/lib/encode-html.ts +0 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lupine.components",
3
- "version": "1.1.51",
3
+ "version": "1.1.52",
4
4
  "license": "MIT",
5
5
  "author": "uuware.com",
6
6
  "homepage": "https://github.com/uuware/lupine.js",
@@ -25,7 +25,7 @@ export const AspectRatio = (props: AspectRatioProps) => {
25
25
  bindGlobalStyle(globalCssId, css);
26
26
 
27
27
  const ref: RefProps = {
28
- globalCssId,
28
+ referToCssId: globalCssId,
29
29
  };
30
30
 
31
31
  const ratio = props.ratio ?? 16 / 9;
@@ -34,7 +34,7 @@ export const AspectRatio = (props: AspectRatioProps) => {
34
34
  const paddingTop = `${(1 / ratio) * 100}%`;
35
35
 
36
36
  return (
37
- <div class={['&-container', props.class].join(' ').trim()} ref={ref} css={{ paddingTop, ...props.style }}>
37
+ <div class={[globalCssId, '&-container', props.class].join(' ').trim()} ref={ref} css={{ paddingTop, ...props.style }}>
38
38
  <div class='&-inner'>{props.children}</div>
39
39
  </div>
40
40
  );
@@ -125,7 +125,7 @@ export const Avatar = (props: AvatarProps) => {
125
125
  const avatarContent = new HtmlVar(renderContent());
126
126
 
127
127
  const ref: RefProps = {
128
- globalCssId,
128
+ referToCssId: globalCssId,
129
129
  };
130
130
 
131
131
  return (
@@ -149,7 +149,7 @@ export const AvatarGroup = (props: AvatarGroupProps) => {
149
149
  bindGlobalStyle(globalCssId, groupCss);
150
150
 
151
151
  const ref: RefProps = {
152
- globalCssId,
152
+ referToCssId: globalCssId,
153
153
  };
154
154
 
155
155
  const children = Array.isArray(props.children) ? props.children : [props.children];
@@ -176,7 +176,7 @@ export const AvatarGroup = (props: AvatarGroupProps) => {
176
176
  }
177
177
 
178
178
  return (
179
- <div ref={ref} class={['&-group', props.class].join(' ').trim()} css={props.style}>
179
+ <div ref={ref} class={[globalCssId, '&-group', props.class].join(' ').trim()} css={props.style}>
180
180
  {items}
181
181
  </div>
182
182
  );
@@ -64,7 +64,7 @@ export const Badge = (props: BadgeProps) => {
64
64
  bindGlobalStyle(globalCssId, badgeCss);
65
65
 
66
66
  const ref: RefProps = {
67
- globalCssId,
67
+ referToCssId: globalCssId,
68
68
  };
69
69
 
70
70
  let displayContent = props.content;
@@ -85,7 +85,7 @@ export const Badge = (props: BadgeProps) => {
85
85
  const showBubble = props.dot || isSup;
86
86
 
87
87
  return (
88
- <div class={['&-container', props.class].join(' ').trim()} ref={ref} css={props.style} onClick={props.onClick}>
88
+ <div class={[globalCssId, '&-container', props.class].join(' ').trim()} ref={ref} css={props.style} onClick={props.onClick}>
89
89
  {/* The Anchor Element */}
90
90
  {props.children}
91
91
 
@@ -91,7 +91,7 @@ export const Breadcrumbs = (props: BreadcrumbsProps) => {
91
91
  let timer: any = null;
92
92
 
93
93
  const ref: RefProps = {
94
- globalCssId,
94
+ referToCssId: globalCssId,
95
95
  onLoad: async () => {
96
96
  if (!autoCollapse) return;
97
97
  const container = ref.current as HTMLElement;
@@ -157,7 +157,7 @@ export const Breadcrumbs = (props: BreadcrumbsProps) => {
157
157
 
158
158
  return (
159
159
  <nav
160
- class={['&-container', autoCollapse ? 'is-initializing' : '', props.class].join(' ').trim()}
160
+ class={[globalCssId, '&-container', autoCollapse ? 'is-initializing' : '', props.class].join(' ').trim()}
161
161
  ref={ref}
162
162
  css={props.style}
163
163
  aria-label='Breadcrumb'
@@ -120,14 +120,14 @@ export const Card = (props: CardProps) => {
120
120
  bindGlobalStyle(globalCssId, cardCss);
121
121
 
122
122
  const ref: RefProps = {
123
- globalCssId,
123
+ referToCssId: globalCssId,
124
124
  };
125
125
 
126
126
  const isHorizontal = props.horizontal ? 'horizontal' : '';
127
127
  const isHoverable = props.hoverable ? 'hoverable' : '';
128
128
 
129
129
  return (
130
- <div class={['&-container', isHorizontal, isHoverable, props.class].join(' ').trim()} ref={ref} css={props.style}>
130
+ <div class={[globalCssId, '&-container', isHorizontal, isHoverable, props.class].join(' ').trim()} ref={ref} css={props.style}>
131
131
  {props.cover && <div class='&-cover'>{props.cover}</div>}
132
132
 
133
133
  <div class='&-body'>
@@ -179,7 +179,7 @@ export const Carousel = (props: CarouselProps) => {
179
179
  };
180
180
 
181
181
  const ref: RefProps = {
182
- globalCssId,
182
+ referToCssId: globalCssId,
183
183
  onLoad: async () => {
184
184
  updateIndicators(0);
185
185
  startAutoplay();
@@ -191,7 +191,7 @@ export const Carousel = (props: CarouselProps) => {
191
191
 
192
192
  return (
193
193
  <div
194
- class={['&-container', props.class].join(' ').trim()}
194
+ class={[globalCssId, '&-container', props.class].join(' ').trim()}
195
195
  css={props.style}
196
196
  ref={ref}
197
197
  onMouseEnter={stopAutoplay}
@@ -160,7 +160,7 @@ export const Cascader = (props: CascaderProps) => {
160
160
  };
161
161
 
162
162
  const ref: RefProps = {
163
- globalCssId,
163
+ referToCssId: globalCssId,
164
164
  };
165
165
 
166
166
  const toggleClass = showCircle ? 'circle' : '';
@@ -190,7 +190,7 @@ export const Cascader = (props: CascaderProps) => {
190
190
 
191
191
  return (
192
192
  <div
193
- class={['&-container', props.class, initialState ? 'open' : ''].join(' ').trim()}
193
+ class={[globalCssId, '&-container', props.class, initialState ? 'open' : ''].join(' ').trim()}
194
194
  ref={ref}
195
195
  css={props.style}
196
196
  data-cascader-group={props.group}
@@ -10,6 +10,7 @@ export type GaugeChartProps = {
10
10
  color?: string;
11
11
  width?: string | number;
12
12
  height?: string | number;
13
+ aspectRatio?: number;
13
14
  valueFormatter?: (value: number) => string;
14
15
  };
15
16
 
@@ -60,7 +61,7 @@ export const GaugeChart = (props: GaugeChartProps) => {
60
61
  : '';
61
62
 
62
63
  const ref: RefProps = {
63
- globalCssId,
64
+ referToCssId: globalCssId,
64
65
  };
65
66
 
66
67
  const ratio = props.aspectRatio ?? 16 / 9;
@@ -69,7 +70,7 @@ export const GaugeChart = (props: GaugeChartProps) => {
69
70
  const styleStr = `width: ${props.width || '100%'};`;
70
71
 
71
72
  return (
72
- <div ref={ref} class='&-container' style={styleStr}>
73
+ <div ref={ref} class={[globalCssId, '&-container'].join(' ')} style={styleStr}>
73
74
  {props.title && <div class='chart-title'>{props.title}</div>}
74
75
 
75
76
  <div style={{ flex: 1, position: 'relative', display: 'flex', justifyContent: 'center', minHeight: 0, paddingTop }}>
@@ -22,7 +22,7 @@ export const PieChart = (props: PieChartProps) => {
22
22
  const viewBoxSize = 200;
23
23
  const center = viewBoxSize / 2;
24
24
  const maxRadius = (viewBoxSize / 2) * 0.9; // 90% of container to leave margin for stroke/anti-aliasing
25
-
25
+
26
26
  const globalInnerRadius = maxRadius * innerRadiusRatio;
27
27
  const numSeries = seriesList.length;
28
28
  // If only 1 series and innerRadiusRatio is 0, ringThickness is maxRadius.
@@ -94,7 +94,7 @@ export const PieChart = (props: PieChartProps) => {
94
94
  });
95
95
 
96
96
  const ref: RefProps = {
97
- globalCssId,
97
+ referToCssId: globalCssId,
98
98
  };
99
99
 
100
100
  const ratio = props.aspectRatio ?? 16 / 9;
@@ -103,7 +103,7 @@ export const PieChart = (props: PieChartProps) => {
103
103
  const styleStr = `width: ${props.width || '100%'}; min-height: 200px;`;
104
104
 
105
105
  return (
106
- <div ref={ref} class='&-container' style={styleStr}>
106
+ <div ref={ref} class={[globalCssId, '&-container'].join(' ')} style={styleStr}>
107
107
  {props.title && <div class='chart-title'>{props.title}</div>}
108
108
 
109
109
  <div
@@ -109,13 +109,13 @@ export const RadarChart = (props: RadarChartProps) => {
109
109
 
110
110
  // Fill area
111
111
  seriesGroupElements.push(
112
- <polygon
112
+ <polygon
113
113
  class="radar-polygon"
114
- points={pointsStr}
115
- fill={color}
116
- fillOpacity='0.15'
117
- stroke={color}
118
- strokeWidth='2'
114
+ points={pointsStr}
115
+ fill={color}
116
+ fillOpacity='0.15'
117
+ stroke={color}
118
+ strokeWidth='2'
119
119
  style={{ transition: 'fill-opacity 0.2s ease' }}
120
120
  />
121
121
  );
@@ -171,9 +171,9 @@ export const RadarChart = (props: RadarChartProps) => {
171
171
  };
172
172
 
173
173
  dataElements.push(
174
- <g
175
- class="radar-series"
176
- onMouseEnter={handleGroupMouseEnter}
174
+ <g
175
+ class="radar-series"
176
+ onMouseEnter={handleGroupMouseEnter}
177
177
  onMouseLeave={handleGroupMouseLeave}
178
178
  >
179
179
  {seriesGroupElements}
@@ -185,7 +185,7 @@ export const RadarChart = (props: RadarChartProps) => {
185
185
  };
186
186
 
187
187
  const ref: RefProps = {
188
- globalCssId,
188
+ referToCssId: globalCssId,
189
189
  };
190
190
 
191
191
  const ratio = props.aspectRatio ?? 16 / 9;
@@ -194,7 +194,7 @@ export const RadarChart = (props: RadarChartProps) => {
194
194
  const styleStr = `width: ${props.width || '100%'};`;
195
195
 
196
196
  return (
197
- <div ref={ref} class='&-container' style={styleStr}>
197
+ <div ref={ref} class={[globalCssId, '&-container'].join(' ')} style={styleStr}>
198
198
  {props.title && <div class='chart-title'>{props.title}</div>}
199
199
 
200
200
  <div style={{ flex: 1, position: 'relative', display: 'flex', justifyContent: 'center', minHeight: 0, paddingTop }}>
@@ -1,4 +1,4 @@
1
- import { bindGlobalStyle, getGlobalStylesId, HtmlVar } from 'lupine.components';
1
+ import { bindGlobalStyle, getGlobalStylesId, HtmlVar, RefProps } from 'lupine.components';
2
2
  import { chartCommonCss, getChartColor, BasicChartProps } from './chart-utils';
3
3
  import { Tooltip } from '../tooltip';
4
4
 
@@ -192,8 +192,8 @@ export const ScatterChart = (props: ScatterChartProps) => {
192
192
 
193
193
  const chartVar = new HtmlVar(renderChart(1000, 300));
194
194
 
195
- const ref = {
196
- globalCssId,
195
+ const ref: RefProps = {
196
+ referToCssId: globalCssId,
197
197
  onLoad: async (el: Element) => {
198
198
  const ro = new ResizeObserver((entries) => {
199
199
  const { width, height } = entries[0].contentRect;
@@ -217,7 +217,7 @@ export const ScatterChart = (props: ScatterChartProps) => {
217
217
  const styleStr = `width: ${props.width || '100%'};`;
218
218
 
219
219
  return (
220
- <div ref={ref} class='&-container' style={styleStr}>
220
+ <div ref={ref} class={[globalCssId, '&-container'].join(' ')} style={styleStr}>
221
221
  {props.title && <div class='chart-title'>{props.title}</div>}
222
222
 
223
223
  <div style={{ flex: 1, position: 'relative', minHeight: 0, paddingTop }}>{chartVar.node}</div>
@@ -114,7 +114,7 @@ export const CopyButton = (props: CopyButtonProps) => {
114
114
  };
115
115
 
116
116
  const ref: RefProps = {
117
- globalCssId,
117
+ referToCssId: globalCssId,
118
118
  };
119
119
 
120
120
  const variantClass = `variant-${props.variant || 'outline'}`;
@@ -132,7 +132,7 @@ export const CopyButton = (props: CopyButtonProps) => {
132
132
 
133
133
  return (
134
134
  <button
135
- class={['&-container', variantClass, props.class].join(' ').trim()}
135
+ class={[globalCssId, '&-container', variantClass, props.class].join(' ').trim()}
136
136
  ref={ref}
137
137
  css={props.style}
138
138
  type='button'
@@ -211,7 +211,7 @@ export const DatePicker = (props: DatePickerProps) => {
211
211
  const globalCssId = getGlobalStylesId(datePickerCss);
212
212
  bindGlobalStyle(globalCssId, datePickerCss);
213
213
 
214
- const ref: RefProps = { globalCssId };
214
+ const ref: RefProps = { referToCssId: globalCssId };
215
215
  let currentValue = props.value || '';
216
216
 
217
217
  const parseDate = (val: string) => {
@@ -241,7 +241,7 @@ export const DatePicker = (props: DatePickerProps) => {
241
241
  let isYearMenuOpen = false;
242
242
 
243
243
  const renderPanel = () => {
244
- const panelRef: RefProps = { globalCssId };
244
+ const panelRef: RefProps = { referToCssId: globalCssId };
245
245
  const gridVar = new HtmlVar('');
246
246
 
247
247
  const refreshGrid = () => {
@@ -332,7 +332,7 @@ export const DatePicker = (props: DatePickerProps) => {
332
332
  );
333
333
  }
334
334
 
335
- const ref2: RefProps = { globalCssId }; // used to replace the & in css
335
+ const ref2: RefProps = { referToCssId: globalCssId }; // used to replace the & in css
336
336
  return (
337
337
  <div class='&-grid' ref={ref2}>
338
338
  {daysNodes}
@@ -411,7 +411,7 @@ export const DatePicker = (props: DatePickerProps) => {
411
411
  };
412
412
 
413
413
  return (
414
- <div class='&-container' css={{ ...datePickerCss, ...props.style }} ref={ref}>
414
+ <div class={[globalCssId, '&-container'].join(' ')} css={{ ...datePickerCss, ...props.style }} ref={ref}>
415
415
  <input
416
416
  class={['&-input', props.className || 'input-base'].join(' ')}
417
417
  placeholder={props.placeholder || 'Select date'}
@@ -156,7 +156,7 @@ export const FloatingIconMenu = (props: FloatingIconMenuProps) => {
156
156
  bindGlobalStyle(globalCssId, css);
157
157
 
158
158
  const ref: RefProps = {
159
- globalCssId,
159
+ referToCssId: globalCssId,
160
160
  };
161
161
 
162
162
  const toggleMenu = () => {
@@ -197,7 +197,8 @@ export const FloatingIconMenu = (props: FloatingIconMenuProps) => {
197
197
  labelPos = top !== undefined ? 'bottom' : 'top';
198
198
  }
199
199
 
200
- const wrapperClass = ['floating-icon-menu', `dir-${direction}`, `label-pos-${labelPos}`, props.className]
200
+ // to avoid nest css, here need to add globalCssId as a class name
201
+ const wrapperClass = [globalCssId, 'floating-icon-menu', `dir-${direction}`, `label-pos-${labelPos}`, props.className]
201
202
  .filter(Boolean)
202
203
  .join(' ');
203
204
 
@@ -45,12 +45,11 @@ export const MapWrapper = (props: MapWrapperProps) => {
45
45
  const zoom = props.zoom ?? 13;
46
46
 
47
47
  const buildSrc = (lat: number, lng: number, zoom: number) =>
48
- `https://www.openstreetmap.org/export/embed.html?bbox=${lng - 0.05},${lat - 0.05},${lng + 0.05},${
49
- lat + 0.05
48
+ `https://www.openstreetmap.org/export/embed.html?bbox=${lng - 0.05},${lat - 0.05},${lng + 0.05},${lat + 0.05
50
49
  }&layer=mapnik&marker=${lat},${lng}`;
51
50
 
52
51
  const ref: RefProps = {
53
- globalCssId,
52
+ referToCssId: globalCssId,
54
53
  onLoad: async () => {
55
54
  const iframe = ref.$('.&-iframe') as HTMLIFrameElement;
56
55
  if (!iframe) return;
@@ -69,7 +68,7 @@ export const MapWrapper = (props: MapWrapperProps) => {
69
68
  const height = props.height || '300px';
70
69
 
71
70
  return (
72
- <div class={['&-container', props.class].join(' ').trim()} ref={ref} css={{ width, height, ...props.style }}>
71
+ <div class={[globalCssId, '&-container', props.class].join(' ').trim()} ref={ref} css={{ width, height, ...props.style }}>
73
72
  <iframe
74
73
  class='&-iframe'
75
74
  src={buildSrc(lat, lng, zoom)}
@@ -86,7 +86,7 @@ export const RadialProgress = (props: RadialProgressProps) => {
86
86
  }
87
87
 
88
88
  const containerRef: RefProps = {
89
- globalCssId,
89
+ referToCssId: globalCssId,
90
90
  };
91
91
 
92
92
  const progressColor = props.color || 'var(--primary-accent-color, #0a74c9)';
@@ -94,7 +94,7 @@ export const RadialProgress = (props: RadialProgressProps) => {
94
94
  const sizeClass = props.size || ButtonSize.Medium;
95
95
 
96
96
  return (
97
- <div class={['&-container', sizeClass, props.class].join(' ').trim()} ref={containerRef} css={props.style}>
97
+ <div class={[globalCssId, '&-container', sizeClass, props.class].join(' ').trim()} ref={containerRef} css={props.style}>
98
98
  <SvgSvg class='&-svg' viewBox='0 0 100 100'>
99
99
  <SvgCircle class='&-track' cx='50' cy='50' r='45' style={{ stroke: trackColor }} />
100
100
  <SvgCircle
@@ -291,7 +291,7 @@ export const Gauge = (props: GaugeProps) => {
291
291
  }
292
292
 
293
293
  const ref: RefProps & { onUnload?: (el: Element) => Promise<void> } = {
294
- globalCssId,
294
+ referToCssId: globalCssId,
295
295
  onLoad: async () => {
296
296
  updateVisuals();
297
297
  },
@@ -341,7 +341,7 @@ export const Gauge = (props: GaugeProps) => {
341
341
 
342
342
  return (
343
343
  <div
344
- class={['&-container', props.class, props.disabled ? 'disabled' : '', isReadonly ? 'readonly' : '']
344
+ class={[globalCssId, '&-container', props.class, props.disabled ? 'disabled' : '', isReadonly ? 'readonly' : '']
345
345
  .join(' ')
346
346
  .trim()}
347
347
  ref={ref}
@@ -328,7 +328,7 @@ export const Range = (props: RangeProps) => {
328
328
  }
329
329
 
330
330
  const ref: RefProps & { onUnload?: (el: Element) => Promise<void> | void } = {
331
- globalCssId,
331
+ referToCssId: globalCssId,
332
332
  onLoad: async () => {
333
333
  if (isVertical) {
334
334
  const wrapper = ref.$('.&-wrapper') as HTMLElement;
@@ -366,7 +366,7 @@ export const Range = (props: RangeProps) => {
366
366
 
367
367
  return (
368
368
  <div
369
- class={['&-container', props.class, props.disabled ? 'disabled' : '', isVertical ? 'vertical' : 'horizontal']
369
+ class={[globalCssId, '&-container', props.class, props.disabled ? 'disabled' : '', isVertical ? 'vertical' : 'horizontal']
370
370
  .join(' ')
371
371
  .trim()}
372
372
  ref={ref}
@@ -69,7 +69,7 @@ export const SearchInput = (props: InputWithClearProps) => {
69
69
  bindGlobalStyle(globalCssId, css);
70
70
 
71
71
  const ref: RefProps = {
72
- globalCssId,
72
+ referToCssId: globalCssId,
73
73
  };
74
74
 
75
75
  const onSearch = () => {
@@ -97,7 +97,7 @@ export const SearchInput = (props: InputWithClearProps) => {
97
97
  }
98
98
 
99
99
  return (
100
- <div ref={ref} class={['search-input', props.class].join(' ').trim()}>
100
+ <div ref={ref} class={[globalCssId, 'search-input', props.class].join(' ').trim()}>
101
101
  <input
102
102
  type='text'
103
103
  maxLength={30}
@@ -43,7 +43,7 @@ export const SkeletonCard = (props: SkeletonCardProps) => {
43
43
  const contentRef: RefProps = {};
44
44
 
45
45
  const ref: RefProps = {
46
- globalCssId,
46
+ referToCssId: globalCssId,
47
47
  onLoad: async () => {
48
48
  const container = ref.current as HTMLElement;
49
49
 
@@ -106,7 +106,7 @@ export const SkeletonCard = (props: SkeletonCardProps) => {
106
106
 
107
107
  // Avatar size is fixed to 48px to represent a typical user profile
108
108
  return (
109
- <div class={['&-container', props.class].join(' ').trim()} ref={ref} css={mergedStyle} aria-hidden='true'>
109
+ <div class={[globalCssId, '&-container', props.class].join(' ').trim()} ref={ref} css={mergedStyle} aria-hidden='true'>
110
110
  <Skeleton width='48px' height='48px' circle={true} animated={animated} />
111
111
  <div class='&-content' ref={contentRef}></div>
112
112
  </div>
@@ -34,7 +34,7 @@ export const Skeleton = (props: SkeletonProps) => {
34
34
  bindGlobalStyle(globalCssId, css);
35
35
 
36
36
  const ref: RefProps = {
37
- globalCssId,
37
+ referToCssId: globalCssId,
38
38
  };
39
39
 
40
40
  const isAnimated = props.animated !== false; // defaults to true
@@ -50,7 +50,7 @@ export const Skeleton = (props: SkeletonProps) => {
50
50
 
51
51
  return (
52
52
  <div
53
- class={['&-container', isAnimated ? 'is-animated' : '', isCircle ? 'is-circle' : '', props.class]
53
+ class={[globalCssId, '&-container', isAnimated ? 'is-animated' : '', isCircle ? 'is-circle' : '', props.class]
54
54
  .join(' ')
55
55
  .trim()}
56
56
  ref={ref}
@@ -89,7 +89,7 @@ export const TagInput = ({
89
89
  bindGlobalStyle(globalCssId, tagInputCss);
90
90
 
91
91
  const ref: RefProps = {
92
- globalCssId,
92
+ referToCssId: globalCssId,
93
93
  };
94
94
 
95
95
  let currentSelection = [...selectedIndices];
@@ -97,7 +97,7 @@ export const TagInput = ({
97
97
  const renderTags = () => {
98
98
  // pass globalCssId for & in classname
99
99
  const tempRef: RefProps = {
100
- globalCssId,
100
+ referToCssId: globalCssId,
101
101
  };
102
102
  if (currentSelection.length === 0) {
103
103
  return (
@@ -158,13 +158,8 @@ export const TagInput = ({
158
158
  };
159
159
 
160
160
  const dom = new HtmlVar(renderTags());
161
-
162
- // Combine native classes, framework namespace (from globalCssId), and optional extra classes
163
- let finalClass = cls || '';
164
- if (disabled) finalClass += ' disabled';
165
-
166
161
  return (
167
- <div ref={ref} css={extraCss} class={finalClass} onClick={openSelector}>
162
+ <div ref={ref} css={extraCss} class={[globalCssId, cls, disabled ? 'disabled' : ''].filter(Boolean).join(' ')} onClick={openSelector}>
168
163
  {dom.node}
169
164
  </div>
170
165
  );
@@ -133,7 +133,7 @@ export const TimePicker = (props: TimePickerProps) => {
133
133
  const globalCssId = getGlobalStylesId(timePickerCss);
134
134
  bindGlobalStyle(globalCssId, timePickerCss);
135
135
 
136
- const ref: RefProps = { globalCssId };
136
+ const ref: RefProps = { referToCssId: globalCssId };
137
137
  let currentValue = props.value || '';
138
138
 
139
139
  const parseValue = (val: string) => {
@@ -189,7 +189,7 @@ export const TimePicker = (props: TimePickerProps) => {
189
189
  const seconds = Array.from({ length: 60 }, (_, i) => i);
190
190
 
191
191
  const panelRef: RefProps = {
192
- globalCssId,
192
+ referToCssId: globalCssId,
193
193
  onLoad: async () => {
194
194
  setTimeout(highlightSelection, 10);
195
195
  },
@@ -285,7 +285,7 @@ export const TimePicker = (props: TimePickerProps) => {
285
285
  };
286
286
 
287
287
  return (
288
- <div class='&-container' css={props.style} ref={ref}>
288
+ <div class={[globalCssId, '&-container'].join(' ')} css={props.style} ref={ref}>
289
289
  <input
290
290
  class={['&-input', props.className || 'input-base'].join(' ')}
291
291
  placeholder={props.placeholder || 'Select time'}
@@ -96,7 +96,7 @@ export const Timeline = (props: TimelineProps) => {
96
96
  bindGlobalStyle(globalCssId, timelineCss);
97
97
 
98
98
  const ref: RefProps = {
99
- globalCssId,
99
+ referToCssId: globalCssId,
100
100
  };
101
101
 
102
102
  const lineColor = props.lineColor || 'var(--secondary-border-color, #ccc)';
@@ -108,7 +108,7 @@ export const Timeline = (props: TimelineProps) => {
108
108
  };
109
109
 
110
110
  return (
111
- <div class={['&-container', props.class].join(' ').trim()} ref={ref} css={containerStyle}>
111
+ <div class={[globalCssId, '&-container', props.class].join(' ').trim()} ref={ref} css={containerStyle}>
112
112
  <div class='&-line' style={{ backgroundColor: lineColor }}></div>
113
113
 
114
114
  {(props.items || []).map((item, index) => {
@@ -222,14 +222,14 @@ const TooltipContent = (props: {
222
222
  bindGlobalStyle(globalCssId, tooltipCss);
223
223
 
224
224
  const ref: RefProps = {
225
- globalCssId,
225
+ referToCssId: globalCssId,
226
226
  onLoad: async () => {
227
227
  props.onRef(ref);
228
228
  },
229
229
  };
230
230
 
231
231
  return (
232
- <div class={['&-container', props.position].join(' ')} ref={ref}>
232
+ <div class={[globalCssId, '&-container', props.position].join(' ')} ref={ref}>
233
233
  <div class='&-box'>
234
234
  {props.content}
235
235
  {props.showArrow && <div class='&-arrow' />}
@@ -1,6 +1,5 @@
1
1
  // import { bindPageResetEvent } from '../core/page-reset-events';
2
- import { addMetaDataTags } from 'lupine.web';
3
- import { encodeHtml } from '../lib';
2
+ import { addMetaDataTags, encodeHtml } from 'lupine.web';
4
3
  type NameMeta = { name: string; content: string };
5
4
  type PropertyMeta = { property: string; content: string };
6
5
  type HttpEquivMeta = { httpEquiv: string; content: string };
@@ -1,7 +1,6 @@
1
1
  // import { bindPageResetEvent } from '../core/page-reset-events';
2
2
 
3
- import { addMetaDataTags } from 'lupine.web';
4
- import { encodeHtml } from '../lib';
3
+ import { addMetaDataTags, encodeHtml } from 'lupine.web';
5
4
 
6
5
  export const MetaDescription = ({ children }: { children: string }) => {
7
6
  addMetaDataTags('name:description', `<meta name="description" content="${encodeHtml(children)}">`);
@@ -258,7 +258,7 @@ const ContentMenuContainer = (props: {
258
258
  bindGlobalStyle(globalCssId, contentMenuCss);
259
259
 
260
260
  const ref: RefProps = {
261
- globalCssId,
261
+ referToCssId: globalCssId,
262
262
  onLoad: async () => {
263
263
  props.onRef(ref);
264
264
  },
@@ -307,7 +307,7 @@ const ContentMenuContainer = (props: {
307
307
  };
308
308
 
309
309
  return (
310
- <div class='&-container' ref={ref}>
310
+ <div class={[globalCssId, '&-container'].join(' ')} ref={ref}>
311
311
  {props.list.map((item) => {
312
312
  if (item === '-' || item === '') return <div class='&-divider'></div>;
313
313
 
@@ -403,7 +403,7 @@ export const PopupMenu = ({
403
403
  },
404
404
  };
405
405
 
406
- let ref: RefProps = { id: '' };
406
+ let ref: RefProps = {};
407
407
  let selectedValue = defaultValue;
408
408
 
409
409
  const openMenu = (event?: MouseEvent) => {
@@ -251,7 +251,7 @@ export const Tabs = ({ pages, defaultIndex, topClassName, pagePadding, hook: ref
251
251
  bindGlobalStyle(tabGlobalCssId, css);
252
252
 
253
253
  const ref: RefProps = {
254
- globalCssId: tabGlobalCssId,
254
+ referToCssId: tabGlobalCssId,
255
255
  };
256
256
 
257
257
  // but we also want to create unique id for the current tab
@@ -264,7 +264,7 @@ export const Tabs = ({ pages, defaultIndex, topClassName, pagePadding, hook: ref
264
264
  },
265
265
  };
266
266
  return (
267
- <div ref={ref} css={cssTab} class={topClassName ? ' ' + topClassName : ''}>
267
+ <div ref={ref} css={cssTab} class={[tabGlobalCssId, topClassName].filter(Boolean).join(' ')}>
268
268
  <div class='&tabs tabs'>
269
269
  {pages.map((i, index) => {
270
270
  const className = index === newIndex ? ' active' : '';
@@ -76,6 +76,8 @@ export const DemoRenderPage = async (props: PageProps) => {
76
76
  borderRight: '1px solid var(--primary-border-color)',
77
77
  borderLeft: '1px solid var(--primary-border-color)',
78
78
  '>fragment>div': {
79
+ flex: 1,
80
+ alignSelf: 'stretch', // overwrite parent's align-items: center
79
81
  width: '100%',
80
82
  height: '100%',
81
83
  },
@@ -9,69 +9,66 @@ export type SideMenuMockProps = {
9
9
  onAction?: (action: string) => void;
10
10
  };
11
11
 
12
- const sideMenuMockCss: CssProps = {
13
- '.msm-header': {
14
- display: 'flex',
15
- alignItems: 'center',
16
- padding: '16px',
17
- borderBottom: '1px solid var(--primary-border-color)',
18
- },
19
- '.msm-header-icon': {
20
- marginRight: '12px',
21
- },
22
- '.msm-header-title': {
23
- fontSize: '18px',
24
- fontWeight: 'bold',
25
- color: 'var(--primary-color)',
26
- },
27
- '.msm-content': {
28
- flex: '1',
29
- overflowY: 'auto',
30
- padding: '12px 0',
31
- },
32
- '.msm-item': {
33
- padding: '12px 0px',
34
- fontSize: '16px',
35
- cursor: 'pointer',
36
- transition: 'background-color 0.2s',
37
- display: 'flex',
38
- alignItems: 'center',
39
- gap: '12px',
40
- '&:hover': {
41
- backgroundColor: 'var(--activatable-bg-color-hover, rgba(0,0,0,0.04))',
42
- },
43
- },
44
- '.msm-footer': {
45
- borderTop: '1px solid var(--primary-border-color)',
46
- padding: '16px 0',
47
- },
48
- '.msm-footer-cfg': {
49
- display: 'flex',
50
- flexDirection: 'row',
51
- justifyContent: 'space-between',
52
- },
53
- '.msm-footer-cfg .msm-item': {
54
- padding: '12px',
55
- },
56
- '.msm-footer-version': {
57
- textAlign: 'center',
58
- fontSize: '12px',
59
- color: 'var(--secondary-color, #999)',
60
- marginTop: '16px',
61
- },
62
- };
63
-
64
12
  export const SideMenuMock = ({
65
13
  menuItems = ['Home', 'Profile', 'Messages', 'Settings'],
66
14
  title = 'My App Menu',
67
15
  version = '1.0.0',
68
16
  onAction,
69
17
  }: SideMenuMockProps): VNode<any> => {
70
- const globalCssId = getGlobalStylesId(sideMenuMockCss);
71
- bindGlobalStyle(globalCssId, sideMenuMockCss);
72
-
73
- const ref: RefProps = {
74
- globalCssId,
18
+ const css: CssProps = {
19
+ display: 'flex',
20
+ flexDirection: 'column',
21
+ flex: 1,
22
+ height: '100%',
23
+ '.msm-header': {
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ padding: '16px',
27
+ borderBottom: '1px solid var(--primary-border-color)',
28
+ },
29
+ '.msm-header-icon': {
30
+ marginRight: '12px',
31
+ },
32
+ '.msm-header-title': {
33
+ fontSize: '18px',
34
+ fontWeight: 'bold',
35
+ color: 'var(--primary-color)',
36
+ },
37
+ '.msm-content': {
38
+ flex: '1',
39
+ overflowY: 'auto',
40
+ padding: '12px 0',
41
+ },
42
+ '.msm-item': {
43
+ padding: '12px 0px',
44
+ fontSize: '16px',
45
+ cursor: 'pointer',
46
+ transition: 'background-color 0.2s',
47
+ display: 'flex',
48
+ alignItems: 'center',
49
+ gap: '12px',
50
+ '&:hover': {
51
+ backgroundColor: 'var(--activatable-bg-color-hover, rgba(0,0,0,0.04))',
52
+ },
53
+ },
54
+ '.msm-footer': {
55
+ borderTop: '1px solid var(--primary-border-color)',
56
+ padding: '16px 0',
57
+ },
58
+ '.msm-footer-cfg': {
59
+ display: 'flex',
60
+ flexDirection: 'row',
61
+ justifyContent: 'space-between',
62
+ },
63
+ '.msm-footer-cfg .msm-item': {
64
+ padding: '12px',
65
+ },
66
+ '.msm-footer-version': {
67
+ textAlign: 'center',
68
+ fontSize: '12px',
69
+ color: 'var(--secondary-color, #999)',
70
+ marginTop: '16px',
71
+ },
75
72
  };
76
73
 
77
74
  const handleAction = (item: string) => {
@@ -84,7 +81,7 @@ export const SideMenuMock = ({
84
81
  };
85
82
 
86
83
  return (
87
- <div ref={ref} style={{ display: 'flex', flexDirection: 'column', flex: 1, height: '100%' }}>
84
+ <div css={css}>
88
85
  <div class='msm-header'>
89
86
  <div class='msm-header-icon'><i class='ifc-icon ma-home-outline'></i></div>
90
87
  <div class='msm-header-title'>{title}</div>
package/src/lib/index.ts CHANGED
@@ -14,7 +14,6 @@ export * from './download-link';
14
14
  export * from './download-stream';
15
15
  export * from './drag-util';
16
16
  export * from './dynamical-load';
17
- export * from './encode-html';
18
17
  export * from './find-parent-tag';
19
18
  export * from './format-bytes';
20
19
  export * from './lite-dom';
@@ -1,25 +0,0 @@
1
- const htmlEscapes: Record<string, string> = {
2
- '&': '&amp;',
3
- '<': '&lt;',
4
- '>': '&gt;',
5
- "'": '&#39;',
6
- '"': '&quot;',
7
- };
8
-
9
- export const encodeHtml = (str: any): string => {
10
- if (str === null || str === undefined) return '';
11
- return String(str).replace(/[&<>'"]/g, (tag) => htmlEscapes[tag]);
12
- };
13
-
14
- const htmlUnescapes: Record<string, string> = {
15
- '&amp;': '&',
16
- '&lt;': '<',
17
- '&gt;': '>',
18
- '&#39;': "'",
19
- '&quot;': '"',
20
- };
21
-
22
- export const decodeHtml = (str: string): string => {
23
- if (str === null || str === undefined) return '';
24
- return String(str).replace(/&(?:amp|lt|gt|quot|#39);/g, (tag) => htmlUnescapes[tag]);
25
- };