foldkit 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/dist/command/index.d.ts +4 -0
- package/dist/command/index.d.ts.map +1 -0
- package/dist/command/index.js +1 -0
- package/dist/command/public.d.ts +2 -0
- package/dist/command/public.d.ts.map +1 -0
- package/dist/command/public.js +1 -0
- package/dist/effectExtensions/optionExtensions.d.ts +4 -0
- package/dist/effectExtensions/optionExtensions.d.ts.map +1 -1
- package/dist/effectExtensions/optionExtensions.js +2 -1
- package/dist/fieldValidation/index.d.ts.map +1 -1
- package/dist/fieldValidation/index.js +4 -4
- package/dist/html/index.d.ts +45 -3
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +53 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/message/index.d.ts +2 -0
- package/dist/message/index.d.ts.map +1 -0
- package/dist/message/index.js +1 -0
- package/dist/message/public.d.ts +2 -0
- package/dist/message/public.d.ts.map +1 -0
- package/dist/message/public.js +1 -0
- package/dist/route/index.d.ts +1 -0
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/index.js +1 -0
- package/dist/route/parser.js +17 -17
- package/dist/route/public.d.ts +1 -1
- package/dist/route/public.d.ts.map +1 -1
- package/dist/route/public.js +1 -1
- package/dist/runtime/public.d.ts +1 -1
- package/dist/runtime/public.d.ts.map +1 -1
- package/dist/runtime/runtime.d.ts +2 -3
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +9 -9
- package/dist/schema/index.d.ts +36 -8
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +6 -0
- package/dist/task/dom.d.ts +58 -0
- package/dist/task/dom.d.ts.map +1 -0
- package/dist/task/dom.js +112 -0
- package/dist/task/error.d.ts +18 -0
- package/dist/task/error.d.ts.map +1 -0
- package/dist/task/error.js +7 -0
- package/dist/task/index.d.ts +7 -108
- package/dist/task/index.d.ts.map +1 -1
- package/dist/task/index.js +7 -168
- package/dist/task/inert.d.ts +26 -0
- package/dist/task/inert.d.ts.map +1 -0
- package/dist/task/inert.js +87 -0
- package/dist/task/public.d.ts +1 -1
- package/dist/task/public.d.ts.map +1 -1
- package/dist/task/public.js +1 -1
- package/dist/task/random.d.ts +11 -0
- package/dist/task/random.d.ts.map +1 -0
- package/dist/task/random.js +10 -0
- package/dist/task/scrollLock.d.ts +24 -0
- package/dist/task/scrollLock.d.ts.map +1 -0
- package/dist/task/scrollLock.js +46 -0
- package/dist/task/time.d.ts +43 -0
- package/dist/task/time.d.ts.map +1 -0
- package/dist/task/time.js +53 -0
- package/dist/task/timing.d.ts +35 -0
- package/dist/task/timing.d.ts.map +1 -0
- package/dist/task/timing.js +51 -0
- package/dist/ui/dialog/index.d.ts +1 -1
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +7 -7
- package/dist/ui/disclosure/index.d.ts +1 -1
- package/dist/ui/disclosure/index.d.ts.map +1 -1
- package/dist/ui/disclosure/index.js +7 -7
- package/dist/ui/keyboard.d.ts.map +1 -1
- package/dist/ui/keyboard.js +1 -1
- package/dist/ui/menu/index.d.ts +71 -18
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +325 -113
- package/dist/ui/menu/public.d.ts +2 -2
- package/dist/ui/menu/public.d.ts.map +1 -1
- package/dist/ui/menu/public.js +1 -1
- package/dist/ui/tabs/index.d.ts +4 -5
- package/dist/ui/tabs/index.d.ts.map +1 -1
- package/dist/ui/tabs/index.js +12 -14
- package/dist/url/index.js +4 -4
- package/package.json +13 -1
package/dist/ui/tabs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
|
+
import type { Command } from '../../command';
|
|
2
3
|
import type { Html, TagName } from '../../html';
|
|
3
|
-
import type { Command } from '../../runtime/runtime';
|
|
4
4
|
export { wrapIndex, findFirstEnabledIndex, keyToIndex } from '../keyboard';
|
|
5
5
|
/** Controls the tab list layout direction and which arrow keys navigate between tabs. */
|
|
6
6
|
export declare const Orientation: S.Literal<["Horizontal", "Vertical"]>;
|
|
@@ -8,12 +8,11 @@ export type Orientation = typeof Orientation.Type;
|
|
|
8
8
|
/** Controls whether tabs activate on focus (`Automatic`) or require an explicit selection (`Manual`). */
|
|
9
9
|
export declare const ActivationMode: S.Literal<["Automatic", "Manual"]>;
|
|
10
10
|
export type ActivationMode = typeof ActivationMode.Type;
|
|
11
|
-
/** Schema for the tabs component's state, tracking active/focused indices
|
|
11
|
+
/** Schema for the tabs component's state, tracking active/focused indices and activation mode. */
|
|
12
12
|
export declare const Model: S.Struct<{
|
|
13
13
|
id: typeof S.String;
|
|
14
14
|
activeIndex: typeof S.Number;
|
|
15
15
|
focusedIndex: typeof S.Number;
|
|
16
|
-
orientation: S.Literal<["Horizontal", "Vertical"]>;
|
|
17
16
|
activationMode: S.Literal<["Automatic", "Manual"]>;
|
|
18
17
|
}>;
|
|
19
18
|
export type Model = typeof Model.Type;
|
|
@@ -41,10 +40,9 @@ export type Message = typeof Message.Type;
|
|
|
41
40
|
export type InitConfig = Readonly<{
|
|
42
41
|
id: string;
|
|
43
42
|
activeIndex?: number;
|
|
44
|
-
orientation?: Orientation;
|
|
45
43
|
activationMode?: ActivationMode;
|
|
46
44
|
}>;
|
|
47
|
-
/** Creates an initial tabs model from a config. Defaults to first tab
|
|
45
|
+
/** Creates an initial tabs model from a config. Defaults to first tab and automatic activation. */
|
|
48
46
|
export declare const init: (config: InitConfig) => Model;
|
|
49
47
|
/** Processes a tabs message and returns the next model and commands. */
|
|
50
48
|
export declare const update: (model: Model, message: Message) => [Model, ReadonlyArray<Command<Message>>];
|
|
@@ -65,6 +63,7 @@ export type ViewConfig<Message, Tab extends string> = Readonly<{
|
|
|
65
63
|
}) => TabConfig;
|
|
66
64
|
isTabDisabled?: (tab: Tab, index: number) => boolean;
|
|
67
65
|
persistPanels?: boolean;
|
|
66
|
+
orientation?: Orientation;
|
|
68
67
|
tabListElement?: TagName;
|
|
69
68
|
tabElement?: TagName;
|
|
70
69
|
panelElement?: TagName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,MAAM,IAAI,CAAC,EAGZ,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAM/C,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI1E,yFAAyF;AACzF,eAAO,MAAM,WAAW,uCAAsC,CAAA;AAC9D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD,yGAAyG;AACzG,eAAO,MAAM,cAAc,oCAAmC,CAAA;AAC9D,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD,kGAAkG;AAClG,eAAO,MAAM,KAAK;;;;;EAKhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,sGAAsG;AACtG,eAAO,MAAM,WAAW;;EAAwC,CAAA;AAChE,wFAAwF;AACxF,eAAO,MAAM,UAAU;;EAAuC,CAAA;AAC9D,kGAAkG;AAClG,eAAO,MAAM,IAAI,yDAAY,CAAA;AAE7B,4DAA4D;AAC5D,eAAO,MAAM,OAAO;;;;6DAAyC,CAAA;AAE7D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AACjD,MAA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ACpD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAC,CAAA;AAMF,yGAAyG;AACzG,eAAO,MAAM,IAAI,GAAI,OAAO,EAAE,GAAG,SAAS,MAAM,EAC9C,QAAQ,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,KAC/B,IAkLF,CAAA"}
|
package/dist/ui/tabs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Array, Match as M, Option, Schema as S, String, pipe } from 'effect';
|
|
1
|
+
import { Array, Effect, Match as M, Option, Schema as S, String, pipe, } from 'effect';
|
|
2
2
|
import { html } from '../../html';
|
|
3
|
-
import {
|
|
3
|
+
import { m } from '../../message';
|
|
4
4
|
import { evo } from '../../struct';
|
|
5
5
|
import * as Task from '../../task';
|
|
6
6
|
import { keyToIndex } from '../keyboard';
|
|
@@ -10,31 +10,29 @@ export { wrapIndex, findFirstEnabledIndex, keyToIndex } from '../keyboard';
|
|
|
10
10
|
export const Orientation = S.Literal('Horizontal', 'Vertical');
|
|
11
11
|
/** Controls whether tabs activate on focus (`Automatic`) or require an explicit selection (`Manual`). */
|
|
12
12
|
export const ActivationMode = S.Literal('Automatic', 'Manual');
|
|
13
|
-
/** Schema for the tabs component's state, tracking active/focused indices
|
|
13
|
+
/** Schema for the tabs component's state, tracking active/focused indices and activation mode. */
|
|
14
14
|
export const Model = S.Struct({
|
|
15
15
|
id: S.String,
|
|
16
16
|
activeIndex: S.Number,
|
|
17
17
|
focusedIndex: S.Number,
|
|
18
|
-
orientation: Orientation,
|
|
19
18
|
activationMode: ActivationMode,
|
|
20
19
|
});
|
|
21
20
|
// MESSAGE
|
|
22
21
|
/** Sent when a tab is selected via click or keyboard. Updates both the active and focused indices. */
|
|
23
|
-
export const TabSelected =
|
|
22
|
+
export const TabSelected = m('TabSelected', { index: S.Number });
|
|
24
23
|
/** Sent when a tab receives keyboard focus in `Manual` mode without being activated. */
|
|
25
|
-
export const TabFocused =
|
|
24
|
+
export const TabFocused = m('TabFocused', { index: S.Number });
|
|
26
25
|
/** Placeholder message used when no action is needed, such as after a focus command completes. */
|
|
27
|
-
export const NoOp =
|
|
26
|
+
export const NoOp = m('NoOp');
|
|
28
27
|
/** Union of all messages the tabs component can produce. */
|
|
29
28
|
export const Message = S.Union(TabSelected, TabFocused, NoOp);
|
|
30
|
-
/** Creates an initial tabs model from a config. Defaults to first tab
|
|
29
|
+
/** Creates an initial tabs model from a config. Defaults to first tab and automatic activation. */
|
|
31
30
|
export const init = (config) => {
|
|
32
31
|
const activeIndex = config.activeIndex ?? 0;
|
|
33
32
|
return {
|
|
34
33
|
id: config.id,
|
|
35
34
|
activeIndex,
|
|
36
35
|
focusedIndex: activeIndex,
|
|
37
|
-
orientation: config.orientation ?? 'Horizontal',
|
|
38
36
|
activationMode: config.activationMode ?? 'Automatic',
|
|
39
37
|
};
|
|
40
38
|
};
|
|
@@ -48,14 +46,14 @@ export const update = (model, message) => M.value(message).pipe(M.withReturnType
|
|
|
48
46
|
activeIndex: () => index,
|
|
49
47
|
focusedIndex: () => index,
|
|
50
48
|
}),
|
|
51
|
-
[Task.focus(tabSelector, (
|
|
49
|
+
[Task.focus(tabSelector).pipe(Effect.ignore, Effect.as(NoOp()))],
|
|
52
50
|
];
|
|
53
51
|
},
|
|
54
52
|
TabFocused: ({ index }) => {
|
|
55
53
|
const tabSelector = `#${tabId(model.id, index)}`;
|
|
56
54
|
return [
|
|
57
55
|
evo(model, { focusedIndex: () => index }),
|
|
58
|
-
[Task.focus(tabSelector, (
|
|
56
|
+
[Task.focus(tabSelector).pipe(Effect.ignore, Effect.as(NoOp()))],
|
|
59
57
|
];
|
|
60
58
|
},
|
|
61
59
|
NoOp: () => [model, []],
|
|
@@ -65,9 +63,9 @@ const tabId = (id, index) => `${id}-tab-${index}`;
|
|
|
65
63
|
/** Renders a headless tab group with accessible ARIA roles, roving tabindex, and keyboard navigation. */
|
|
66
64
|
export const view = (config) => {
|
|
67
65
|
const { div, empty, AriaControls, AriaDisabled, AriaLabelledBy, AriaOrientation, AriaSelected, Class, DataAttribute, Disabled, Hidden, Id, OnClick, OnKeyDownPreventDefault, Role, Tabindex, Type, keyed, } = html();
|
|
68
|
-
const { model, model: { id,
|
|
66
|
+
const { model, model: { id, activationMode, focusedIndex }, toMessage, tabs, tabToConfig, isTabDisabled, persistPanels, orientation = 'Horizontal', tabListElement = 'div', tabElement = 'button', panelElement = 'div', className, tabListClassName, } = config;
|
|
69
67
|
const isDisabled = (index) => !!isTabDisabled &&
|
|
70
|
-
pipe(tabs, Array.get(index), Option.exists(
|
|
68
|
+
pipe(tabs, Array.get(index), Option.exists(tab => isTabDisabled(tab, index)));
|
|
71
69
|
const { nextKey, previousKey } = M.value(orientation).pipe(M.when('Horizontal', () => ({
|
|
72
70
|
nextKey: 'ArrowRight',
|
|
73
71
|
previousKey: 'ArrowLeft',
|
|
@@ -114,7 +112,7 @@ export const view = (config) => {
|
|
|
114
112
|
});
|
|
115
113
|
const activePanelOnly = pipe(tabs, Array.get(model.activeIndex), Option.match({
|
|
116
114
|
onNone: () => empty,
|
|
117
|
-
onSome:
|
|
115
|
+
onSome: tab => {
|
|
118
116
|
const activeConfig = tabToConfig(tab, { isActive: true });
|
|
119
117
|
return keyed(panelElement)(tabPanelId(id, model.activeIndex), [
|
|
120
118
|
Class(activeConfig.panelClassName),
|
package/dist/url/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const LocationAndHrefFromString = S.transformOrFail(S.String, LocationAndHref, {
|
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
},
|
|
34
|
-
catch:
|
|
34
|
+
catch: error => new ParseResult.Type(ast, urlString, `Invalid URL: ${error}`),
|
|
35
35
|
}),
|
|
36
36
|
encode: ({ href, location }) => {
|
|
37
37
|
const portString = location.port ? `:${location.port}` : '';
|
|
@@ -52,14 +52,14 @@ const UrlFromLocationAndHref = S.transform(LocationAndHref, Url, {
|
|
|
52
52
|
hash: OptionExt.fromString(hashPart || ''),
|
|
53
53
|
};
|
|
54
54
|
},
|
|
55
|
-
encode:
|
|
55
|
+
encode: url => {
|
|
56
56
|
const search = Option.match(url.search, {
|
|
57
57
|
onNone: () => '',
|
|
58
|
-
onSome:
|
|
58
|
+
onSome: s => `?${s}`,
|
|
59
59
|
});
|
|
60
60
|
const hash = Option.match(url.hash, {
|
|
61
61
|
onNone: () => '',
|
|
62
|
-
onSome:
|
|
62
|
+
onSome: h => `#${h}`,
|
|
63
63
|
});
|
|
64
64
|
const href = `${url.pathname}${search}${hash}`;
|
|
65
65
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Elm-inspired UI framework powered by Effect",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,10 +11,18 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./command": {
|
|
15
|
+
"types": "./dist/command/public.d.ts",
|
|
16
|
+
"import": "./dist/command/public.js"
|
|
17
|
+
},
|
|
14
18
|
"./html": {
|
|
15
19
|
"types": "./dist/html/public.d.ts",
|
|
16
20
|
"import": "./dist/html/public.js"
|
|
17
21
|
},
|
|
22
|
+
"./message": {
|
|
23
|
+
"types": "./dist/message/public.d.ts",
|
|
24
|
+
"import": "./dist/message/public.js"
|
|
25
|
+
},
|
|
18
26
|
"./navigation": {
|
|
19
27
|
"types": "./dist/navigation/public.d.ts",
|
|
20
28
|
"import": "./dist/navigation/public.js"
|
|
@@ -39,6 +47,10 @@
|
|
|
39
47
|
"types": "./dist/struct/public.d.ts",
|
|
40
48
|
"import": "./dist/struct/public.js"
|
|
41
49
|
},
|
|
50
|
+
"./task": {
|
|
51
|
+
"types": "./dist/task/public.d.ts",
|
|
52
|
+
"import": "./dist/task/public.js"
|
|
53
|
+
},
|
|
42
54
|
"./ui": {
|
|
43
55
|
"types": "./dist/ui/index.d.ts",
|
|
44
56
|
"import": "./dist/ui/index.js"
|