@jsenv/navi 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18611,7 +18611,8 @@ const FlexDirectionContext = createContext();
18611
18611
  * @param {string|number} [props.paddingBottom] - Bottom padding
18612
18612
  * @param {"start"|"center"|"end"|"stretch"} [props.alignX] - Horizontal alignment
18613
18613
  * @param {"start"|"center"|"end"|"stretch"} [props.alignY] - Vertical alignment
18614
- * @param {boolean} [props.expand] - Whether element should expand to fill available space
18614
+ * @param {boolean} [props.expandX] - Whether element should expand horizontally to fill available space
18615
+ * @param {boolean} [props.expandY] - Whether element should expand vertically to fill available space
18615
18616
  * @returns {Object} Object with categorized styles: { margin, padding, alignment, expansion, all }
18616
18617
  */
18617
18618
  const useLayoutStyle = (props) => {
@@ -18776,13 +18777,32 @@ const useLayoutStyle = (props) => {
18776
18777
  {
18777
18778
  const expand = props.expand;
18778
18779
  delete props.expand;
18779
- if (expand) {
18780
- if (flexDirection === "row") {
18781
- expansionStyle.flexGrow = 1;
18782
- } else if (flexDirection === "column") {
18783
- expansionStyle.flexGrow = 1;
18784
- } else {
18785
- expansionStyle.width = "100%";
18780
+
18781
+ {
18782
+ const expandX = props.expandX || expand;
18783
+ delete props.expandX;
18784
+ if (expandX) {
18785
+ if (flexDirection === "row") {
18786
+ expansionStyle.flexGrow = 1; // Grow horizontally in row
18787
+ } else if (flexDirection === "column") {
18788
+ expansionStyle.width = "100%"; // Take full width in column
18789
+ } else {
18790
+ expansionStyle.width = "100%"; // Take full width outside flex
18791
+ }
18792
+ }
18793
+ }
18794
+
18795
+ {
18796
+ const expandY = props.expandY || expand;
18797
+ delete props.expandY;
18798
+ if (expandY) {
18799
+ if (flexDirection === "row") {
18800
+ expansionStyle.height = "100%"; // Take full height in row
18801
+ } else if (flexDirection === "column") {
18802
+ expansionStyle.flexGrow = 1; // Grow vertically in column
18803
+ } else {
18804
+ expansionStyle.height = "100%"; // Take full height outside flex
18805
+ }
18786
18806
  }
18787
18807
  }
18788
18808
  }
@@ -22276,6 +22296,7 @@ const FormBasic = forwardRef((props, ref) => {
22276
22296
  const {
22277
22297
  readOnly,
22278
22298
  loading,
22299
+ style,
22279
22300
  children,
22280
22301
  ...rest
22281
22302
  } = props;
@@ -22292,9 +22313,14 @@ const FormBasic = forwardRef((props, ref) => {
22292
22313
  loading
22293
22314
  };
22294
22315
  }, [loading]);
22316
+ const {
22317
+ all
22318
+ } = useLayoutStyle(rest);
22319
+ const innerStyle = withPropsStyle(all, style);
22295
22320
  return jsx("form", {
22296
22321
  ...rest,
22297
22322
  ref: innerRef,
22323
+ style: innerStyle,
22298
22324
  onReset: e => {
22299
22325
  // browser would empty all fields to their default values (likely empty/unchecked)
22300
22326
  // we want to reset to the last known external state instead
@@ -28210,12 +28236,13 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
28210
28236
  }
28211
28237
  `;
28212
28238
  const Text = ({
28213
- children,
28214
28239
  color,
28215
28240
  bold,
28216
28241
  italic,
28217
28242
  underline,
28243
+ size,
28218
28244
  style,
28245
+ children,
28219
28246
  ...rest
28220
28247
  }) => {
28221
28248
  const {
@@ -28226,6 +28253,7 @@ const Text = ({
28226
28253
  color,
28227
28254
  fontWeight: bold ? "bold" : undefined,
28228
28255
  fontStyle: italic ? "italic" : undefined,
28256
+ fontSize: size,
28229
28257
  textDecoration: underline ? "underline" : undefined
28230
28258
  }, style);
28231
28259
  return jsx("span", {
@@ -28235,23 +28263,21 @@ const Text = ({
28235
28263
  children: children
28236
28264
  });
28237
28265
  };
28238
- const alignYMapping = {
28239
- start: "flex-start",
28240
- center: "center",
28241
- end: "flex-end"
28242
- };
28243
28266
  const Icon = ({
28244
- alignY,
28267
+ color,
28268
+ size,
28245
28269
  style,
28246
28270
  children,
28247
28271
  ...rest
28248
28272
  }) => {
28249
- const innerStyle = {
28250
- ...style
28251
- };
28252
- if (alignY !== "center") {
28253
- innerStyle["--align-y"] = alignYMapping[alignY];
28254
- }
28273
+ const {
28274
+ all
28275
+ } = useLayoutStyle(rest);
28276
+ const innerStyle = withPropsStyle({
28277
+ ...all,
28278
+ color,
28279
+ fontSize: size
28280
+ }, style);
28255
28281
  return jsx("span", {
28256
28282
  ...rest,
28257
28283
  className: "navi_icon",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/navi",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Library of components including navigation to create frontend applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,6 +25,8 @@ import {
25
25
  import { renderActionableComponent } from "../action_execution/render_actionable_component.jsx";
26
26
  import { useActionBoundToOneParam } from "../action_execution/use_action.js";
27
27
  import { useExecuteAction } from "../action_execution/use_execute_action.js";
28
+ import { useLayoutStyle } from "../layout/use_layout_style.js";
29
+ import { withPropsStyle } from "../props_composition/with_props_style.js";
28
30
  import { collectFormElementValues } from "./collect_form_element_values.js";
29
31
  import {
30
32
  useActionEvents,
@@ -75,7 +77,7 @@ export const Form = forwardRef((props, ref) => {
75
77
 
76
78
  const FormBasic = forwardRef((props, ref) => {
77
79
  const uiStateController = useContext(UIStateControllerContext);
78
- const { readOnly, loading, children, ...rest } = props;
80
+ const { readOnly, loading, style, children, ...rest } = props;
79
81
  const innerRef = useRef();
80
82
  useImperativeHandle(ref, () => innerRef.current);
81
83
 
@@ -90,10 +92,14 @@ const FormBasic = forwardRef((props, ref) => {
90
92
  return { loading };
91
93
  }, [loading]);
92
94
 
95
+ const { all } = useLayoutStyle(rest);
96
+ const innerStyle = withPropsStyle(all, style);
97
+
93
98
  return (
94
99
  <form
95
100
  {...rest}
96
101
  ref={innerRef}
102
+ style={innerStyle}
97
103
  onReset={(e) => {
98
104
  // browser would empty all fields to their default values (likely empty/unchecked)
99
105
  // we want to reset to the last known external state instead
@@ -64,33 +64,118 @@
64
64
  </p>
65
65
 
66
66
  <div className="demo-container">
67
- <h3>1. Button with Expand in FlexRow</h3>
67
+ <h3>1. Button ExpandX - Horizontal Expansion Only</h3>
68
68
  <div className="visual-container">
69
+ <h4>In FlexRow (grows horizontally)</h4>
69
70
  <FlexRow gap="10px">
70
71
  <Button>Fixed</Button>
71
- <Button expand>Expanding Button</Button>
72
+ <Button expandX>ExpandX Button</Button>
72
73
  <Button>Fixed</Button>
73
74
  </FlexRow>
75
+
76
+ <h4>In FlexColumn (takes full width)</h4>
77
+ <FlexColumn gap="10px" style={{ height: "150px" }}>
78
+ <Button>Normal Width</Button>
79
+ <Button expandX>Full Width Button</Button>
80
+ <Button>Normal Width</Button>
81
+ </FlexColumn>
74
82
  </div>
75
83
  </div>
76
84
 
77
85
  <div className="demo-container">
78
- <h3>2. Button with Expand in FlexColumn</h3>
86
+ <h3>2. Button ExpandY - Vertical Expansion Only</h3>
79
87
  <div className="visual-container">
88
+ <h4>In FlexRow (takes full height)</h4>
89
+ <FlexRow gap="10px" style={{ height: "100px" }}>
90
+ <Button>Normal Height</Button>
91
+ <Button expandY>Full Height Button</Button>
92
+ <Button>Normal Height</Button>
93
+ </FlexRow>
94
+
95
+ <h4>In FlexColumn (grows vertically)</h4>
80
96
  <FlexColumn gap="10px" style={{ height: "200px" }}>
81
- <Button>Fixed Button</Button>
82
- <Button expand>Expanding Button (height)</Button>
83
- <Button>Fixed Button</Button>
97
+ <Button>Fixed</Button>
98
+ <Button expandY>ExpandY Button</Button>
99
+ <Button>Fixed</Button>
100
+ </FlexColumn>
101
+ </div>
102
+ </div>
103
+
104
+ <div className="demo-container">
105
+ <h3>3. Button ExpandX + ExpandY - Both Axes</h3>
106
+ <div className="visual-container">
107
+ <h4>In FlexRow (grows horizontally, full height)</h4>
108
+ <FlexRow gap="10px" style={{ height: "80px" }}>
109
+ <Button>Fixed</Button>
110
+ <Button expandX expandY>
111
+ Both Axes
112
+ </Button>
113
+ <Button>Fixed</Button>
114
+ </FlexRow>
115
+
116
+ <h4>In FlexColumn (full width, grows vertically)</h4>
117
+ <FlexColumn gap="10px" style={{ height: "150px" }}>
118
+ <Button>Fixed</Button>
119
+ <Button expandX expandY>
120
+ Both Axes
121
+ </Button>
122
+ <Button>Fixed</Button>
123
+ </FlexColumn>
124
+ </div>
125
+ </div>
126
+
127
+ <div className="demo-container">
128
+ <h3>4. Precise Control Comparison</h3>
129
+ <div className="visual-container">
130
+ <FlexColumn gap="15px">
131
+ <div>
132
+ <h4>FlexRow with different expansions</h4>
133
+ <FlexRow
134
+ gap="10px"
135
+ style={{
136
+ height: "60px",
137
+ background: "#f8f9fa",
138
+ padding: "10px",
139
+ }}
140
+ >
141
+ <Button>No Expand</Button>
142
+ <Button expandX>ExpandX Only</Button>
143
+ <Button expandY>ExpandY Only</Button>
144
+ <Button expandX expandY>
145
+ Both
146
+ </Button>
147
+ </FlexRow>
148
+ </div>
149
+
150
+ <div>
151
+ <h4>FlexColumn with different expansions</h4>
152
+ <FlexColumn
153
+ gap="10px"
154
+ style={{
155
+ height: "200px",
156
+ background: "#f8f9fa",
157
+ padding: "10px",
158
+ }}
159
+ >
160
+ <Button>No Expand</Button>
161
+ <Button expandX>ExpandX Only</Button>
162
+ <Button expandY>ExpandY Only</Button>
163
+ <Button expandX expandY>
164
+ Both
165
+ </Button>
166
+ </FlexColumn>
167
+ </div>
84
168
  </FlexColumn>
85
169
  </div>
86
170
  </div>
87
171
 
88
172
  <div className="demo-container">
89
- <h3>3. Button with Expand outside Flex context</h3>
173
+ <h3>5. Outside Flex Context</h3>
90
174
  <div className="visual-container">
91
175
  <div
92
176
  style={{
93
177
  width: "300px",
178
+ height: "150px",
94
179
  border: "1px solid #ccc",
95
180
  padding: "10px",
96
181
  }}
@@ -98,26 +183,32 @@
98
183
  <Button>Normal Button</Button>
99
184
  <br />
100
185
  <br />
101
- <Button expand>
102
- Expanding Button (should take full width)
186
+ <Button expandX>ExpandX (full width)</Button>
187
+ <br />
188
+ <br />
189
+ <Button expandY>ExpandY (full height)</Button>
190
+ <br />
191
+ <br />
192
+ <Button expandX expandY>
193
+ Both (full width & height)
103
194
  </Button>
104
195
  </div>
105
196
  </div>
106
197
  </div>
107
198
 
108
199
  <div className="demo-container">
109
- <h3>4. Multiple Expand Buttons</h3>
200
+ <h3>6. Multiple Expand Buttons</h3>
110
201
  <div className="visual-container">
111
202
  <FlexRow gap="10px">
112
- <Button expand>Expand 1</Button>
113
- <Button expand>Expand 2</Button>
114
- <Button expand>Expand 3</Button>
203
+ <Button expandX>ExpandX 1</Button>
204
+ <Button expandX>ExpandX 2</Button>
205
+ <Button expandX>ExpandX 3</Button>
115
206
  </FlexRow>
116
207
  </div>
117
208
  </div>
118
209
 
119
210
  <div className="demo-container">
120
- <h3>5. Button Spacing - Margins</h3>
211
+ <h3>7. Button Spacing - Margins</h3>
121
212
  <div className="visual-container">
122
213
  <FlexColumn gap="5px">
123
214
  <Button margin="10px">Margin All Sides</Button>
@@ -143,7 +234,7 @@
143
234
  </div>
144
235
 
145
236
  <div className="demo-container">
146
- <h3>7. Button AlignX Test: FlexRow + alignX="end"</h3>
237
+ <h3>8. Button AlignX Test: FlexRow + alignX="end"</h3>
147
238
  <div className="visual-container">
148
239
  <div className="bounded">
149
240
  <FlexRow gap="10px" style={{ height: "100%" }}>
@@ -155,12 +246,12 @@
155
246
  </div>
156
247
 
157
248
  <div className="demo-container">
158
- <h3>8. Combined Spacing and Expand</h3>
249
+ <h3>9. Combined Spacing and ExpandX</h3>
159
250
  <div className="visual-container">
160
251
  <FlexRow gap="10px">
161
252
  <Button>Label</Button>
162
- <Button expand marginY="5px" paddingX="20px">
163
- Margin + Padding + Expand
253
+ <Button expandX marginY="5px" paddingX="20px">
254
+ Margin + Padding + ExpandX
164
255
  </Button>
165
256
  <Button>End</Button>
166
257
  </FlexRow>
@@ -168,20 +259,20 @@
168
259
  </div>
169
260
 
170
261
  <div className="demo-container">
171
- <h3>9. Button Toolbar Layout</h3>
262
+ <h3>10. Button Toolbar Layout</h3>
172
263
  <div className="visual-container">
173
264
  <FlexRow gap="10px">
174
265
  <Button>New</Button>
175
266
  <Button>Open</Button>
176
267
  <Button>Save</Button>
177
- <Button expand>Status Message Area</Button>
268
+ <Button expandX>Status Message Area</Button>
178
269
  <Button alignX="end">Settings</Button>
179
270
  </FlexRow>
180
271
  </div>
181
272
  </div>
182
273
 
183
274
  <div className="demo-container">
184
- <h3>10. Button Group with Various Alignments</h3>
275
+ <h3>11. Button Group with Various Alignments</h3>
185
276
  <div className="visual-container">
186
277
  <FlexColumn gap="10px">
187
278
  <FlexRow gap="10px">
@@ -191,7 +282,7 @@
191
282
  </FlexRow>
192
283
 
193
284
  <FlexRow gap="10px">
194
- <Button expand>Primary Action</Button>
285
+ <Button expandX>Primary Action</Button>
195
286
  <Button>Cancel</Button>
196
287
  </FlexRow>
197
288
 
@@ -204,7 +295,7 @@
204
295
  </div>
205
296
 
206
297
  <div className="demo-container">
207
- <h3>11. Card Layout with Button Actions</h3>
298
+ <h3>12. Card Layout with Button Actions</h3>
208
299
  <div className="visual-container">
209
300
  <div
210
301
  style={{
@@ -220,7 +311,7 @@
220
311
  </p>
221
312
 
222
313
  <FlexRow gap="10px">
223
- <Button expand>Primary Action</Button>
314
+ <Button expandX>Primary Action</Button>
224
315
  <Button alignX="end">More</Button>
225
316
  </FlexRow>
226
317
  </div>
@@ -228,12 +319,12 @@
228
319
  </div>
229
320
 
230
321
  <div className="demo-container">
231
- <h3>12. Navigation Button Layout</h3>
322
+ <h3>13. Navigation Button Layout</h3>
232
323
  <div className="visual-container">
233
324
  <FlexColumn gap="15px">
234
325
  <FlexRow gap="10px">
235
326
  <Button>Home</Button>
236
- <Button expand>Current Page Title</Button>
327
+ <Button expandX>Current Page Title</Button>
237
328
  <Button alignX="end">Profile</Button>
238
329
  </FlexRow>
239
330
 
@@ -68,7 +68,7 @@
68
68
  <div className="visual-container">
69
69
  <FlexRow gap="10px">
70
70
  <Button>Start</Button>
71
- <Input placeholder="Expanding input" expand />
71
+ <Input placeholder="Expanding input" expandX />
72
72
  <Button>End</Button>
73
73
  </FlexRow>
74
74
  </div>
@@ -79,7 +79,7 @@
79
79
  <div className="visual-container">
80
80
  <FlexColumn gap="10px" style={{ height: "200px" }}>
81
81
  <Input placeholder="Fixed input" />
82
- <Input placeholder="Expanding input (height)" expand />
82
+ <Input placeholder="Expanding input (height)" expandY />
83
83
  <Input placeholder="Fixed input" />
84
84
  </FlexColumn>
85
85
  </div>
@@ -35,7 +35,8 @@ import { FlexDirectionContext } from "./layout_context.jsx";
35
35
  * @param {string|number} [props.paddingBottom] - Bottom padding
36
36
  * @param {"start"|"center"|"end"|"stretch"} [props.alignX] - Horizontal alignment
37
37
  * @param {"start"|"center"|"end"|"stretch"} [props.alignY] - Vertical alignment
38
- * @param {boolean} [props.expand] - Whether element should expand to fill available space
38
+ * @param {boolean} [props.expandX] - Whether element should expand horizontally to fill available space
39
+ * @param {boolean} [props.expandY] - Whether element should expand vertically to fill available space
39
40
  * @returns {Object} Object with categorized styles: { margin, padding, alignment, expansion, all }
40
41
  */
41
42
  export const useLayoutStyle = (props) => {
@@ -200,13 +201,32 @@ export const useLayoutStyle = (props) => {
200
201
  expand: {
201
202
  const expand = props.expand;
202
203
  delete props.expand;
203
- if (expand) {
204
- if (flexDirection === "row") {
205
- expansionStyle.flexGrow = 1;
206
- } else if (flexDirection === "column") {
207
- expansionStyle.flexGrow = 1;
208
- } else {
209
- expansionStyle.width = "100%";
204
+
205
+ expandX: {
206
+ const expandX = props.expandX || expand;
207
+ delete props.expandX;
208
+ if (expandX) {
209
+ if (flexDirection === "row") {
210
+ expansionStyle.flexGrow = 1; // Grow horizontally in row
211
+ } else if (flexDirection === "column") {
212
+ expansionStyle.width = "100%"; // Take full width in column
213
+ } else {
214
+ expansionStyle.width = "100%"; // Take full width outside flex
215
+ }
216
+ }
217
+ }
218
+
219
+ expandY: {
220
+ const expandY = props.expandY || expand;
221
+ delete props.expandY;
222
+ if (expandY) {
223
+ if (flexDirection === "row") {
224
+ expansionStyle.height = "100%"; // Take full height in row
225
+ } else if (flexDirection === "column") {
226
+ expansionStyle.flexGrow = 1; // Grow vertically in column
227
+ } else {
228
+ expansionStyle.height = "100%"; // Take full height outside flex
229
+ }
210
230
  }
211
231
  }
212
232
  }
@@ -25,12 +25,13 @@ import.meta.css = /* css */ `
25
25
  `;
26
26
 
27
27
  export const Text = ({
28
- children,
29
28
  color,
30
29
  bold,
31
30
  italic,
32
31
  underline,
32
+ size,
33
33
  style,
34
+ children,
34
35
  ...rest
35
36
  }) => {
36
37
  const { all } = useLayoutStyle(rest);
@@ -40,6 +41,7 @@ export const Text = ({
40
41
  color,
41
42
  fontWeight: bold ? "bold" : undefined,
42
43
  fontStyle: italic ? "italic" : undefined,
44
+ fontSize: size,
43
45
  textDecoration: underline ? "underline" : undefined,
44
46
  },
45
47
  style,
@@ -52,16 +54,16 @@ export const Text = ({
52
54
  );
53
55
  };
54
56
 
55
- const alignYMapping = {
56
- start: "flex-start",
57
- center: "center",
58
- end: "flex-end",
59
- };
60
- export const Icon = ({ alignY, style, children, ...rest }) => {
61
- const innerStyle = { ...style };
62
- if (alignY !== "center") {
63
- innerStyle["--align-y"] = alignYMapping[alignY];
64
- }
57
+ export const Icon = ({ color, size, style, children, ...rest }) => {
58
+ const { all } = useLayoutStyle(rest);
59
+ const innerStyle = withPropsStyle(
60
+ {
61
+ ...all,
62
+ color,
63
+ fontSize: size,
64
+ },
65
+ style,
66
+ );
65
67
 
66
68
  return (
67
69
  <span {...rest} className="navi_icon" style={innerStyle}>