Skip to content

Commit

Permalink
fix: update rollup to avoid losing reactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
cafadev committed Jun 19, 2023
1 parent f3c227e commit fd9fca3
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 181 deletions.
13 changes: 5 additions & 8 deletions demo/main.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
import { createApp } from 'vue'
import type { ZodAny } from 'zod'
import axios from 'axios'
import '@oruga-ui/oruga-next/dist/oruga-full.css'
import Oruga from '@oruga-ui/oruga-next'
import { FancyCrud } from '@fancy-crud/vue'
import Oruga from '@oruga-ui/oruga-next'

import { defaultClasses, fields, orugaFlowbite, table, utils } from '../src/wrappers'
import { defaultCustomization, fields, table, utils } from '../src'
import App from './App.vue'

import '@mdi/font/css/materialdesignicons.css'
import '@fancy-crud/vue/dist/fancy-crud-vue.css'
import './styles/main.sass'
import '../src/styles/index.sass'

axios.defaults.baseURL = 'http://localhost:9000/api/'

const app = createApp(App)

app.use(Oruga, orugaFlowbite)
app.use(Oruga)
app.use(FancyCrud, {
http: {
service: axios,
},
fields,
utils,
table,
defaultClasses,
defaultClasses: defaultCustomization,
ruleOptions: {
processResult: (raw: { value: unknown; rule: ZodAny }) => {
const { value, rule } = raw
Expand Down
2 changes: 2 additions & 0 deletions demo/viewer/FCheckboxViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ const form = useForm({
url: 'artists/',
},
})
console.log(form.fields.checkbox)
</script>
3 changes: 3 additions & 0 deletions demo/viewer/FInputViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<script lang='ts' setup>
import { z } from 'zod'
import { FieldType, useForm } from '@fancy-crud/vue'
import { getDefaults } from '@fancy-crud/core'
// import { NotificationType, useForm } from '@/forms/integration'
// const { rules } = useRules()
Expand Down Expand Up @@ -74,5 +75,7 @@ const form = useForm({
},
settings,
})
console.log(form.buttons)
</script>

1 change: 1 addition & 0 deletions demo/viewer/FRadioViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const form = useForm({
radio: {
label: 'Radio',
type: 'radio',
inRow: true,
optionLabel: 'label',
optionValue: 'value',
options: [
Expand Down
103 changes: 0 additions & 103 deletions demo/viewer/FTableViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,109 +66,6 @@ const table = useTable({
},
})
// const data = [
// {
// id: 1,
// name: 'Fredy',
// gender: 'm',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-01-01T21:51:25.587947-06:00',
// updated_at: '2023-05-27T13:27:32.958539-06:00',
// },
// {
// id: 2,
// name: 'Sami',
// gender: 'f',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-01-01T21:52:53.183908-06:00',
// updated_at: '2023-01-01T21:52:53.183944-06:00',
// },
// {
// id: 3,
// name: 'Pat',
// gender: 'm',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-01-04T15:51:28.429890-06:00',
// updated_at: '2023-01-04T15:51:28.429991-06:00',
// },
// {
// id: 4,
// name: 'New',
// gender: 'm',
// image: null,
// image2: null,
// is_active: false,
// created_at: '2023-02-20T12:14:22.899425-06:00',
// updated_at: '2023-02-20T12:14:58.061190-06:00',
// },
// {
// id: 5,
// name: 'not',
// gender: 'f',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-02-20T12:22:26.391576-06:00',
// updated_at: '2023-02-20T12:22:26.391654-06:00',
// },
// {
// id: 6,
// name: '12222',
// gender: 'f',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-05-20T11:52:52.333315-06:00',
// updated_at: '2023-05-20T11:52:52.333365-06:00',
// },
// {
// id: 7,
// name: 'ref',
// gender: 'm',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-05-21T21:05:59.197929-06:00',
// updated_at: '2023-05-21T21:05:59.197993-06:00',
// },
// {
// id: 8,
// name: 'refd',
// gender: 'm',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-05-21T21:06:23.797258-06:00',
// updated_at: '2023-05-21T21:06:23.797304-06:00',
// },
// {
// id: 9,
// name: 'refr',
// gender: 'm',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-05-21T21:07:25.663547-06:00',
// updated_at: '2023-05-28T09:39:08.161961-06:00',
// },
// {
// id: 16,
// name: 'c',
// gender: 'm',
// image: null,
// image2: null,
// is_active: true,
// created_at: '2023-05-31T06:41:50.400785-06:00',
// updated_at: '2023-05-31T06:41:50.400868-06:00',
// },
// ]
setTimeout(() => {
form.fields.name.placeholder = 'Vaya vaya'
}, 3000)
Expand Down
28 changes: 19 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@
"type": "git",
"url": "https://github.com/fancy-crud"
},
"main": "./dist/oruga-wraper.cjs",
"module": "./dist/oruga-wraper.cjs",
"main": "./dist/fancy-crud-oruga-wrapper.umd.js",
"module": "./dist/fancy-crud-oruga-wrapper.es.js",
"exports": {
".": {
"import": "./dist/fancy-crud-oruga-wrapper.es.js",
"require": "./dist/fancy-crud-oruga-wrapper.umd.js"
},
"./dist/fancy-crud-oruga-wrapper.css": {
"import": "./dist/fancy-crud-oruga-wrapper.css",
"require": "./dist/fancy-crud-oruga-wrapper.css"
}
},
"types": "./dist/src/index.d.ts",
"files": [
"dist"
Expand All @@ -24,18 +34,18 @@
"lint:fix": "eslint . --fix"
},
"peerDependencies": {
"@oruga-ui/oruga-next": "^0.6.0",
"@fancy-crud/core": "^1.0.0",
"@fancy-crud/core": "^1.4.0",
"@fancy-crud/vue": "^1.0.0",
"@oruga-ui/oruga-next": "^0.6.0",
"@vueuse/core": "^9.9.0",
"esno": "0.10.0",
"lodash": "^4.17.21",
"vue": "^3.2.19"
},
"dependencies": {
"@oruga-ui/oruga-next": "^0.6.0",
"@fancy-crud/core": "^1.0.0",
"@fancy-crud/core": "^1.4.0",
"@fancy-crud/vue": "^1.0.0",
"@oruga-ui/oruga-next": "^0.6.0",
"@vueuse/core": "^9.9.0",
"esno": "0.10.0",
"lodash": "^4.17.21",
Expand All @@ -47,7 +57,9 @@
"@types/node": "^18.7.23",
"@vitejs/plugin-vue": "^3.1.0",
"@vue/test-utils": "^2.0.2",
"@vue/tsconfig": "^0.1.3",
"autoprefixer": "^10.4.13",
"axios": "^1.4.0",
"cross-env": "^7.0.3",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -66,9 +78,7 @@
"vite-plugin-pages": "^0.26.0",
"vitest": "^0.23.4",
"vue-tsc": "^1.0.24",
"zod": "^3.21.4",
"axios": "^1.4.0",
"@vue/tsconfig": "^0.1.3"
"zod": "^3.21.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion src/common/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LoadingIcon from './LoadingIcon.vue'
export default defineComponent({
props: {
icon: { type: String, default: () => '' },
borderless: { type: String, default: () => '' },
borderless: { type: Boolean, default: () => false },
isLoading: { type: Boolean, default: () => false },
},
Expand Down
2 changes: 1 addition & 1 deletion src/common/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineComponent({
const modelValue = useVModel(props, 'modelValue', emit)
return () =>
h(OModal, { ...attrs, 'active': modelValue.value, 'onUpdate:active': (e: boolean) => modelValue.value = e, 'width': '640' }, slots)
h(OModal, { ...attrs, 'active': modelValue.value, 'onUpdate:active': (e: boolean) => modelValue.value = e, 'width': '960', 'scroll': 'clip' }, slots)
},
})
</script>
2 changes: 1 addition & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './defaults'
export * from './themes'
2 changes: 2 additions & 0 deletions src/fields/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ function getCheckboxAttributes(value: unknown) {
if (props.field.multiple) {
attributes = {
nativeValue: value,
...props.field,
}
}
else {
attributes = {
trueValue: value,
falseValue: null,
...props.field,
}
}
Expand Down
62 changes: 23 additions & 39 deletions src/fields/Radio.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
<script lang="ts">
import _ from 'lodash'
import { OField, ORadio } from '@oruga-ui/oruga-next'
import type { NormalizedRadioField } from '@fancy-crud/core'
import type { PropType } from 'vue'
import { useRadioField } from '@fancy-crud/vue'
<template>
<o-field v-bind="props.field.wrapper" :label="props.field.label" :variant="variant" :message="hintText">
<div :class="display">
<template v-for="([label, value], _index) in options" :key="_index">
<o-radio v-bind="props.field" v-model="modelValue" :name="nameIdentifier" :native-value="value">
{{ label }}
</o-radio>
</template>
</div>
</o-field>
</template>

export default defineComponent({
props: {
formId: {
type: Symbol,
required: true,
},
field: {
type: Object as PropType<NormalizedRadioField>,
required: true,
},
},
<script lang="ts" setup>
import { ORadio } from '@oruga-ui/oruga-next'
import { useRadioField } from '@fancy-crud/vue'
import type { NormalizedRadioField } from '@fancy-crud/vue'
setup(props, { attrs, slots }) {
const { vmodel, hasFieldErrors, hintText, inRowDisplay, options } = useRadioField(props)
const props = defineProps<{
formId: symbol
field: NormalizedRadioField
}>()
const nameIdentifier = Symbol(props.field.modelKey).toString()
const nameIdentifier = Symbol(props.field.modelKey).toString()
const variant = computed(() => hasFieldErrors.value ? 'danger' : '')
const { modelValue, hasFieldErrors, hintText, inRowDisplay, options } = useRadioField(props)
function renderOptions() {
return options.value.map(
([label, value]) => h(
ORadio, { ...attrs, ...vmodel, name: nameIdentifier, nativeValue: value }, {
default: () => String(label),
...slots,
}),
)
}
const display = computed(() => inRowDisplay.value ? inRowDisplay.value : 'radio-group--cascade')
return () =>
h(OField, { ...props.field.wrapper, label: props.field.label, message: hintText.value, variant: variant.value }, {
default: () => h('div', { class: inRowDisplay },
renderOptions(),
),
})
},
})
const variant = computed(() => hasFieldErrors.value ? 'danger' : '')
</script>

3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ export * from './common'
export * from './fields'
export * from './table'
export * from './config'

// eslint-disable-next-line import/first
import './styles/index.sass'
26 changes: 13 additions & 13 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const colors = require('tailwindcss/colors')
import { blue, gray, red } from 'tailwindcss/colors'

module.exports = {
content: [
'./index.html',
'./src/**/*.{vue,js,ts,jsx,tsx}',
'./demo/**/*.{vue,js,ts,jsx,tsx}',
],
theme: {
extend: {},
export const content = [
'./demo/**/*.{vue,js,ts,jsx,tsx}',
'./index.html',
'./src/**/*.{vue,js,ts,jsx,tsx}',
'node_modules/@fancy-crud/vue/*.{js,css}',
]
export const theme = {
extend: {
colors: {
primary: colors.blue,
danger: colors.red,
primary: blue,
danger: red,
inactive: gray,
},
},
plugins: [
],
}
export const plugins = []
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
},
"exclude": [
// "demo",
"demo",
"dist",
"node_modules",
"cypress",
Expand Down
Loading

0 comments on commit fd9fca3

Please sign in to comment.