Skip to content

Commit

Permalink
Use url instead of queryMapping in LiveProp constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
squrious committed Dec 19, 2023
1 parent d0409ca commit d894632
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
9 changes: 1 addition & 8 deletions src/Autocomplete/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */


function __classPrivateFieldGet(receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
}

var _default_1_instances, _default_1_getCommonConfig, _default_1_createAutocomplete, _default_1_createAutocompleteWithHtmlContents, _default_1_createAutocompleteWithRemoteData, _default_1_stripTags, _default_1_mergeObjects, _default_1_createTomSelect;
class default_1 extends Controller {
Expand Down
3 changes: 0 additions & 3 deletions src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,6 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof win
let insertionPoint = oldParent.firstChild;
let newChild;

newParent.children;
oldParent.children;

// run through all the new content
while (nextNewChild) {

Expand Down
12 changes: 6 additions & 6 deletions src/LiveComponent/src/Attribute/LiveProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class LiveProp
*
* Tells if this property should be bound to the URL
*/
private bool $queryMapping;
private bool $url;

/**
* @param bool|array $writable If true, this property can be changed by the frontend.
Expand All @@ -80,7 +80,7 @@ final class LiveProp
* from the value used when originally rendering
* this child, the value in the child will be updated
* to match the new value and the child will be re-rendered
* @param bool $queryMapping if true, this property will be synchronized with a query parameter
* @param bool $url if true, this property will be synchronized with a query parameter
* in the URL
*/
public function __construct(
Expand All @@ -93,7 +93,7 @@ public function __construct(
string $format = null,
bool $updateFromParent = false,
string|array $onUpdated = null,
bool $queryMapping = false,
bool $url = false,
) {
$this->writable = $writable;
$this->hydrateWith = $hydrateWith;
Expand All @@ -104,7 +104,7 @@ public function __construct(
$this->format = $format;
$this->acceptUpdatesFromParent = $updateFromParent;
$this->onUpdated = $onUpdated;
$this->queryMapping = $queryMapping;
$this->url = $url;

if ($this->useSerializerForHydration && ($this->hydrateWith || $this->dehydrateWith)) {
throw new \InvalidArgumentException('Cannot use useSerializerForHydration with hydrateWith or dehydrateWith.');
Expand Down Expand Up @@ -200,8 +200,8 @@ public function onUpdated(): null|string|array
return $this->onUpdated;
}

public function queryMapping(): bool
public function url(): bool
{
return $this->queryMapping;
return $this->url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function createLivePropMetadata(string $className, string $propertyName,
$isTypeBuiltIn,
$isTypeNullable,
$collectionValueType,
$liveProp->queryMapping()
$liveProp->url()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@
class ComponentWithUrlBoundProps
{
use DefaultActionTrait;
#[LiveProp(queryMapping: true)]

#[LiveProp(url: true)]
public ?string $prop1 = null;

#[LiveProp(queryMapping: true)]
#[LiveProp(url: true)]
public ?int $prop2 = null;

#[LiveProp(queryMapping: true)]
#[LiveProp(url: true)]
public array $prop3 = [];

#[LiveProp]
public ?string $prop4 = null;

#[LiveProp(queryMapping: true)]
#[LiveProp(url: true)]
public ?Address $prop5 = null;

#[LiveProp(fieldName: 'field6', queryMapping: true)]
#[LiveProp(fieldName: 'field6', url: true)]
public ?string $prop6 = null;
}

0 comments on commit d894632

Please sign in to comment.