webcoreui 1.1.0-beta.2 → 1.1.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 +43 -7
- package/astro.d.ts +3 -0
- package/astro.js +2 -0
- package/components/Alert/alert.ts +1 -0
- package/components/Card/card.ts +1 -0
- package/components/Carousel/Carousel.tsx +1 -1
- package/components/ContextMenu/ContextMenu.astro +95 -0
- package/components/ContextMenu/ContextMenu.svelte +81 -0
- package/components/ContextMenu/ContextMenu.tsx +83 -0
- package/components/ContextMenu/contextmenu.module.scss +24 -0
- package/components/ContextMenu/contextmenu.ts +19 -0
- package/components/Flex/flex.ts +1 -0
- package/components/Grid/grid.ts +1 -0
- package/components/Masonry/Masonry.tsx +1 -1
- package/components/TimelineItem/timelineitem.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +10 -11
- package/react.d.ts +3 -0
- package/react.js +2 -0
- package/svelte.d.ts +3 -0
- package/svelte.js +2 -0
- package/utils/context.ts +20 -0
- package/utils/webcore.ts +0 -28
package/README.md
CHANGED
|
@@ -40,14 +40,18 @@
|
|
|
40
40
|
- [Documentation](#documentation)
|
|
41
41
|
- [Getting started](#getting-started)
|
|
42
42
|
- [Prerequisites](#prerequisites)
|
|
43
|
-
- [Installation](#installation)
|
|
43
|
+
- [Installation with CLI](#installation-with-cli)
|
|
44
|
+
- [Manual Installation](#manual-installation)
|
|
44
45
|
- [Setup](#setup)
|
|
45
46
|
- [Using Components](#using-components)
|
|
46
47
|
- [Components](#components)
|
|
48
|
+
- [Blocks](#blocks)
|
|
49
|
+
- [Templates](#templates)
|
|
47
50
|
|
|
48
51
|
## Documentation
|
|
49
52
|
|
|
50
|
-
Full documentation available on [webcoreui.dev](https://webcoreui.dev).
|
|
53
|
+
- Full documentation available on [webcoreui.dev](https://webcoreui.dev).
|
|
54
|
+
- For installation steps, visit our [setup docs](https://webcoreui.dev/docs/setup).
|
|
51
55
|
|
|
52
56
|
## Getting Started
|
|
53
57
|
|
|
@@ -60,20 +64,41 @@ Webcore can be used as a standalone project, or it can be integrated into your e
|
|
|
60
64
|
|
|
61
65
|
Webcore components use Sass for styling. To use the component library, you must have the following packages installed:
|
|
62
66
|
|
|
63
|
-
- [Sass](https://www.npmjs.com/package/sass) - `v1.
|
|
67
|
+
- [Sass](https://www.npmjs.com/package/sass) - `v1.9`
|
|
64
68
|
- [TypeScript](https://www.npmjs.com/package/typescript) - `v5.8`
|
|
65
69
|
|
|
66
70
|
Depending on your project setup, you'll also need the following packages:
|
|
67
71
|
|
|
68
72
|
- **For Astro projects**
|
|
69
|
-
- [Astro](https://www.npmjs.com/package/astro) - `v5.
|
|
73
|
+
- [Astro](https://www.npmjs.com/package/astro) - `v5.13`
|
|
70
74
|
- **For Svelte projects**
|
|
71
|
-
- [Svelte](https://www.npmjs.com/package/svelte) - `v5.
|
|
75
|
+
- [Svelte](https://www.npmjs.com/package/svelte) - `v5.38`
|
|
72
76
|
- **For React projects**
|
|
73
77
|
- [React](https://www.npmjs.com/package/react) - `v19.0`
|
|
74
78
|
- [React DOM](https://www.npmjs.com/package/react-dom) -`v19.0`
|
|
75
79
|
|
|
76
|
-
### Installation
|
|
80
|
+
### Installation with CLI
|
|
81
|
+
|
|
82
|
+
You can use our CLI tool to create a new Webcore project, or integrate it into an existing project more easily:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Create a new Webcore project
|
|
86
|
+
npm create webcore@latest
|
|
87
|
+
|
|
88
|
+
# Update configuration files for an existing Astro project
|
|
89
|
+
npm create webcore@lates config
|
|
90
|
+
|
|
91
|
+
# Create a new Webcore project with a specific template
|
|
92
|
+
npm create webcore@latest template [TemplateName] [destination]
|
|
93
|
+
|
|
94
|
+
# Use the "Portfolio" template on the current directory
|
|
95
|
+
npm create webcore@latest template Portfolio
|
|
96
|
+
|
|
97
|
+
# Create the "Portfolio" template in the "portfolio" directory
|
|
98
|
+
npm create webcore@latest template Portfolio ./portfolio
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Manual Installation
|
|
77
102
|
|
|
78
103
|
Install Webcore as a dependency by running one of the following command:
|
|
79
104
|
|
|
@@ -87,6 +112,16 @@ yarn add webcoreui
|
|
|
87
112
|
|
|
88
113
|
### Setup
|
|
89
114
|
|
|
115
|
+
Add the following integration to your Astro configuration file (`astro.config.mjs`) at the root of your project directory:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
import { webcore } from 'webcoreui/integration'
|
|
119
|
+
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
integrations: [webcore()]
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
|
|
90
125
|
Create an empty [`webcore.config.scss`](https://webcoreui.dev/docs/css-configuration#webcoreconfigscss) file at the root of your project to setup CSS configurations. Setup default styles and fonts by calling the following in your global SCSS file:
|
|
91
126
|
|
|
92
127
|
```scss
|
|
@@ -101,7 +136,7 @@ Create an empty [`webcore.config.scss`](https://webcoreui.dev/docs/css-configura
|
|
|
101
136
|
> [!TIP]
|
|
102
137
|
> You can download the fonts Webcore uses from the [`public/fonts`](https://github.com/Frontendland/webcoreui/tree/main/public/fonts) directory.
|
|
103
138
|
|
|
104
|
-
The `
|
|
139
|
+
The `setup` mixin can also accept the following options:
|
|
105
140
|
|
|
106
141
|
|
|
107
142
|
| Property | Default value | Purpose |
|
|
@@ -244,6 +279,7 @@ import { Accordion } from 'webcoreui/react'
|
|
|
244
279
|
- [Checkbox](https://github.com/Frontendland/webcoreui/tree/main/src/components/Checkbox)
|
|
245
280
|
- [Collapsible](https://github.com/Frontendland/webcoreui/tree/main/src/components/Collapsible)
|
|
246
281
|
- [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
|
|
282
|
+
- [ContextMenu](https://github.com/Frontendland/webcoreui/tree/main/src/components/ContextMenu)
|
|
247
283
|
- [Copy](https://github.com/Frontendland/webcoreui/tree/main/src/components/Copy)
|
|
248
284
|
- [DataTable](https://github.com/Frontendland/webcoreui/tree/main/src/components/DataTable)
|
|
249
285
|
- [Flex](https://github.com/Frontendland/webcoreui/tree/main/src/components/Flex)
|
package/astro.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { CarouselProps as WCarouselProps } from './components/Carousel/caro
|
|
|
12
12
|
import type { CheckboxProps as WCheckboxProps } from './components/Checkbox/checkbox'
|
|
13
13
|
import type { CollapsibleProps as WCollapsibleProps } from './components/Collapsible/collapsible'
|
|
14
14
|
import type { ConditionalWrapperProps as WConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
|
|
15
|
+
import type { ContextMenuProps as WContextMenuProps } from './components/ContextMenu/contextmenu'
|
|
15
16
|
import type { CopyProps as WCopyProps } from './components/Copy/copy'
|
|
16
17
|
import type { DataTableProps as WDataTableProps } from './components/DataTable/datatable'
|
|
17
18
|
import type { FlexProps as WFlexProps } from './components/Flex/flex'
|
|
@@ -70,6 +71,7 @@ declare module 'webcoreui/astro' {
|
|
|
70
71
|
export function Checkbox(_props: WCheckboxProps): any
|
|
71
72
|
export function Collapsible(_props: WCollapsibleProps): any
|
|
72
73
|
export function ConditionalWrapper(_props: WConditionalWrapperProps): any
|
|
74
|
+
export function ContextMenu(_props: WContextMenuProps): any
|
|
73
75
|
export function Copy(_props: WCopyProps): any
|
|
74
76
|
export function DataTable(_props: WDataTableProps): any
|
|
75
77
|
export function Flex(_props: WFlexProps): any
|
|
@@ -122,6 +124,7 @@ declare module 'webcoreui/astro' {
|
|
|
122
124
|
export type CheckboxProps = WCheckboxProps
|
|
123
125
|
export type CollapsibleProps = WCollapsibleProps
|
|
124
126
|
export type ConditionalWrapperProps = WConditionalWrapperProps
|
|
127
|
+
export type ContextMenuProps = WContextMenuProps
|
|
125
128
|
export type CopyProps = WCopyProps
|
|
126
129
|
export type DataTableProps = WDataTableProps
|
|
127
130
|
export type FlexProps = WFlexProps
|
package/astro.js
CHANGED
|
@@ -12,6 +12,7 @@ import CarouselComponent from './components/Carousel/Carousel.astro'
|
|
|
12
12
|
import CheckboxComponent from './components/Checkbox/Checkbox.astro'
|
|
13
13
|
import CollapsibleComponent from './components/Collapsible/Collapsible.astro'
|
|
14
14
|
import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.astro'
|
|
15
|
+
import ContextMenuComponent from './components/ContextMenu/ContextMenu.astro'
|
|
15
16
|
import CopyComponent from './components/Copy/Copy.astro'
|
|
16
17
|
import DataTableComponent from './components/DataTable/DataTable.astro'
|
|
17
18
|
import FlexComponent from './components/Flex/Flex.astro'
|
|
@@ -64,6 +65,7 @@ export const Carousel = CarouselComponent
|
|
|
64
65
|
export const Checkbox = CheckboxComponent
|
|
65
66
|
export const Collapsible = CollapsibleComponent
|
|
66
67
|
export const ConditionalWrapper = ConditionalWrapperComponent
|
|
68
|
+
export const ContextMenu = ContextMenuComponent
|
|
67
69
|
export const Copy = CopyComponent
|
|
68
70
|
export const DataTable = DataTableComponent
|
|
69
71
|
export const Flex = FlexComponent
|
package/components/Card/card.ts
CHANGED
|
@@ -132,7 +132,7 @@ const Carousel = ({
|
|
|
132
132
|
const usedInAstro = carousel.current?.children[0].nodeName === 'ASTRO-SLOT'
|
|
133
133
|
|
|
134
134
|
carouselItems.current = usedInAstro
|
|
135
|
-
? carousel.current
|
|
135
|
+
? carousel.current?.querySelectorAll('li')
|
|
136
136
|
: carousel.current?.children
|
|
137
137
|
|
|
138
138
|
carouselContainer.current?.addEventListener('scroll', scroll)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ContextMenuProps } from './contextmenu'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
|
|
6
|
+
import styles from './contextmenu.module.scss'
|
|
7
|
+
|
|
8
|
+
interface Props extends ContextMenuProps {}
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
element = 'div',
|
|
12
|
+
className,
|
|
13
|
+
...rest
|
|
14
|
+
} = Astro.props
|
|
15
|
+
|
|
16
|
+
const Component = element
|
|
17
|
+
|
|
18
|
+
const classes = classNames([
|
|
19
|
+
styles.ctx,
|
|
20
|
+
className
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
const props = {
|
|
24
|
+
class: classes
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!Astro.slots.has('context')) {
|
|
28
|
+
// eslint-disable-next-line no-console, max-len
|
|
29
|
+
console.error('Missing "context" slot. Attach slot="context" to one of the children of your <ContextMenu> component.')
|
|
30
|
+
}
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<Component {...rest} {...props} data-id="w-ctx">
|
|
34
|
+
<slot />
|
|
35
|
+
<div class={styles.content} data-id="w-ctx-content">
|
|
36
|
+
<slot name="context" />
|
|
37
|
+
</div>
|
|
38
|
+
</Component>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
import { get, on } from '../../utils/DOMUtils'
|
|
42
|
+
|
|
43
|
+
const addEventListeners = () => {
|
|
44
|
+
const ctxs = get('[data-id="w-ctx"]', true) as NodeListOf<HTMLElement>
|
|
45
|
+
const contents: HTMLDivElement[] = []
|
|
46
|
+
|
|
47
|
+
const hideContent = (content: HTMLDivElement, event: MouseEvent) => {
|
|
48
|
+
if (content.contains(event.target as Node)) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
content.dataset.show = 'false'
|
|
53
|
+
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
content.style.top = ''
|
|
56
|
+
content.style.left = ''
|
|
57
|
+
}, 200)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[...ctxs].forEach((ctx, i) => {
|
|
61
|
+
on(ctx, 'contextmenu', (event: MouseEvent) => {
|
|
62
|
+
event.preventDefault()
|
|
63
|
+
|
|
64
|
+
const target = event.currentTarget as HTMLElement
|
|
65
|
+
|
|
66
|
+
if (!contents[i]) {
|
|
67
|
+
contents[i] = target.lastElementChild as HTMLDivElement
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (contents.length > 1) {
|
|
71
|
+
contents.forEach((content, y) => {
|
|
72
|
+
if (i !== y) {
|
|
73
|
+
hideContent(content, event)
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const rect = target.getBoundingClientRect()
|
|
79
|
+
const x = event.clientX - rect.left
|
|
80
|
+
const y = event.clientY - rect.top
|
|
81
|
+
|
|
82
|
+
contents[i].style.top = `${y}px`
|
|
83
|
+
contents[i].style.left = `${x}px`
|
|
84
|
+
contents[i].dataset.show = 'true'
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
on(document, 'click', (event: MouseEvent) => {
|
|
89
|
+
contents.forEach(content => hideContent(content, event))
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
on(document, 'astro:after-swap', addEventListeners)
|
|
94
|
+
addEventListeners()
|
|
95
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import type { SvelteContextMenuProps } from './contextmenu'
|
|
4
|
+
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
import { on } from '../../utils/DOMUtils'
|
|
7
|
+
|
|
8
|
+
import styles from './contextmenu.module.scss'
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
element = 'div',
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
context,
|
|
15
|
+
...rest
|
|
16
|
+
}: SvelteContextMenuProps = $props()
|
|
17
|
+
|
|
18
|
+
const classes = classNames([
|
|
19
|
+
styles.ctx,
|
|
20
|
+
className
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
const showContext = (event: MouseEvent) => {
|
|
24
|
+
event.preventDefault()
|
|
25
|
+
|
|
26
|
+
if (content) {
|
|
27
|
+
const target = event.currentTarget as HTMLElement
|
|
28
|
+
const rect = target.getBoundingClientRect()
|
|
29
|
+
const x = event.clientX - rect.left
|
|
30
|
+
const y = event.clientY - rect.top
|
|
31
|
+
|
|
32
|
+
content.style.top = `${y}px`
|
|
33
|
+
content.style.left = `${x}px`
|
|
34
|
+
content.dataset.show = 'true'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const hideContext = (event: MouseEvent) => {
|
|
39
|
+
if (content) {
|
|
40
|
+
if (content.contains(event.target as Node)) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
content.dataset.show = 'false'
|
|
45
|
+
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
if (content) {
|
|
48
|
+
content.style.top = ''
|
|
49
|
+
content.style.left = ''
|
|
50
|
+
}
|
|
51
|
+
}, 200)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let ctx: HTMLElement
|
|
56
|
+
let content: HTMLDivElement
|
|
57
|
+
|
|
58
|
+
onMount(() => {
|
|
59
|
+
if (ctx && content) {
|
|
60
|
+
on(ctx, 'contextmenu', showContext)
|
|
61
|
+
on(document, 'click', hideContext)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return () => {
|
|
65
|
+
ctx?.removeEventListener('contextmenu', showContext)
|
|
66
|
+
document.removeEventListener('click', hideContext)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
if (!context) {
|
|
71
|
+
// eslint-disable-next-line no-console, max-len
|
|
72
|
+
console.error('Missing "context" slot. Attach slot="context" to one of the children of your <ContextMenu> component.')
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<svelte:element {...rest} this={element} class={classes} bind:this={ctx}>
|
|
77
|
+
{@render children?.()}
|
|
78
|
+
<div class={styles.content} bind:this={content}>
|
|
79
|
+
{@render context?.()}
|
|
80
|
+
</div>
|
|
81
|
+
</svelte:element>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react'
|
|
2
|
+
import type { ReactContextMenuProps } from './contextmenu'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
import { on } from '../../utils/DOMUtils'
|
|
6
|
+
|
|
7
|
+
import styles from './contextmenu.module.scss'
|
|
8
|
+
|
|
9
|
+
const ContextMenu = ({
|
|
10
|
+
Element = 'div',
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
context,
|
|
14
|
+
...rest
|
|
15
|
+
}: ReactContextMenuProps) => {
|
|
16
|
+
const ctx = useRef<HTMLElement>(null)
|
|
17
|
+
const content = useRef<HTMLDivElement>(null)
|
|
18
|
+
const classes = classNames([
|
|
19
|
+
styles.ctx,
|
|
20
|
+
className
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
const showContext = (event: MouseEvent) => {
|
|
24
|
+
event.preventDefault()
|
|
25
|
+
|
|
26
|
+
if (content.current) {
|
|
27
|
+
const target = event.currentTarget as HTMLElement
|
|
28
|
+
const rect = target.getBoundingClientRect()
|
|
29
|
+
const x = event.clientX - rect.left
|
|
30
|
+
const y = event.clientY - rect.top
|
|
31
|
+
|
|
32
|
+
content.current.style.top = `${y}px`
|
|
33
|
+
content.current.style.left = `${x}px`
|
|
34
|
+
content.current.dataset.show = 'true'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const hideContext = (event: MouseEvent) => {
|
|
39
|
+
if (content.current) {
|
|
40
|
+
if (content.current.contains(event.target as Node)) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
content.current.dataset.show = 'false'
|
|
45
|
+
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
if (content.current) {
|
|
48
|
+
content.current.style.top = ''
|
|
49
|
+
content.current.style.left = ''
|
|
50
|
+
}
|
|
51
|
+
}, 200)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (ctx.current) {
|
|
57
|
+
on(ctx.current, 'contextmenu', showContext)
|
|
58
|
+
on(document, 'click', hideContext)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
ctx.current?.removeEventListener('contextmenu', showContext)
|
|
63
|
+
document.removeEventListener('click', hideContext)
|
|
64
|
+
}
|
|
65
|
+
}, [])
|
|
66
|
+
|
|
67
|
+
if (!context) {
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.error('Missing `context` prop. Add `context={...}` to your <ContextMenu> component.')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Element {...rest} className={classes} ref={ctx}>
|
|
74
|
+
{children}
|
|
75
|
+
<div className={styles.content} ref={content} onClick={event => event.stopPropagation()}>
|
|
76
|
+
{context}
|
|
77
|
+
</div>
|
|
78
|
+
</Element>
|
|
79
|
+
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default ContextMenu
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@use '../../scss/config.scss' as *;
|
|
2
|
+
|
|
3
|
+
.ctx {
|
|
4
|
+
@include position(relative);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.content {
|
|
8
|
+
@include position(absolute);
|
|
9
|
+
@include background(primary-70);
|
|
10
|
+
@include size(wmax-content);
|
|
11
|
+
@include layer(modal);
|
|
12
|
+
@include transition(.2s);
|
|
13
|
+
@include visibility(0);
|
|
14
|
+
|
|
15
|
+
transform: scale(.95);
|
|
16
|
+
pointer-events: none;
|
|
17
|
+
|
|
18
|
+
&[data-show="true"] {
|
|
19
|
+
@include visibility(1);
|
|
20
|
+
|
|
21
|
+
transform: scale(1);
|
|
22
|
+
pointer-events: all;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
export type ContextMenuProps = {
|
|
5
|
+
element?: string
|
|
6
|
+
className?: string
|
|
7
|
+
[key: string]: any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type SvelteContextMenuProps = {
|
|
11
|
+
children: Snippet
|
|
12
|
+
context: Snippet
|
|
13
|
+
} & ContextMenuProps
|
|
14
|
+
|
|
15
|
+
export type ReactContextMenuProps = {
|
|
16
|
+
Element?: React.ElementType
|
|
17
|
+
children: React.ReactNode
|
|
18
|
+
context: React.ReactNode
|
|
19
|
+
} & Omit<ContextMenuProps, 'element'>
|
package/components/Flex/flex.ts
CHANGED
package/components/Grid/grid.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ export type Toast = {
|
|
|
126
126
|
declare module 'webcoreui' {
|
|
127
127
|
export const bodyFreeze: (freeze: boolean) => void
|
|
128
128
|
export const classNames: (classes: any[]) => string
|
|
129
|
+
export const closeContext: (ctx: string | HTMLElement) => void
|
|
129
130
|
|
|
130
131
|
export const setCookie: (name: string, value: string, days: number) => void
|
|
131
132
|
export const getCookie: (name: string) => string | null
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcoreui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "husky",
|
|
7
7
|
"pre-commit": "lint-staged",
|
|
@@ -18,13 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@astrojs/check": "0.9.4",
|
|
21
|
-
"@astrojs/node": "9.1
|
|
22
|
-
"@astrojs/react": "4.
|
|
23
|
-
"@astrojs/svelte": "7.0
|
|
21
|
+
"@astrojs/node": "9.4.1",
|
|
22
|
+
"@astrojs/react": "4.3.0",
|
|
23
|
+
"@astrojs/svelte": "7.1.0",
|
|
24
24
|
"@eslint/js": "9.23.0",
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"astro": "5.5.4",
|
|
25
|
+
"@typescript-eslint/parser": "8.39.1",
|
|
26
|
+
"astro": "5.13.0",
|
|
28
27
|
"astro-eslint-parser": "1.2.2",
|
|
29
28
|
"eslint": "9.23.0",
|
|
30
29
|
"eslint-plugin-astro": "1.3.1",
|
|
@@ -36,12 +35,12 @@
|
|
|
36
35
|
"lint-staged": "15.5.0",
|
|
37
36
|
"react": "19.0.0",
|
|
38
37
|
"react-dom": "19.0.0",
|
|
39
|
-
"sass": "1.
|
|
38
|
+
"sass": "1.90.0",
|
|
40
39
|
"sass-true": "8.1.0",
|
|
41
|
-
"svelte": "5.
|
|
40
|
+
"svelte": "5.38.1",
|
|
42
41
|
"svelte-eslint-parser": "1.1.0",
|
|
43
|
-
"typescript": "5.
|
|
44
|
-
"typescript-eslint": "8.
|
|
42
|
+
"typescript": "5.9.2",
|
|
43
|
+
"typescript-eslint": "8.39.1",
|
|
45
44
|
"vite-tsconfig-paths": "5.1.4",
|
|
46
45
|
"vitest": "3.0.4"
|
|
47
46
|
},
|
package/react.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { ReactCarouselProps as WReactCarouselProps } from './components/Car
|
|
|
13
13
|
import type { ReactCheckboxProps as WReactCheckboxProps } from './components/Checkbox/checkbox'
|
|
14
14
|
import type { ReactCollapsibleProps as WReactCollapsibleProps } from './components/Collapsible/collapsible'
|
|
15
15
|
import type { ReactConditionalWrapperProps as WReactConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
|
|
16
|
+
import type { ReactContextMenuProps as WReactContextMenuProps } from './components/ContextMenu/contextmenu'
|
|
16
17
|
import type { ReactCopyProps as WReactCopyProps } from './components/Copy/copy'
|
|
17
18
|
import type { ReactDataTableProps as WReactDataTableProps } from './components/DataTable/datatable'
|
|
18
19
|
import type { ReactFlexProps as WReactFlexProps } from './components/Flex/flex'
|
|
@@ -71,6 +72,7 @@ declare module 'webcoreui/react' {
|
|
|
71
72
|
export const Checkbox: FC<WReactCheckboxProps>
|
|
72
73
|
export const Collapsible: FC<WReactCollapsibleProps>
|
|
73
74
|
export const ConditionalWrapper: FC<WReactConditionalWrapperProps>
|
|
75
|
+
export const ContextMenu: FC<WReactContextMenuProps>
|
|
74
76
|
export const Copy: FC<WReactCopyProps>
|
|
75
77
|
export const DataTable: FC<WReactDataTableProps>
|
|
76
78
|
export const Flex: FC<WReactFlexProps>
|
|
@@ -123,6 +125,7 @@ declare module 'webcoreui/react' {
|
|
|
123
125
|
export type CheckboxProps = WReactCheckboxProps
|
|
124
126
|
export type CollapsibleProps = WReactCollapsibleProps
|
|
125
127
|
export type ConditionalWrapperProps = WReactConditionalWrapperProps
|
|
128
|
+
export type ContextMenuProps = WReactContextMenuProps
|
|
126
129
|
export type CopyProps = WReactCopyProps
|
|
127
130
|
export type DataTableProps = WReactDataTableProps
|
|
128
131
|
export type FlexProps = WReactFlexProps
|
package/react.js
CHANGED
|
@@ -12,6 +12,7 @@ import CarouselComponent from './components/Carousel/Carousel.tsx'
|
|
|
12
12
|
import CheckboxComponent from './components/Checkbox/Checkbox.tsx'
|
|
13
13
|
import CollapsibleComponent from './components/Collapsible/Collapsible.tsx'
|
|
14
14
|
import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.tsx'
|
|
15
|
+
import ContextMenuComponent from './components/ContextMenu/ContextMenu.tsx'
|
|
15
16
|
import CopyComponent from './components/Copy/Copy.tsx'
|
|
16
17
|
import DataTableComponent from './components/DataTable/DataTable.tsx'
|
|
17
18
|
import FlexComponent from './components/Flex/Flex.tsx'
|
|
@@ -64,6 +65,7 @@ export const Carousel = CarouselComponent
|
|
|
64
65
|
export const Checkbox = CheckboxComponent
|
|
65
66
|
export const Collapsible = CollapsibleComponent
|
|
66
67
|
export const ConditionalWrapper = ConditionalWrapperComponent
|
|
68
|
+
export const ContextMenu = ContextMenuComponent
|
|
67
69
|
export const Copy = CopyComponent
|
|
68
70
|
export const DataTable = DataTableComponent
|
|
69
71
|
export const Flex = FlexComponent
|
package/svelte.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { SvelteCarouselProps as WSvelteCarouselProps } from './components/C
|
|
|
13
13
|
import type { SvelteCheckboxProps as WSvelteCheckboxProps } from './components/Checkbox/checkbox'
|
|
14
14
|
import type { SvelteCollapsibleProps as WSvelteCollapsibleProps } from './components/Collapsible/collapsible'
|
|
15
15
|
import type { SvelteConditionalWrapperProps as WSvelteConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
|
|
16
|
+
import type { SvelteContextMenuProps as WSvelteContextMenuProps } from './components/ContextMenu/contextmenu'
|
|
16
17
|
import type { SvelteCopyProps as WSvelteCopyProps } from './components/Copy/copy'
|
|
17
18
|
import type { SvelteDataTableProps as WSvelteDataTableProps } from './components/DataTable/datatable'
|
|
18
19
|
import type { SvelteFlexProps as WSvelteFlexProps } from './components/Flex/flex'
|
|
@@ -71,6 +72,7 @@ declare module 'webcoreui/svelte' {
|
|
|
71
72
|
export const Checkbox: Component<WSvelteCheckboxProps>
|
|
72
73
|
export const Collapsible: Component<WSvelteCollapsibleProps>
|
|
73
74
|
export const ConditionalWrapper: Component<WSvelteConditionalWrapperProps>
|
|
75
|
+
export const ContextMenu: Component<WSvelteContextMenuProps>
|
|
74
76
|
export const Copy: Component<WSvelteCopyProps>
|
|
75
77
|
export const DataTable: Component<WSvelteDataTableProps>
|
|
76
78
|
export const Flex: Component<WSvelteFlexProps>
|
|
@@ -123,6 +125,7 @@ declare module 'webcoreui/svelte' {
|
|
|
123
125
|
export type CheckboxProps = WSvelteCheckboxProps
|
|
124
126
|
export type CollapsibleProps = WSvelteCollapsibleProps
|
|
125
127
|
export type ConditionalWrapperProps = WSvelteConditionalWrapperProps
|
|
128
|
+
export type ContextMenuProps = WSvelteContextMenuProps
|
|
126
129
|
export type CopyProps = WSvelteCopyProps
|
|
127
130
|
export type DataTableProps = WSvelteDataTableProps
|
|
128
131
|
export type FlexProps = WSvelteFlexProps
|
package/svelte.js
CHANGED
|
@@ -12,6 +12,7 @@ import CarouselComponent from './components/Carousel/Carousel.svelte'
|
|
|
12
12
|
import CheckboxComponent from './components/Checkbox/Checkbox.svelte'
|
|
13
13
|
import CollapsibleComponent from './components/Collapsible/Collapsible.svelte'
|
|
14
14
|
import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.svelte'
|
|
15
|
+
import ContextMenuComponent from './components/ContextMenu/ContextMenu.svelte'
|
|
15
16
|
import CopyComponent from './components/Copy/Copy.svelte'
|
|
16
17
|
import DataTableComponent from './components/DataTable/DataTable.svelte'
|
|
17
18
|
import FlexComponent from './components/Flex/Flex.svelte'
|
|
@@ -64,6 +65,7 @@ export const Carousel = CarouselComponent
|
|
|
64
65
|
export const Checkbox = CheckboxComponent
|
|
65
66
|
export const Collapsible = CollapsibleComponent
|
|
66
67
|
export const ConditionalWrapper = ConditionalWrapperComponent
|
|
68
|
+
export const ContextMenu = ContextMenuComponent
|
|
67
69
|
export const Copy = CopyComponent
|
|
68
70
|
export const DataTable = DataTableComponent
|
|
69
71
|
export const Flex = FlexComponent
|
package/utils/context.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const closeContext = (ctx: string | HTMLElement) => {
|
|
2
|
+
const element = typeof ctx === 'string'
|
|
3
|
+
? document.querySelector(ctx) as HTMLElement
|
|
4
|
+
: ctx
|
|
5
|
+
|
|
6
|
+
const parent = element?.parentElement as HTMLElement
|
|
7
|
+
|
|
8
|
+
if (!parent) {
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
console.error('Could not found context for:', ctx)
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parent.dataset.show = 'false'
|
|
15
|
+
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
parent.style.top = ''
|
|
18
|
+
parent.style.left = ''
|
|
19
|
+
}, 200)
|
|
20
|
+
}
|
package/utils/webcore.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AstroIntegration } from 'astro'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
export const webcore = (): AstroIntegration => {
|
|
5
|
-
return {
|
|
6
|
-
name: 'webcoreui',
|
|
7
|
-
hooks: {
|
|
8
|
-
'astro:config:setup': ({ updateConfig }) => {
|
|
9
|
-
updateConfig({
|
|
10
|
-
vite: {
|
|
11
|
-
ssr: {
|
|
12
|
-
noExternal: ['webcoreui']
|
|
13
|
-
},
|
|
14
|
-
css: {
|
|
15
|
-
preprocessorOptions: {
|
|
16
|
-
scss: {
|
|
17
|
-
loadPaths: [
|
|
18
|
-
path.resolve(process.cwd())
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|