change export
parent
b8c61fe15e
commit
b4c610f9be
|
|
@ -1,44 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exports;
|
|
||||||
|
|
||||||
use App\Models\Contract;
|
|
||||||
|
|
||||||
class BuyContractsSheet extends ContractsSheet
|
|
||||||
{
|
|
||||||
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return Contract::buyContracts()->whereYear('date', '=', $this->year)->orderBy('date', 'asc');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['Ankaufsverträge ' . $this->year],
|
|
||||||
[
|
|
||||||
'Datum',
|
|
||||||
'Auto',
|
|
||||||
'Stammnummer',
|
|
||||||
'Verkäufer',
|
|
||||||
'Betrag',
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($contract): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
$contract->date_formatted,
|
|
||||||
$contract->car->name,
|
|
||||||
$contract->car->stammnummer,
|
|
||||||
$contract->contact->full_title,
|
|
||||||
$contract->price,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function title(): string
|
|
||||||
{
|
|
||||||
return 'Ankaufsverträge';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exports;
|
|
||||||
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
|
||||||
|
|
||||||
class ContractsExport implements WithMultipleSheets
|
|
||||||
{
|
|
||||||
protected $year;
|
|
||||||
|
|
||||||
public function __construct(int $year)
|
|
||||||
{
|
|
||||||
$this->year = $year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sheets(): array
|
|
||||||
{
|
|
||||||
$sheets = [];
|
|
||||||
|
|
||||||
$sheets[] = new ContractsSheet($this->year);
|
|
||||||
$sheets[] = new BuyContractsSheet($this->year);
|
|
||||||
$sheets[] = new SellContractsSheet($this->year);
|
|
||||||
|
|
||||||
return $sheets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exports;
|
|
||||||
|
|
||||||
use App\Models\Contract;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
||||||
use Maatwebsite\Excel\Concerns\RegistersEventListeners;
|
|
||||||
|
|
||||||
class ContractsSheet implements FromQuery, WithTitle, WithHeadings, WithMapping, WithStyles, WithEvents
|
|
||||||
{
|
|
||||||
use RegistersEventListeners;
|
|
||||||
protected $year;
|
|
||||||
|
|
||||||
public function __construct(int $year)
|
|
||||||
{
|
|
||||||
$this->year = $year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return Contract::whereYear('date', '=', $this->year)->orderBy('date', 'asc');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['Alle Verträge ' . $this->year],
|
|
||||||
[
|
|
||||||
'Datum',
|
|
||||||
'Vertragsart',
|
|
||||||
'Auto',
|
|
||||||
'Stammnummer',
|
|
||||||
'Kontakt',
|
|
||||||
'Betrag',
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($contract): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
$contract->date_formatted,
|
|
||||||
$contract->type_formatted,
|
|
||||||
$contract->car->name,
|
|
||||||
$contract->car->stammnummer,
|
|
||||||
$contract->contact->full_title,
|
|
||||||
$contract->price,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function title(): string
|
|
||||||
{
|
|
||||||
return 'Alle Verträge';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function styles(Worksheet $sheet)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
1 => ['font' => ['bold' => true]],
|
|
||||||
2 => ['font' => ['bold' => true]],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Models\Car;
|
||||||
|
use App\Models\Contract;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
|
class Report implements FromCollection ,WithTitle, WithHeadings, WithStyles, WithColumnFormatting, ShouldAutoSize
|
||||||
|
{
|
||||||
|
protected $year;
|
||||||
|
|
||||||
|
public function __construct(int $year)
|
||||||
|
{
|
||||||
|
$this->year = $year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Bezeichnung',
|
||||||
|
'Stammnummer',
|
||||||
|
'Einkaufsdatum',
|
||||||
|
'Einkaufpreis',
|
||||||
|
'Verkäufer',
|
||||||
|
'Verkaufsdatum',
|
||||||
|
'Verkaufspreis',
|
||||||
|
'Käufer',
|
||||||
|
'Lagerbestand',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$cars = Contract::with('car')->soldByYear($this->year)->get()->pluck('car');
|
||||||
|
$cars = $cars->merge(Car::unsoldOnly()->get())->unique()->map(function ($car) {
|
||||||
|
$bcontract = $car->latestBuyContract();
|
||||||
|
$scontract = $car->latestSellContract();
|
||||||
|
if (!$car->isSold()) {
|
||||||
|
$scontract = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'title' => $car->name_with_year,
|
||||||
|
'stammnummer' => $car->stammnummer,
|
||||||
|
'buy_date' => $bcontract ? Date::dateTimeToExcel(Carbon::parse($bcontract->date)) : null,
|
||||||
|
'buy_price' => $bcontract ? $bcontract->price_for_excel : null,
|
||||||
|
'seller' => $bcontract ? $bcontract->contact->full_title_with_address : null,
|
||||||
|
'sell_date' => $scontract ? Date::dateTimeToExcel(Carbon::parse($scontract->date)) : null,
|
||||||
|
'sell_price' => $scontract ? $scontract->price_for_excel : null,
|
||||||
|
'buyer' => $scontract ? $scontract->contact->full_title_with_address : null,
|
||||||
|
'lager' => !$scontract && $bcontract ? $bcontract->price_for_excel : null,
|
||||||
|
];
|
||||||
|
})->sortBy('buy_date');
|
||||||
|
|
||||||
|
return $cars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function styles(Worksheet $sheet)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
1 => ['font' => ['bold' => true]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'C' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||||
|
'D' => NumberFormat::FORMAT_NUMBER_00,
|
||||||
|
'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||||
|
'G' => NumberFormat::FORMAT_NUMBER_00,
|
||||||
|
'I' => NumberFormat::FORMAT_NUMBER_00,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function title(): string
|
||||||
|
{
|
||||||
|
return 'Wagenhandelbuch ' . $this->year;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exports;
|
|
||||||
|
|
||||||
use App\Models\Contract;
|
|
||||||
use Maatwebsite\Excel\Events\AfterSheet;
|
|
||||||
|
|
||||||
class SellContractsSheet extends ContractsSheet
|
|
||||||
{
|
|
||||||
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return Contract::sellContracts()->whereYear('date', '=', $this->year)->orderBy('date', 'asc');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['Verkaufsverträge ' . $this->year],
|
|
||||||
[
|
|
||||||
'Datum',
|
|
||||||
'Auto',
|
|
||||||
'Stammnummer',
|
|
||||||
'Käufer',
|
|
||||||
'Versicherung',
|
|
||||||
'Betrag',
|
|
||||||
'Eingezahlt',
|
|
||||||
'Noch offen'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($contract): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
$contract->date_formatted,
|
|
||||||
$contract->car->name,
|
|
||||||
$contract->car->stammnummer,
|
|
||||||
$contract->contact->full_title,
|
|
||||||
$contract->insurance_type_formatted,
|
|
||||||
$contract->price,
|
|
||||||
$contract->paid,
|
|
||||||
$contract->left_to_pay,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function title(): string
|
|
||||||
{
|
|
||||||
return 'Verkaufsverträge';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use App\Models\Contract;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Exports\ContractsExport;
|
use App\Exports\Report;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
|
||||||
use Maatwebsite\Excel\Facades\Excel as Excel;
|
use Maatwebsite\Excel\Facades\Excel as Excel;
|
||||||
|
|
||||||
class ReportController extends Controller
|
class ReportController extends Controller
|
||||||
|
|
@ -19,6 +17,6 @@ class ReportController extends Controller
|
||||||
public function print(Request $request)
|
public function print(Request $request)
|
||||||
{
|
{
|
||||||
$year = (int)$request->get('year');
|
$year = (int)$request->get('year');
|
||||||
return Excel::download(new ContractsExport($year), 'Jahresbericht-' . $year .'.xlsx');
|
return Excel::download(new Report($year), 'Wagenhandelbuch-' . $year .'.xlsx');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class Car extends Model
|
||||||
|
|
||||||
public function isSold()
|
public function isSold()
|
||||||
{
|
{
|
||||||
return $this->buyContracts()->count() >= 1 && $this->buyContracts()->count() <= $this->sellContracts()->count();
|
return $this->buyContracts()->count() <= $this->sellContracts()->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function contracts()
|
public function contracts()
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,12 @@ class Contact extends Model
|
||||||
return implode(', ', array_filter([$this->company, $this->name]));
|
return implode(', ', array_filter([$this->company, $this->name]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getFullTitleWithAddressAttribute()
|
||||||
|
{
|
||||||
|
return implode(', ', array_filter([$this->full_title, $this->address, $this->full_city]));
|
||||||
|
}
|
||||||
|
|
||||||
public function getFullCityAttribute()
|
public function getFullCityAttribute()
|
||||||
{
|
{
|
||||||
return $this->zip . ' ' . $this->city;
|
return $this->zip . ' ' . $this->city;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ class Contract extends Model
|
||||||
return Money::CHF($price);
|
return Money::CHF($price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPriceForExcelAttribute()
|
||||||
|
{
|
||||||
|
return $this->price->format(null, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function getPaidAttribute()
|
public function getPaidAttribute()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -129,6 +134,11 @@ class Contract extends Model
|
||||||
$query->sellContracts()->thisYear();
|
$query->sellContracts()->thisYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeSoldByYear($query, $year)
|
||||||
|
{
|
||||||
|
$query->sellContracts()->whereYear('date', $year);
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeBoughtThisYear($query)
|
public function scopeBoughtThisYear($query)
|
||||||
{
|
{
|
||||||
$query->buyContracts()->thisYear();
|
$query->buyContracts()->thisYear();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/*! tailwindcss v2.2.2 | MIT License | https://tailwindcss.com */
|
/*! tailwindcss v2.2.4 | MIT License | https://tailwindcss.com */
|
||||||
|
|
||||||
/*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
|
/*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
|
||||||
|
|
||||||
|
|
@ -332,16 +332,6 @@ button {
|
||||||
background-image: none;
|
background-image: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Work around a Firefox/IE bug where the transparent `button` background
|
|
||||||
* results in a loss of the default `button` focus styles.
|
|
||||||
*/
|
|
||||||
|
|
||||||
button:focus {
|
|
||||||
outline: 1px dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
||||||
|
|
@ -502,18 +502,59 @@ function isCoreComponent(tag) {
|
||||||
}
|
}
|
||||||
const nonIdentifierRE = /^\d|[^\$\w]/;
|
const nonIdentifierRE = /^\d|[^\$\w]/;
|
||||||
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
||||||
const memberExpRE = /^[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*(?:\s*\.\s*[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*|\[(.+)\])*$/;
|
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
||||||
|
const validIdentCharRE = /[\.\w$\xA0-\uFFFF]/;
|
||||||
|
const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
||||||
|
/**
|
||||||
|
* Simple lexer to check if an expression is a member expression. This is
|
||||||
|
* lax and only checks validity at the root level (i.e. does not validate exps
|
||||||
|
* inside square brackets), but it's ok since these are only used on template
|
||||||
|
* expressions and false positives are invalid expressions in the first place.
|
||||||
|
*/
|
||||||
const isMemberExpression = (path) => {
|
const isMemberExpression = (path) => {
|
||||||
if (!path)
|
// remove whitespaces around . or [ first
|
||||||
|
path = path.trim().replace(whitespaceRE, s => s.trim());
|
||||||
|
let state = 0 /* inMemberExp */;
|
||||||
|
let prevState = 0 /* inMemberExp */;
|
||||||
|
let currentOpenBracketCount = 0;
|
||||||
|
let currentStringType = null;
|
||||||
|
for (let i = 0; i < path.length; i++) {
|
||||||
|
const char = path.charAt(i);
|
||||||
|
switch (state) {
|
||||||
|
case 0 /* inMemberExp */:
|
||||||
|
if (char === '[') {
|
||||||
|
prevState = state;
|
||||||
|
state = 1 /* inBrackets */;
|
||||||
|
currentOpenBracketCount++;
|
||||||
|
}
|
||||||
|
else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
||||||
return false;
|
return false;
|
||||||
const matched = memberExpRE.exec(path.trim());
|
}
|
||||||
if (!matched)
|
break;
|
||||||
return false;
|
case 1 /* inBrackets */:
|
||||||
if (!matched[1])
|
if (char === `'` || char === `"` || char === '`') {
|
||||||
return true;
|
prevState = state;
|
||||||
if (!/[\[\]]/.test(matched[1]))
|
state = 2 /* inString */;
|
||||||
return true;
|
currentStringType = char;
|
||||||
return isMemberExpression(matched[1].trim());
|
}
|
||||||
|
else if (char === `[`) {
|
||||||
|
currentOpenBracketCount++;
|
||||||
|
}
|
||||||
|
else if (char === `]`) {
|
||||||
|
if (!--currentOpenBracketCount) {
|
||||||
|
state = prevState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2 /* inString */:
|
||||||
|
if (char === currentStringType) {
|
||||||
|
state = prevState;
|
||||||
|
currentStringType = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !currentOpenBracketCount;
|
||||||
};
|
};
|
||||||
function getInnerRange(loc, offset, length) {
|
function getInnerRange(loc, offset, length) {
|
||||||
const source = loc.source.substr(offset, length);
|
const source = loc.source.substr(offset, length);
|
||||||
|
|
@ -1194,43 +1235,19 @@ function parseTag(context, type, parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let tagType = 0 /* ELEMENT */;
|
let tagType = 0 /* ELEMENT */;
|
||||||
const options = context.options;
|
if (!context.inVPre) {
|
||||||
if (!context.inVPre && !options.isCustomElement(tag)) {
|
|
||||||
const hasVIs = props.some(p => {
|
|
||||||
if (p.name !== 'is')
|
|
||||||
return;
|
|
||||||
// v-is="xxx" (TODO: deprecate)
|
|
||||||
if (p.type === 7 /* DIRECTIVE */) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// is="vue:xxx"
|
|
||||||
if (p.value && p.value.content.startsWith('vue:')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// in compat mode, any is usage is considered a component
|
|
||||||
if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (options.isNativeTag && !hasVIs) {
|
|
||||||
if (!options.isNativeTag(tag))
|
|
||||||
tagType = 1 /* COMPONENT */;
|
|
||||||
}
|
|
||||||
else if (hasVIs ||
|
|
||||||
isCoreComponent(tag) ||
|
|
||||||
(options.isBuiltInComponent && options.isBuiltInComponent(tag)) ||
|
|
||||||
/^[A-Z]/.test(tag) ||
|
|
||||||
tag === 'component') {
|
|
||||||
tagType = 1 /* COMPONENT */;
|
|
||||||
}
|
|
||||||
if (tag === 'slot') {
|
if (tag === 'slot') {
|
||||||
tagType = 2 /* SLOT */;
|
tagType = 2 /* SLOT */;
|
||||||
}
|
}
|
||||||
else if (tag === 'template' &&
|
else if (tag === 'template') {
|
||||||
props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
|
if (props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
|
||||||
tagType = 3 /* TEMPLATE */;
|
tagType = 3 /* TEMPLATE */;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (isComponent(tag, props, context)) {
|
||||||
|
tagType = 1 /* COMPONENT */;
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
type: 1 /* ELEMENT */,
|
type: 1 /* ELEMENT */,
|
||||||
ns,
|
ns,
|
||||||
|
|
@ -1243,6 +1260,49 @@ function parseTag(context, type, parent) {
|
||||||
codegenNode: undefined // to be created during transform phase
|
codegenNode: undefined // to be created during transform phase
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function isComponent(tag, props, context) {
|
||||||
|
const options = context.options;
|
||||||
|
if (options.isCustomElement(tag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (tag === 'component' ||
|
||||||
|
/^[A-Z]/.test(tag) ||
|
||||||
|
isCoreComponent(tag) ||
|
||||||
|
(options.isBuiltInComponent && options.isBuiltInComponent(tag)) ||
|
||||||
|
(options.isNativeTag && !options.isNativeTag(tag))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// at this point the tag should be a native tag, but check for potential "is"
|
||||||
|
// casting
|
||||||
|
for (let i = 0; i < props.length; i++) {
|
||||||
|
const p = props[i];
|
||||||
|
if (p.type === 6 /* ATTRIBUTE */) {
|
||||||
|
if (p.name === 'is' && p.value) {
|
||||||
|
if (p.value.content.startsWith('vue:')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// directive
|
||||||
|
// v-is (TODO Deprecate)
|
||||||
|
if (p.name === 'is') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
// :is on plain element - only treat as component in compat mode
|
||||||
|
p.name === 'bind' &&
|
||||||
|
isBindKey(p.arg, 'is') &&
|
||||||
|
true &&
|
||||||
|
checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function parseAttributes(context, type) {
|
function parseAttributes(context, type) {
|
||||||
const props = [];
|
const props = [];
|
||||||
const attributeNames = new Set();
|
const attributeNames = new Set();
|
||||||
|
|
@ -3564,16 +3624,10 @@ function resolveComponentType(node, context, ssr = false) {
|
||||||
let { tag } = node;
|
let { tag } = node;
|
||||||
// 1. dynamic component
|
// 1. dynamic component
|
||||||
const isExplicitDynamic = isComponentTag(tag);
|
const isExplicitDynamic = isComponentTag(tag);
|
||||||
const isProp = findProp(node, 'is') || (!isExplicitDynamic && findDir(node, 'is'));
|
const isProp = findProp(node, 'is');
|
||||||
if (isProp) {
|
if (isProp) {
|
||||||
if (!isExplicitDynamic && isProp.type === 6 /* ATTRIBUTE */) {
|
if (isExplicitDynamic ||
|
||||||
// <button is="vue:xxx">
|
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))) {
|
||||||
// if not <component>, only is value that starts with "vue:" will be
|
|
||||||
// treated as component by the parse phase and reach here, unless it's
|
|
||||||
// compat mode where all is values are considered components
|
|
||||||
tag = isProp.value.content.replace(/^vue:/, '');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const exp = isProp.type === 6 /* ATTRIBUTE */
|
const exp = isProp.type === 6 /* ATTRIBUTE */
|
||||||
? isProp.value && createSimpleExpression(isProp.value.content, true)
|
? isProp.value && createSimpleExpression(isProp.value.content, true)
|
||||||
: isProp.exp;
|
: isProp.exp;
|
||||||
|
|
@ -3583,6 +3637,21 @@ function resolveComponentType(node, context, ssr = false) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (isProp.type === 6 /* ATTRIBUTE */ &&
|
||||||
|
isProp.value.content.startsWith('vue:')) {
|
||||||
|
// <button is="vue:xxx">
|
||||||
|
// if not <component>, only is value that starts with "vue:" will be
|
||||||
|
// treated as component by the parse phase and reach here, unless it's
|
||||||
|
// compat mode where all is values are considered components
|
||||||
|
tag = isProp.value.content.slice(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 1.5 v-is (TODO: Deprecate)
|
||||||
|
const isDir = !isExplicitDynamic && findDir(node, 'is');
|
||||||
|
if (isDir && isDir.exp) {
|
||||||
|
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
||||||
|
isDir.exp
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// 2. built-in components (Teleport, Transition, KeepAlive, Suspense...)
|
// 2. built-in components (Teleport, Transition, KeepAlive, Suspense...)
|
||||||
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
||||||
|
|
@ -3666,7 +3735,9 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
||||||
}
|
}
|
||||||
// skip is on <component>, or is="vue:xxx"
|
// skip is on <component>, or is="vue:xxx"
|
||||||
if (name === 'is' &&
|
if (name === 'is' &&
|
||||||
(isComponentTag(tag) || (value && value.content.startsWith('vue:')))) {
|
(isComponentTag(tag) ||
|
||||||
|
(value && value.content.startsWith('vue:')) ||
|
||||||
|
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
|
properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
|
||||||
|
|
@ -3689,7 +3760,10 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
||||||
}
|
}
|
||||||
// skip v-is and :is on <component>
|
// skip v-is and :is on <component>
|
||||||
if (name === 'is' ||
|
if (name === 'is' ||
|
||||||
(isVBind && isComponentTag(tag) && isBindKey(arg, 'is'))) {
|
(isVBind &&
|
||||||
|
isBindKey(arg, 'is') &&
|
||||||
|
(isComponentTag(tag) ||
|
||||||
|
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// skip v-on in SSR compilation
|
// skip v-on in SSR compilation
|
||||||
|
|
@ -4233,7 +4307,7 @@ const transformModel = (dir, node, context) => {
|
||||||
// _unref(exp)
|
// _unref(exp)
|
||||||
context.bindingMetadata[rawExp];
|
context.bindingMetadata[rawExp];
|
||||||
const maybeRef = !true /* SETUP_CONST */;
|
const maybeRef = !true /* SETUP_CONST */;
|
||||||
if (!isMemberExpression(expString) && !maybeRef) {
|
if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
|
||||||
context.onError(createCompilerError(41 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
|
context.onError(createCompilerError(41 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
|
||||||
return createTransformProps();
|
return createTransformProps();
|
||||||
}
|
}
|
||||||
|
|
@ -6079,7 +6153,7 @@ function shallowRef(value) {
|
||||||
return createRef(value, true);
|
return createRef(value, true);
|
||||||
}
|
}
|
||||||
class RefImpl {
|
class RefImpl {
|
||||||
constructor(_rawValue, _shallow = false) {
|
constructor(_rawValue, _shallow) {
|
||||||
this._rawValue = _rawValue;
|
this._rawValue = _rawValue;
|
||||||
this._shallow = _shallow;
|
this._shallow = _shallow;
|
||||||
this.__v_isRef = true;
|
this.__v_isRef = true;
|
||||||
|
|
@ -7328,11 +7402,12 @@ function emit(instance, event, ...rawArgs) {
|
||||||
const onceHandler = props[handlerName + `Once`];
|
const onceHandler = props[handlerName + `Once`];
|
||||||
if (onceHandler) {
|
if (onceHandler) {
|
||||||
if (!instance.emitted) {
|
if (!instance.emitted) {
|
||||||
(instance.emitted = {})[handlerName] = true;
|
instance.emitted = {};
|
||||||
}
|
}
|
||||||
else if (instance.emitted[handlerName]) {
|
else if (instance.emitted[handlerName]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
instance.emitted[handlerName] = true;
|
||||||
callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
|
callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7799,6 +7874,12 @@ const SuspenseImpl = {
|
||||||
// Force-casted public typing for h and TSX props inference
|
// Force-casted public typing for h and TSX props inference
|
||||||
const Suspense = (SuspenseImpl
|
const Suspense = (SuspenseImpl
|
||||||
);
|
);
|
||||||
|
function triggerEvent(vnode, name) {
|
||||||
|
const eventListener = vnode.props && vnode.props[name];
|
||||||
|
if ((0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.isFunction)(eventListener)) {
|
||||||
|
eventListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
|
function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
|
||||||
const { p: patch, o: { createElement } } = rendererInternals;
|
const { p: patch, o: { createElement } } = rendererInternals;
|
||||||
const hiddenContainer = createElement('div');
|
const hiddenContainer = createElement('div');
|
||||||
|
|
@ -7808,6 +7889,9 @@ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense
|
||||||
// now check if we have encountered any async deps
|
// now check if we have encountered any async deps
|
||||||
if (suspense.deps > 0) {
|
if (suspense.deps > 0) {
|
||||||
// has async
|
// has async
|
||||||
|
// invoke @fallback event
|
||||||
|
triggerEvent(vnode, 'onPending');
|
||||||
|
triggerEvent(vnode, 'onFallback');
|
||||||
// mount the fallback tree
|
// mount the fallback tree
|
||||||
patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
|
patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
|
||||||
isSVG, slotScopeIds);
|
isSVG, slotScopeIds);
|
||||||
|
|
@ -7895,10 +7979,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
|
||||||
else {
|
else {
|
||||||
// root node toggled
|
// root node toggled
|
||||||
// invoke @pending event
|
// invoke @pending event
|
||||||
const onPending = n2.props && n2.props.onPending;
|
triggerEvent(n2, 'onPending');
|
||||||
if ((0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.isFunction)(onPending)) {
|
|
||||||
onPending();
|
|
||||||
}
|
|
||||||
// mount pending branch in off-dom container
|
// mount pending branch in off-dom container
|
||||||
suspense.pendingBranch = newBranch;
|
suspense.pendingBranch = newBranch;
|
||||||
suspense.pendingId++;
|
suspense.pendingId++;
|
||||||
|
|
@ -8011,10 +8092,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
|
||||||
}
|
}
|
||||||
suspense.effects = [];
|
suspense.effects = [];
|
||||||
// invoke @resolve event
|
// invoke @resolve event
|
||||||
const onResolve = vnode.props && vnode.props.onResolve;
|
triggerEvent(vnode, 'onResolve');
|
||||||
if ((0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.isFunction)(onResolve)) {
|
|
||||||
onResolve();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fallback(fallbackVNode) {
|
fallback(fallbackVNode) {
|
||||||
if (!suspense.pendingBranch) {
|
if (!suspense.pendingBranch) {
|
||||||
|
|
@ -8022,10 +8100,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
|
||||||
}
|
}
|
||||||
const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
|
const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
|
||||||
// invoke @fallback event
|
// invoke @fallback event
|
||||||
const onFallback = vnode.props && vnode.props.onFallback;
|
triggerEvent(vnode, 'onFallback');
|
||||||
if ((0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.isFunction)(onFallback)) {
|
|
||||||
onFallback();
|
|
||||||
}
|
|
||||||
const anchor = next(activeBranch);
|
const anchor = next(activeBranch);
|
||||||
const mountFallback = () => {
|
const mountFallback = () => {
|
||||||
if (!suspense.isInFallback) {
|
if (!suspense.isInFallback) {
|
||||||
|
|
@ -8040,11 +8115,11 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
|
||||||
if (delayEnter) {
|
if (delayEnter) {
|
||||||
activeBranch.transition.afterLeave = mountFallback;
|
activeBranch.transition.afterLeave = mountFallback;
|
||||||
}
|
}
|
||||||
|
suspense.isInFallback = true;
|
||||||
// unmount current active branch
|
// unmount current active branch
|
||||||
unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
|
unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
|
||||||
true // shouldRemove
|
true // shouldRemove
|
||||||
);
|
);
|
||||||
suspense.isInFallback = true;
|
|
||||||
if (!delayEnter) {
|
if (!delayEnter) {
|
||||||
mountFallback();
|
mountFallback();
|
||||||
}
|
}
|
||||||
|
|
@ -8239,7 +8314,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
||||||
}
|
}
|
||||||
else if (arguments.length > 1) {
|
else if (arguments.length > 1) {
|
||||||
return treatDefaultAsFactory && (0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.isFunction)(defaultValue)
|
return treatDefaultAsFactory && (0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.isFunction)(defaultValue)
|
||||||
? defaultValue()
|
? defaultValue.call(instance.proxy)
|
||||||
: defaultValue;
|
: defaultValue;
|
||||||
}
|
}
|
||||||
else if ((true)) {
|
else if ((true)) {
|
||||||
|
|
@ -9601,25 +9676,23 @@ const internalOptionMergeStrats = {
|
||||||
methods: mergeObjectOptions,
|
methods: mergeObjectOptions,
|
||||||
computed: mergeObjectOptions,
|
computed: mergeObjectOptions,
|
||||||
// lifecycle
|
// lifecycle
|
||||||
beforeCreate: mergeHook,
|
beforeCreate: mergeAsArray,
|
||||||
created: mergeHook,
|
created: mergeAsArray,
|
||||||
beforeMount: mergeHook,
|
beforeMount: mergeAsArray,
|
||||||
mounted: mergeHook,
|
mounted: mergeAsArray,
|
||||||
beforeUpdate: mergeHook,
|
beforeUpdate: mergeAsArray,
|
||||||
updated: mergeHook,
|
updated: mergeAsArray,
|
||||||
beforeDestroy: mergeHook,
|
beforeDestroy: mergeAsArray,
|
||||||
destroyed: mergeHook,
|
destroyed: mergeAsArray,
|
||||||
activated: mergeHook,
|
activated: mergeAsArray,
|
||||||
deactivated: mergeHook,
|
deactivated: mergeAsArray,
|
||||||
errorCaptured: mergeHook,
|
errorCaptured: mergeAsArray,
|
||||||
serverPrefetch: mergeHook,
|
serverPrefetch: mergeAsArray,
|
||||||
// assets
|
// assets
|
||||||
components: mergeObjectOptions,
|
components: mergeObjectOptions,
|
||||||
directives: mergeObjectOptions,
|
directives: mergeObjectOptions,
|
||||||
// watch has special merge behavior in v2, but isn't actually needed in v3.
|
// watch
|
||||||
// since we are only exposing these for compat and nobody should be relying
|
watch: mergeWatchOptions,
|
||||||
// on the watch-specific behavior, just expose the object merge strat.
|
|
||||||
watch: mergeObjectOptions,
|
|
||||||
// provide / inject
|
// provide / inject
|
||||||
provide: mergeDataFn,
|
provide: mergeDataFn,
|
||||||
inject: mergeInject
|
inject: mergeInject
|
||||||
|
|
@ -9648,12 +9721,23 @@ function normalizeInject(raw) {
|
||||||
}
|
}
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
function mergeHook(to, from) {
|
function mergeAsArray(to, from) {
|
||||||
return to ? [...new Set([].concat(to, from))] : from;
|
return to ? [...new Set([].concat(to, from))] : from;
|
||||||
}
|
}
|
||||||
function mergeObjectOptions(to, from) {
|
function mergeObjectOptions(to, from) {
|
||||||
return to ? (0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.extend)((0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.extend)(Object.create(null), to), from) : from;
|
return to ? (0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.extend)((0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.extend)(Object.create(null), to), from) : from;
|
||||||
}
|
}
|
||||||
|
function mergeWatchOptions(to, from) {
|
||||||
|
if (!to)
|
||||||
|
return from;
|
||||||
|
if (!from)
|
||||||
|
return to;
|
||||||
|
const merged = (0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.extend)(Object.create(null), to);
|
||||||
|
for (const key in from) {
|
||||||
|
merged[key] = mergeAsArray(to[key], from[key]);
|
||||||
|
}
|
||||||
|
return merged;
|
||||||
|
}
|
||||||
|
|
||||||
function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
|
function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
|
||||||
isSSR = false) {
|
isSSR = false) {
|
||||||
|
|
@ -10311,6 +10395,7 @@ function createAppAPI(render, hydrate) {
|
||||||
_props: rootProps,
|
_props: rootProps,
|
||||||
_container: null,
|
_container: null,
|
||||||
_context: context,
|
_context: context,
|
||||||
|
_instance: null,
|
||||||
version,
|
version,
|
||||||
get config() {
|
get config() {
|
||||||
return context.config;
|
return context.config;
|
||||||
|
|
@ -10401,6 +10486,7 @@ function createAppAPI(render, hydrate) {
|
||||||
app._container = rootContainer;
|
app._container = rootContainer;
|
||||||
rootContainer.__vue_app__ = app;
|
rootContainer.__vue_app__ = app;
|
||||||
if (true) {
|
if (true) {
|
||||||
|
app._instance = vnode.component;
|
||||||
devtoolsInitApp(app, version);
|
devtoolsInitApp(app, version);
|
||||||
}
|
}
|
||||||
return vnode.component.proxy;
|
return vnode.component.proxy;
|
||||||
|
|
@ -10416,6 +10502,7 @@ function createAppAPI(render, hydrate) {
|
||||||
if (isMounted) {
|
if (isMounted) {
|
||||||
render(null, app._container);
|
render(null, app._container);
|
||||||
if (true) {
|
if (true) {
|
||||||
|
app._instance = null;
|
||||||
devtoolsUnmountApp(app);
|
devtoolsUnmountApp(app);
|
||||||
}
|
}
|
||||||
delete app._container.__vue_app__;
|
delete app._container.__vue_app__;
|
||||||
|
|
@ -11023,7 +11110,11 @@ function baseCreateRenderer(options, createHydrationFns) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const mountStaticNode = (n2, container, anchor, isSVG) => {
|
const mountStaticNode = (n2, container, anchor, isSVG) => {
|
||||||
[n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
[n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG,
|
||||||
|
// pass cached nodes if the static node is being mounted multiple times
|
||||||
|
// so that runtime-dom can simply cloneNode() instead of inserting new
|
||||||
|
// HTML
|
||||||
|
n2.el && [n2.el, n2.anchor]);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Dev / HMR only
|
* Dev / HMR only
|
||||||
|
|
@ -13062,10 +13153,6 @@ const publicPropertiesMap = (0,_vue_shared__WEBPACK_IMPORTED_MODULE_1__.extend)(
|
||||||
const PublicInstanceProxyHandlers = {
|
const PublicInstanceProxyHandlers = {
|
||||||
get({ _: instance }, key) {
|
get({ _: instance }, key) {
|
||||||
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
||||||
// let @vue/reactivity know it should never observe Vue public instances.
|
|
||||||
if (key === "__v_skip" /* SKIP */) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// for internal formatters to know that this is a Vue instance
|
// for internal formatters to know that this is a Vue instance
|
||||||
if (( true) && key === '__isVue') {
|
if (( true) && key === '__isVue') {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -13421,7 +13508,7 @@ function setupStatefulComponent(instance, isSSR) {
|
||||||
instance.accessCache = Object.create(null);
|
instance.accessCache = Object.create(null);
|
||||||
// 1. create public instance / render proxy
|
// 1. create public instance / render proxy
|
||||||
// also mark it raw so it's never observed
|
// also mark it raw so it's never observed
|
||||||
instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
|
instance.proxy = (0,_vue_reactivity__WEBPACK_IMPORTED_MODULE_0__.markRaw)(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
||||||
if ((true)) {
|
if ((true)) {
|
||||||
exposePropsOnRenderContext(instance);
|
exposePropsOnRenderContext(instance);
|
||||||
}
|
}
|
||||||
|
|
@ -13896,7 +13983,7 @@ function initCustomFormatter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Core API ------------------------------------------------------------------
|
// Core API ------------------------------------------------------------------
|
||||||
const version = "3.1.1";
|
const version = "3.1.2";
|
||||||
/**
|
/**
|
||||||
* SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
|
* SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -14051,8 +14138,6 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
|
|
||||||
const svgNS = 'http://www.w3.org/2000/svg';
|
const svgNS = 'http://www.w3.org/2000/svg';
|
||||||
const doc = (typeof document !== 'undefined' ? document : null);
|
const doc = (typeof document !== 'undefined' ? document : null);
|
||||||
let tempContainer;
|
|
||||||
let tempSVGContainer;
|
|
||||||
const nodeOps = {
|
const nodeOps = {
|
||||||
insert: (child, parent, anchor) => {
|
insert: (child, parent, anchor) => {
|
||||||
parent.insertBefore(child, anchor || null);
|
parent.insertBefore(child, anchor || null);
|
||||||
|
|
@ -14103,25 +14188,58 @@ const nodeOps = {
|
||||||
return cloned;
|
return cloned;
|
||||||
},
|
},
|
||||||
// __UNSAFE__
|
// __UNSAFE__
|
||||||
// Reason: innerHTML.
|
// Reason: insertAdjacentHTML.
|
||||||
// Static content here can only come from compiled templates.
|
// Static content here can only come from compiled templates.
|
||||||
// As long as the user only uses trusted templates, this is safe.
|
// As long as the user only uses trusted templates, this is safe.
|
||||||
insertStaticContent(content, parent, anchor, isSVG) {
|
insertStaticContent(content, parent, anchor, isSVG, cached) {
|
||||||
const temp = isSVG
|
if (cached) {
|
||||||
? tempSVGContainer ||
|
let [cachedFirst, cachedLast] = cached;
|
||||||
(tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
|
let first, last;
|
||||||
: tempContainer || (tempContainer = doc.createElement('div'));
|
while (true) {
|
||||||
temp.innerHTML = content;
|
let node = cachedFirst.cloneNode(true);
|
||||||
const first = temp.firstChild;
|
if (!first)
|
||||||
let node = first;
|
first = node;
|
||||||
let last = node;
|
parent.insertBefore(node, anchor);
|
||||||
while (node) {
|
if (cachedFirst === cachedLast) {
|
||||||
last = node;
|
last = node;
|
||||||
nodeOps.insert(node, parent, anchor);
|
break;
|
||||||
node = temp.firstChild;
|
}
|
||||||
|
cachedFirst = cachedFirst.nextSibling;
|
||||||
}
|
}
|
||||||
return [first, last];
|
return [first, last];
|
||||||
}
|
}
|
||||||
|
// <parent> before | first ... last | anchor </parent>
|
||||||
|
const before = anchor ? anchor.previousSibling : parent.lastChild;
|
||||||
|
if (anchor) {
|
||||||
|
let insertionPoint;
|
||||||
|
let usingTempInsertionPoint = false;
|
||||||
|
if (anchor instanceof Element) {
|
||||||
|
insertionPoint = anchor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// insertAdjacentHTML only works for elements but the anchor is not an
|
||||||
|
// element...
|
||||||
|
usingTempInsertionPoint = true;
|
||||||
|
insertionPoint = isSVG
|
||||||
|
? doc.createElementNS(svgNS, 'g')
|
||||||
|
: doc.createElement('div');
|
||||||
|
parent.insertBefore(insertionPoint, anchor);
|
||||||
|
}
|
||||||
|
insertionPoint.insertAdjacentHTML('beforebegin', content);
|
||||||
|
if (usingTempInsertionPoint) {
|
||||||
|
parent.removeChild(insertionPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parent.insertAdjacentHTML('beforeend', content);
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
// first
|
||||||
|
before ? before.nextSibling : parent.firstChild,
|
||||||
|
// last
|
||||||
|
anchor ? anchor.previousSibling : parent.lastChild
|
||||||
|
];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// compiler should normalize class + :class bindings on the same element
|
// compiler should normalize class + :class bindings on the same element
|
||||||
|
|
@ -18518,7 +18636,6 @@ var STATUS_FAILED = 2;
|
||||||
|
|
||||||
// upload data to the server
|
// upload data to the server
|
||||||
this.currentStatus = STATUS_SAVING;
|
this.currentStatus = STATUS_SAVING;
|
||||||
console.log(this.route('documents.store'));
|
|
||||||
axios.post(this.route('documents.store'), formData).then(function (response) {
|
axios.post(this.route('documents.store'), formData).then(function (response) {
|
||||||
_this.documents.push(response.data);
|
_this.documents.push(response.data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ export default {
|
||||||
save(formData) {
|
save(formData) {
|
||||||
// upload data to the server
|
// upload data to the server
|
||||||
this.currentStatus = STATUS_SAVING;
|
this.currentStatus = STATUS_SAVING;
|
||||||
console.log(this.route('documents.store'));
|
|
||||||
axios.post(this.route('documents.store'), formData)
|
axios.post(this.route('documents.store'), formData)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.documents.push(response.data);
|
this.documents.push(response.data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue