@granularjs/ui 0.3.1 → 0.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granularjs/ui",
3
- "version": "0.3.1",
3
+ "version": "0.3.4",
4
4
  "description": "90+ production-ready UI components for Granular. Dark/light themes, CSS variables, accessible, zero dependencies beyond @granularjs/core.",
5
5
  "type": "module",
6
6
  "main": "./dist/granular-ui.min.js",
@@ -29,7 +29,7 @@
29
29
  "@granularjs/core": "^1.0.0"
30
30
  },
31
31
  "author": "Guilherme Ferreira",
32
- "license": "MIT",
32
+ "license": "Apache-2.0",
33
33
  "repository": {
34
34
  "type": "git",
35
35
  "url": "https://github.com/zerobytes/granular-ui.git"
@@ -1,17 +1,21 @@
1
1
  import { Div } from '@granularjs/core';
2
2
  import { state, when, after } from '@granularjs/core';
3
- import { cx, splitPropsChildren, resolveBool } from '../utils.js';
3
+ import { cx, splitPropsChildren, resolveBool, isReactive } from '../utils.js';
4
4
 
5
5
  export function Accordion(...args) {
6
- const { props, children } = splitPropsChildren(args, { opened: false });
6
+ const { props, rawProps, children } = splitPropsChildren(args, { opened: false });
7
7
  const { opened, className, ...rest } = props;
8
- const openedState = state(resolveBool(opened));
8
+ const { opened: rawOpened } = rawProps;
9
+ const isControlledOutside = isReactive(rawOpened)
10
+ const openedState = isControlledOutside ? rawOpened : state(resolveBool(opened));
9
11
 
10
12
  after(opened).change((next) => {
13
+ if(isControlledOutside) return;
11
14
  openedState.set(resolveBool(next));
12
15
  });
13
16
 
14
17
  const toggle = () => {
18
+ if(isControlledOutside) return;
15
19
  openedState.set(!openedState.get());
16
20
  };
17
21
 
@@ -7,8 +7,10 @@ export function Tabs(...args) {
7
7
  orientation: 'horizontal',
8
8
  variant: 'default',
9
9
  sticky: true,
10
+ align: 'left',
11
+ size: 'md'
10
12
  });
11
- const { value, tabs, orientation, variant, sticky, className, style } = props;
13
+ const { value, tabs, orientation, variant, sticky, className, style, align, size } = props;
12
14
  const { onChange } = rawProps;
13
15
 
14
16
  const currentState = state(resolveValue(value) ?? resolveValue(tabs)?.[0]?.value ?? '');
@@ -161,13 +163,15 @@ export function Tabs(...args) {
161
163
 
162
164
  return Div(
163
165
  Div({
164
- className: cx(
165
- 'g-ui-tabs',
166
- classMap(orientation, { vertical: 'g-ui-tabs-vertical' }),
167
- classVar('g-ui-tabs-variant-', variant, 'default'),
168
- props.className ?? className
169
- ),
170
- },
166
+ className: cx(
167
+ 'g-ui-tabs',
168
+ classMap(orientation, { vertical: 'g-ui-tabs-vertical' }),
169
+ classVar('g-ui-tabs-variant-', variant, 'default'),
170
+ classVar('g-ui-tabs-align-', align, 'left'),
171
+ classVar('g-ui-tabs-size-', size, 'md'),
172
+ props.className ?? className
173
+ ),
174
+ },
171
175
  Div({ node: sentinelNode }),
172
176
  Div({ style: spacerStyle }),
173
177
  Div({ node: listNode, className: 'g-ui-tabs-list', style: stickyStyle },
@@ -1323,6 +1323,45 @@ body .g-ui-card-shadow-lg { box-shadow: var(--g-ui-shadow-lg); }
1323
1323
  color: var(--g-ui-primary-fg);
1324
1324
  }
1325
1325
 
1326
+ .g-ui-tabs-vertical {
1327
+ display: grid;
1328
+ grid-template-columns: 200px 1fr;
1329
+ gap: var(--g-ui-space-16);
1330
+ }
1331
+ .g-ui-tabs-vertical .g-ui-tabs-list {
1332
+ flex-direction: column;
1333
+ }
1334
+ .g-ui-tabs-align-left .g-ui-tabs-list {
1335
+ justify-content: flex-start;
1336
+ }
1337
+ .g-ui-tabs-align-center .g-ui-tabs-list {
1338
+ justify-content: center;
1339
+ }
1340
+ .g-ui-tabs-align-right .g-ui-tabs-list {
1341
+ justify-content: flex-end;
1342
+ }
1343
+ .
1344
+ .g-ui-tabs-size-xs .g-ui-tabs-tab {
1345
+ padding: var(--g-ui-space-6) var(--g-ui-space-10);
1346
+ font-size: 12px;
1347
+ }
1348
+ .g-ui-tabs-size-sm .g-ui-tabs-tab {
1349
+ padding: var(--g-ui-space-8) var(--g-ui-space-12);
1350
+ font-size:
1351
+ }
1352
+ .g-ui-tabs-size-md .g-ui-tabs-tab {
1353
+ padding: var(--g-ui-space-10) var(--g-ui-space-14);
1354
+ font-size: 16px;
1355
+ }
1356
+ .g-ui-tabs-size-lg .g-ui-tabs-tab {
1357
+ padding: var(--g-ui-space-12) var(--g-ui-space-16);
1358
+ font-size: 18px;
1359
+ }
1360
+ .g-ui-tabs-size-xl .g-ui-tabs-tab {
1361
+ padding: var(--g-ui-space-14) var(--g-ui-space-20);
1362
+ font-size: 20px;
1363
+ }
1364
+
1326
1365
  .g-ui-table {
1327
1366
  width: 100%;
1328
1367
  border-collapse: collapse;
@@ -2246,6 +2285,11 @@ body .g-ui-card-shadow-lg { box-shadow: var(--g-ui-shadow-lg); }
2246
2285
  .g-ui-timeline-pin-size-md .g-ui-timeline-dot { width: 20px; height: 20px; border-width: 4px; }
2247
2286
  .g-ui-timeline-pin-size-lg .g-ui-timeline-dot { width: 24px; height: 24px; border-width: 4px; }
2248
2287
  .g-ui-timeline-pin-size-xl .g-ui-timeline-dot { width: 28px; height: 28px; border-width: 4px; }
2288
+ .g-ui-timeline-line-width-xs .g-ui-timeline-track-segment { width: 2px; left: 13px; }
2289
+ .g-ui-timeline-line-width-sm .g-ui-timeline-track-segment { width: 3px; }
2290
+ .g-ui-timeline-line-width-md .g-ui-timeline-track-segment { width: 4px; }
2291
+ .g-ui-timeline-line-width-lg .g-ui-timeline-track-segment { width: 6px; left: 11px; }
2292
+ .g-ui-timeline-line-width-xl .g-ui-timeline-track-segment { width: 10px; left: 9px; }
2249
2293
  .g-ui-timeline-pin-radius-xs .g-ui-timeline-dot { border-radius: 2px; }
2250
2294
  .g-ui-timeline-pin-radius-sm .g-ui-timeline-dot { border-radius: 4px; }
2251
2295
  .g-ui-timeline-pin-radius-md .g-ui-timeline-dot { border-radius: 50%; }
@@ -3015,14 +3059,6 @@ body .g-ui-card-shadow-lg { box-shadow: var(--g-ui-shadow-lg); }
3015
3059
  }
3016
3060
  .g-ui-toast-title { font-weight: 600; }
3017
3061
 
3018
- .g-ui-tabs-vertical {
3019
- display: grid;
3020
- grid-template-columns: 200px 1fr;
3021
- gap: var(--g-ui-space-16);
3022
- }
3023
- .g-ui-tabs-vertical .g-ui-tabs-list {
3024
- flex-direction: column;
3025
- }
3026
3062
 
3027
3063
  .g-ui-drawer-shadowed {
3028
3064
  box-shadow: var(--g-ui-shadow);
package/src/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Renderer, isSignal, isState, isStatePath, isComputed, resolve, computed, after, concat } from '@granularjs/core';
2
2
 
3
- function isReactive(value) {
3
+ export function isReactive(value) {
4
4
  return isSignal(value) || isState(value) || isStatePath(value) || isComputed(value);
5
5
  }
6
6
 
@@ -13,6 +13,7 @@ export function toPx(value) {
13
13
  return typeof value === 'number' ? `${value}px` : value;
14
14
  }
15
15
 
16
+
16
17
  export function splitPropsChildren(args, defaults) {
17
18
  const props = {};
18
19
  const children = [];
package/types/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export function isReactive(value: any): any;
1
2
  export function cx(...values: any[]): any;
2
3
  export function toPx(value: any): any;
3
4
  export function splitPropsChildren(args: any, defaults: any): {