@kanso-protocol/core 2.0.1 → 2.0.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.
|
@@ -27,6 +27,34 @@ const KP_ICON_SIZES = {
|
|
|
27
27
|
xl: 24,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Find the right portal target for a floating overlay (select dropdown,
|
|
32
|
+
* combobox listbox, popover panel, etc.) so it stays in the same
|
|
33
|
+
* stacking context as its trigger.
|
|
34
|
+
*
|
|
35
|
+
* Background: Kanso `<kp-dialog>` uses native `<dialog>.showModal()`
|
|
36
|
+
* which places the dialog in the browser's **top-layer**. Anything
|
|
37
|
+
* portaled to `document.body` ends up BELOW the top-layer — invisible
|
|
38
|
+
* and inert. To stay visible / interactive, overlays must portal
|
|
39
|
+
* inside the nearest open `<dialog>` ancestor instead.
|
|
40
|
+
*
|
|
41
|
+
* Outside a dialog, `document.body` is still the right target so the
|
|
42
|
+
* overlay isn't clipped by any transformed / overflow:hidden ancestor.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const target = findPortalTarget(this.host.nativeElement, this.doc);
|
|
46
|
+
* if (target && el.parentElement !== target) target.appendChild(el);
|
|
47
|
+
*/
|
|
48
|
+
function findPortalTarget(host, doc) {
|
|
49
|
+
let el = host;
|
|
50
|
+
while (el) {
|
|
51
|
+
if (el.tagName === 'DIALOG' && el.open)
|
|
52
|
+
return el;
|
|
53
|
+
el = el.parentElement;
|
|
54
|
+
}
|
|
55
|
+
return doc.body;
|
|
56
|
+
}
|
|
57
|
+
|
|
30
58
|
// Kanso Protocol — Core
|
|
31
59
|
// This file re-exports generated token constants and core utilities.
|
|
32
60
|
// Generated tokens will be available after running `npm run build:tokens`
|
|
@@ -36,5 +64,5 @@ const KP_ICON_SIZES = {
|
|
|
36
64
|
* Generated bundle index. Do not edit.
|
|
37
65
|
*/
|
|
38
66
|
|
|
39
|
-
export { KP_ICON_SIZES, KP_RADII, KP_SIZES };
|
|
67
|
+
export { KP_ICON_SIZES, KP_RADII, KP_SIZES, findPortalTarget };
|
|
40
68
|
//# sourceMappingURL=kanso-protocol-core.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kanso-protocol-core.mjs","sources":["../../../../packages/core/src/lib/types.ts","../../../../packages/core/src/index.ts","../../../../packages/core/src/kanso-protocol-core.ts"],"sourcesContent":["/**\n * Kanso Protocol — Core Types\n *\n * These types define the shared API contract for all components.\n * Every interactive component MUST use these types consistently.\n */\n\n/** Component size scale */\nexport type KpSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n/** Visual variant */\nexport type KpVariant = 'default' | 'subtle' | 'outline' | 'ghost';\n\n/** Color role */\nexport type KpColorRole = 'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'info' | 'neutral';\n\n/** Interactive component states (for documentation/testing) */\nexport type KpState = 'rest' | 'hover' | 'active' | 'focus' | 'disabled' | 'loading' | 'error';\n\n/** Size-to-value mappings */\nexport const KP_SIZES: Record<KpSize, number> = {\n xs: 24,\n sm: 28,\n md: 36,\n lg: 44,\n xl: 52,\n};\n\nexport const KP_RADII: Record<KpSize, number> = {\n xs: 8,\n sm: 10,\n md: 12,\n lg: 14,\n xl: 16,\n};\n\nexport const KP_ICON_SIZES: Record<KpSize, number> = {\n xs: 14,\n sm: 16,\n md: 18,\n lg: 22,\n xl: 24,\n};\n","// Kanso Protocol — Core\n// This file re-exports generated token constants and core utilities.\n\n// Generated tokens will be available after running `npm run build:tokens`\n// import { kpColorPrimaryDefaultBgRest } from './_generated/tokens';\n\nexport * from './lib/types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAcH;AACO,MAAM,QAAQ,GAA2B;AAC9C,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;;AAGD,MAAM,QAAQ,GAA2B;AAC9C,IAAA,EAAE,EAAE,CAAC;AACL,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;;AAGD,MAAM,aAAa,GAA2B;AACnD,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;;;ACzCR;AACA;AAEA;AACA;;ACJA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"kanso-protocol-core.mjs","sources":["../../../../packages/core/src/lib/types.ts","../../../../packages/core/src/lib/portal.ts","../../../../packages/core/src/index.ts","../../../../packages/core/src/kanso-protocol-core.ts"],"sourcesContent":["/**\n * Kanso Protocol — Core Types\n *\n * These types define the shared API contract for all components.\n * Every interactive component MUST use these types consistently.\n */\n\n/** Component size scale */\nexport type KpSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n/** Visual variant */\nexport type KpVariant = 'default' | 'subtle' | 'outline' | 'ghost';\n\n/** Color role */\nexport type KpColorRole = 'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'info' | 'neutral';\n\n/** Interactive component states (for documentation/testing) */\nexport type KpState = 'rest' | 'hover' | 'active' | 'focus' | 'disabled' | 'loading' | 'error';\n\n/** Size-to-value mappings */\nexport const KP_SIZES: Record<KpSize, number> = {\n xs: 24,\n sm: 28,\n md: 36,\n lg: 44,\n xl: 52,\n};\n\nexport const KP_RADII: Record<KpSize, number> = {\n xs: 8,\n sm: 10,\n md: 12,\n lg: 14,\n xl: 16,\n};\n\nexport const KP_ICON_SIZES: Record<KpSize, number> = {\n xs: 14,\n sm: 16,\n md: 18,\n lg: 22,\n xl: 24,\n};\n","/**\n * Find the right portal target for a floating overlay (select dropdown,\n * combobox listbox, popover panel, etc.) so it stays in the same\n * stacking context as its trigger.\n *\n * Background: Kanso `<kp-dialog>` uses native `<dialog>.showModal()`\n * which places the dialog in the browser's **top-layer**. Anything\n * portaled to `document.body` ends up BELOW the top-layer — invisible\n * and inert. To stay visible / interactive, overlays must portal\n * inside the nearest open `<dialog>` ancestor instead.\n *\n * Outside a dialog, `document.body` is still the right target so the\n * overlay isn't clipped by any transformed / overflow:hidden ancestor.\n *\n * @example\n * const target = findPortalTarget(this.host.nativeElement, this.doc);\n * if (target && el.parentElement !== target) target.appendChild(el);\n */\nexport function findPortalTarget(host: HTMLElement, doc: Document): HTMLElement {\n let el: HTMLElement | null = host;\n while (el) {\n if (el.tagName === 'DIALOG' && (el as HTMLDialogElement).open) return el;\n el = el.parentElement;\n }\n return doc.body;\n}\n","// Kanso Protocol — Core\n// This file re-exports generated token constants and core utilities.\n\n// Generated tokens will be available after running `npm run build:tokens`\n// import { kpColorPrimaryDefaultBgRest } from './_generated/tokens';\n\nexport * from './lib/types';\nexport * from './lib/portal';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAcH;AACO,MAAM,QAAQ,GAA2B;AAC9C,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;;AAGD,MAAM,QAAQ,GAA2B;AAC9C,IAAA,EAAE,EAAE,CAAC;AACL,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;;AAGD,MAAM,aAAa,GAA2B;AACnD,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,EAAE,EAAE,EAAE;;;ACzCR;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,gBAAgB,CAAC,IAAiB,EAAE,GAAa,EAAA;IAC/D,IAAI,EAAE,GAAuB,IAAI;IACjC,OAAO,EAAE,EAAE;QACT,IAAI,EAAE,CAAC,OAAO,KAAK,QAAQ,IAAK,EAAwB,CAAC,IAAI;AAAE,YAAA,OAAO,EAAE;AACxE,QAAA,EAAE,GAAG,EAAE,CAAC,aAAa;IACvB;IACA,OAAO,GAAG,CAAC,IAAI;AACjB;;ACzBA;AACA;AAEA;AACA;;ACJA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -17,5 +17,25 @@ declare const KP_SIZES: Record<KpSize, number>;
|
|
|
17
17
|
declare const KP_RADII: Record<KpSize, number>;
|
|
18
18
|
declare const KP_ICON_SIZES: Record<KpSize, number>;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Find the right portal target for a floating overlay (select dropdown,
|
|
22
|
+
* combobox listbox, popover panel, etc.) so it stays in the same
|
|
23
|
+
* stacking context as its trigger.
|
|
24
|
+
*
|
|
25
|
+
* Background: Kanso `<kp-dialog>` uses native `<dialog>.showModal()`
|
|
26
|
+
* which places the dialog in the browser's **top-layer**. Anything
|
|
27
|
+
* portaled to `document.body` ends up BELOW the top-layer — invisible
|
|
28
|
+
* and inert. To stay visible / interactive, overlays must portal
|
|
29
|
+
* inside the nearest open `<dialog>` ancestor instead.
|
|
30
|
+
*
|
|
31
|
+
* Outside a dialog, `document.body` is still the right target so the
|
|
32
|
+
* overlay isn't clipped by any transformed / overflow:hidden ancestor.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const target = findPortalTarget(this.host.nativeElement, this.doc);
|
|
36
|
+
* if (target && el.parentElement !== target) target.appendChild(el);
|
|
37
|
+
*/
|
|
38
|
+
declare function findPortalTarget(host: HTMLElement, doc: Document): HTMLElement;
|
|
39
|
+
|
|
40
|
+
export { KP_ICON_SIZES, KP_RADII, KP_SIZES, findPortalTarget };
|
|
21
41
|
export type { KpColorRole, KpSize, KpState, KpVariant };
|